DJANGO QUERYSET INTERMEDIATE EXAM LATEST UPDATE model - ANSWER Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a datab ase field. id field - ANSWER This field is added automatically, but this behav ior can be overridden How to activate your models - ANSWER edit your settings file and chang e the INSTALLED_APPS setting to add the name of the module that contains your models.py. when to run syncdb - ANSWER When you add new apps to INSTALLED_APPS class attributes - ANSWER Fields are specified by these what the field class type determines - ANSWER (1) The database column type (e.g. INTEGER, VARCHAR); (2) The widget to use in Django's admin interface, if you care to use it (e.g. <input type="text">, <select>); (3) The minimal validation requirements, used in Django's admin and in automatically-generated forms. null - ANSWER If this option is True, Django will store empty values as NULL in the database. Default is False. blank - ANSWER If this option is True, the field is allowed to be blank. D efault is False. choices - ANSWER An iterable (e.g., a list or tuple) of 2-tuples to use as options for this field. If this is given, Django's admin will use a select box in stead of the standard text field and will limit options to those given. choices tuple - ANSWER The first element in this iterable is the value t hat will be stored in the database, the second element will be displayed by the admin interface, or in a ModelChoiceField. default - ANSWER The value given in the absence of a specified value for the field. This can be a value or a callable object. If callable it will be called every tim e a new object is created. help_text - ANSWER Extra text to be displayed under the field on the o bject's admin form to provide assistance to users. It's useful for documentation even if your object doesn't have an admin form. primary_key - ANSWER If True, this field is the primary key for the model. unique - ANSWER If True, the table does not permit duplicate values for this field. many- to-one relationship - ANSWER Defined by django.db.models.ForeignKey. You use it just like any other Field type: by including it as a class attri bute of your model. ForeignKey - ANSWER Defines a many- to-one relationship. ou use it just like any other Field type: by including it as a class attribute of your model. many- to-many relationship - ANSWER Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribu te of your model. ManyToManyField - ANSWER Defines a many- to-many relationship. You use it just like any other Field type: by including it as a class attribute of y our model. through argument - ANSWER Specifies the model that will be used to govern the many- to-many relationship. You can then put extra fields on the intermediate model. The intermediate model is associated with the ManyToManyField usi ng this to point to the model that will act as an intermediary. restrictions on intermediate models - ANSWER (1) Your intermediate model must contain one - and only one - foreign key to the target model. (2) Your i ntermediate model must contain one - and only one - foreign key to the source mo del. (3) When defining a many- to-many relationship from a model to itself, using an intermediary model, you must use symmetrical=False. Many- to-many relationship to self - ANSWER In this case, an intermediate model can have multiple foreign keys to the source model. Here, two foreign keys to the same model are permitted, but they will be treated as the two (different) si des of the
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller luzlinkuz. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $11.49. You're not tied to anything after your purchase.