Questions tagged [models]

A model is an abstract representation of a real-life object or process. Models are a part of the popular MVC pattern, as well as a more general concept in the sciences for approximating behavior.

A model is one of the three components of Model-View-Controller (MVC) programming pattern that provides knowledge: data and how to work with this data, responding to requests by changing its state.

It can also refer to models in a more general scientific sense, denoting a representation (generally a simplification) of how a real-world process operates.

2397 questions
0
votes
1 answer

Many foreign keys in a model, better way to do models?

I'm kind of new to django. While writing the models for an app I'm doing, I felt like I was doing something wrong because of all the foreign keys I was using for a single model (ticket model to be specific) My thinking at the beginning was that I…
siggibk
  • 11
  • 2
0
votes
0 answers

Can not solving Reverse accessor clashes

I have a bug that I can not solve in django>=1.8,<1.9. I merged my changes and I get this: ERRORS: archive.Booking.articles: (fields.E304) Reverse accessor for 'Booking.articles' clashes with reverse accessor for 'Booking.articles'. HINT: Add or…
git-e
  • 269
  • 1
  • 4
  • 15
0
votes
1 answer

default model field attribute in Django

I have a Django model: @staticmethod def getdefault(): print "getdefault called" return cPickle.dumps(set()) _applies_to = models.TextField(db_index=True, default=getdefault) For some reason, getdefault() is never…
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
0
votes
1 answer

Rails - Has Many :through, with multiple models confusion

I have 4 models i'm dealing with. I have an Account, Location, Tag, and Tagging Model. I have set it up like follows class Tag < ActiveRecord::Base # belongs_to :shelter has_many :taggings, :dependent => :destroy has_many :locations,…
bokor
  • 1,829
  • 1
  • 19
  • 25
0
votes
1 answer

Django should I use an optional related field or get_or_create?

I have the a ForeignKey field on the User model. company = models.ForeignKey('crm.Company') So every user needs to have a company. The problem is the create_super_user method does not have a company at the start of a project and I get the following…
tread
  • 10,133
  • 17
  • 95
  • 170
0
votes
0 answers

Where is defined orderProp in AngularJS and why is not present in API documentation?

I started to study AngularJS from the official tutorial and at a certain point, it use: this.orderProp = 'age'; To give the possibility to order the list based on age. Now the question became inevitable:"What are the other properties? and where is…
realnot
  • 721
  • 1
  • 11
  • 31
0
votes
1 answer

Random Option In Django Drop Down Form

I've been picking my brain trying to figure this out and so now I turn to the community for help. I'm using models to create a form in Django and I want to add a Random option to a few of the drop-down choices. Here is a general idea of what I'm…
0
votes
0 answers

Django Rest Framework model relations

I'm creating school project, Gallery app. I have next entities: Profile, Album, Image, Tag, Like, Comment. But i'm a little bit confused with relations. I created all, but i'm not sure everything is good. Please check: Profile: class…
М.Б.
  • 1,308
  • 17
  • 20
0
votes
2 answers

How to register a django model field with any type?

I have built an API With Django REST Framework. On client side I use Angular and I have an class that looks like: export class Property{ id: number; value: any; } The value property can…
Junior Gantin
  • 2,102
  • 1
  • 18
  • 24
0
votes
0 answers

How to handle displaying objects created at different times/days in rails view

I've tried searching on this for several hours and I've not found any 'best practice' way to display views. I'm creating a task-tracking app in which a User has many(1-3) Goals/"lists", each goal/list is a set of Tasks which are set at any time, but…
Olliedee
  • 79
  • 2
  • 10
0
votes
1 answer

How to select results from django model group by an attribute

I need some help with a problem that i can't figure out with Django (unless by doing crappy nested for). I have these three models : class Article(models.Model): label = models.CharField(max_length=100) unity = models.ForeignKey('Unity') …
Gemkodor
  • 1
  • 3
0
votes
1 answer

Delete row with relationships and sub relationship, including images laravel 4.2

I have 3 tables Client ----------- |id|client| ----------- |1 |client| ----------- Items --------------------- |id|client_id|item | --------------------- |1 | 1 |item 1| --------------------- |2 | 1 |item…
Carlos Salazar
  • 1,818
  • 5
  • 25
  • 48
0
votes
1 answer

Error "'DefaultConnectionProxy' object has no attribute '__getitem__'" when calling stored procedure

Hi i'm making a project using python/Django, on my first page (index) i'm calling a stored procedure to fetch the data. def index(request): listOPT = [] Data = [] fluxState = settings.FLUX_MANAGER_STATE if fluxState != True: …
0
votes
1 answer

error in R: Error in model.frame.default.... variable lengths differ (no N/As in my data)

I had this this problem with an error message that I don't understand whilst trying to create a binomial mixed effects model, but I didn't have any N/As in my data which I thought this error message meant... can you help? thanks formula: …
0
votes
1 answer

Loopback extending built in User model issues

I am inheriting the builtin User model in my own Customer model. The Customer model is having extra parameters like first-name, last-name etc. To create an User and Customer I am using the following code: // create a Customer User.create({ …
Ashy Ashcsi
  • 1,529
  • 7
  • 22
  • 54