Questions tagged [model]

Part of the MVC pattern, the Model manages the behaviour and data of the application.

The MVC (Model, View, Controller) pattern separates objects into one of three categories — models for maintaining data, views for displaying all or a portion of the data, and controllers for handling events that affect the model or view(s).

Frameworks such as Laravel, Rails, Django and ASP.NET MVC apply this pattern in the web development domain.

18996 questions
4
votes
3 answers

Recursive model in Rails

I have a trouble trying to get this working. I have an Item model, and each Item can have other items or nothing. So is this possible or do I need to do some magic?
Trausti Thor
  • 3,722
  • 31
  • 41
4
votes
5 answers

How to fix a Database Error and ghost migration error in Django?

I am getting an DatabaseError saying no column named playlist exists and I'm trying to figure out how to fix it. I'm using South. I deleted the old files in the my migrations folder and ran: python manage.py schemamigration app_name…
sharataka
  • 5,014
  • 20
  • 65
  • 125
4
votes
1 answer

How to exactly detect iDevice model?

I want to detect what iDevice the user has and then put the device name in a UILabel. With the following code the App detects only the iPhone/iPad/iPod I like to have iPhone 4/iPod 3G/iPad 1G... or the exact names (iPhone 3.1/iPod 2.0/ iPad…
David Gölzhäuser
  • 3,525
  • 8
  • 50
  • 98
4
votes
4 answers

How can I extend the Model in ASP.NET MVC and Entity Framework?

In my first ASP.NET MVC applications, the model was a simple O/R mapping between a table and the classes, managed by the Entity Framework. Now I would like to add some meat to this skeleton, and introduce business methods for the generated classes.…
mjn
  • 36,362
  • 28
  • 176
  • 378
4
votes
1 answer

What's the right way to remove multiple indices for a QStandardItemModel?

I was trying to remove all selected indices of a QTableView, Now I use: foreach (const QModelIndex & idx, model->selectionModel()->selectedIndexes()) { model->removeRow (idx.row()); // Obviously bug } There's a obvious problem that once you…
daisy
  • 22,498
  • 29
  • 129
  • 265
4
votes
3 answers

edit uri of existing resource using jena

I try to modify the uri of an existing resource of a ontology model. I thought of creating a new model, new resource (including the new desired uri) and duplicating the content of the old resource. By iterating and adding the statements doens't work…
wassermine
  • 131
  • 1
  • 1
  • 9
4
votes
1 answer

Rails model attr_accessor attribute not saving?

Here is the structure I'm working with: app/models/model.rb class Model < ActiveRecord::Base attr_accessor :some_var end app/models/model_controller.rb class ModelsController < ApplicationController def show @model =…
tanookiben
  • 22,575
  • 8
  • 27
  • 25
4
votes
3 answers

MySQL - SELECT data and create a "virtual" table

Let's say my database table looks like this: page_table | id | page_id | meta_id | value ---------------------------------------- | 1 | 2 | 1 | Testing value | 2 | 2 | 2 | Small content | 3 | 2 | 1 | Another…
Jens Törnell
  • 23,180
  • 45
  • 124
  • 206
4
votes
3 answers

Model alias in ExtJs

I have definition of my model. Here is: Ext.define('KP.model.account.AccountList', { extend: 'Ext.data.Model', alias: 'model.d_AccountList', fields: ['key', 'number', 'personal_account', 'full_name', 'adress', 'pu'] }); So, I want to…
Oleg
  • 1,467
  • 4
  • 26
  • 39
4
votes
1 answer

Django Model: How to use mixin class to override django model for function likes save

I want to validate value before every model save. So, I must override the save function. The code is nearly just the same on, and I want to write it in a mixin class. But failed for I don't know how to write super func. I'm poor of of English, so…
chenchiyuan
  • 151
  • 1
  • 9
4
votes
1 answer

How should a Model be implemented in iOS using Objective-C?

EDIT: Although the answers are teaching me things, I still have no idea how I might "implement" a model. Can anyone give me an example as to how I would create a simple model class that has a few basic functions that make calls to…
Deminetix
  • 2,866
  • 26
  • 21
4
votes
1 answer

Rails: attr_accessor doesn't show up when try to render as JSON

In my application I have a model that is below; class Init < ActiveRecord::Base attr_accessor :clientAvailability attr_accessible :returnCode, :returnMessage, :tokenCode, :updateURL end In here when I've added the **attr_accessor** later on and…
Ali
  • 5,338
  • 12
  • 55
  • 78
4
votes
2 answers

Model foreign key validation

I have two models: Client and Invoice. Every client can have many invoices, every invoice belongs to only one client. If the client is deleted, the invoices with reference to him should be deleted, too. This is all done through the following…
Dennis Hackethal
  • 13,662
  • 12
  • 66
  • 115
4
votes
1 answer

Web API model binding issue in POST

I am new to Web API and this is really puzzling to me. Here is the model: public class Model { public string firstname { get; set; } public string lastname { get; set; } } here is the controller: public class TestController : ApiController { …
user1669811
  • 835
  • 3
  • 12
  • 15
4
votes
2 answers

django-mptt filter without breaking the tree

I'm using django-mptt for a Article model in my Django application. If I want to get all Articles which are set to for example hidden, I could do Article.objects.filter(hidden=False) but that would break the mptt-tree. How can I filter on my…
user1614463