Changes between Version 5 and Version 6 of new_meta_api


Ignore:
Timestamp:
Jul 11, 2014, 5:33:38 AM (10 years ago)
Author:
pirosb3
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • new_meta_api

    v5 v6  
    7676}}}
    7777GenericForeignKey uses content_type and object_id to keep track of what model type and id is set by item, but item itself does not have a concrete presence on the database.
    78 In this case, item is a virtual field.
     78In this case, item is a virtual field.
     79
     80==== Field options
     81There are 5 properties that each field can have:
     82
     83===== Local
     84A local field is one that is defined on the queries model and is not derived from inheritance.
     85Fields from models that directly inherit from abstract models or proxy classes are still local
     86
     87{{{
     88class Person(models.Model):
     89  name = models.CharField(max_length=50)
     90
     91class Londoner(Person):
     92  overdraft = models.DecimalField()
     93}}}
     94
     95Londoner has two fields (name and overdraft) but only one local field (overdraft)
     96
     97===== Hidden
     98Hidden fields are only referred to related objects and related m2m. When a relational model (such as ManyToManyField, or ForeignKey) specifies a related_name that starts with a "+", it tells Django to not create a reverse relation.
     99{{{
     100class City(models.Model):
     101    name = models.CharField(max_length=100)
     102
     103class Person(models.Model):
     104    city = models.ForeignKey(City, related_name='+')
     105}}}
     106
     107In this case, City has a related hidden object from Person (as you can't access person_set)
    79108
    80109
Back to Top