Changes between Version 10 and Version 11 of DynamicModels


Ignore:
Timestamp:
Jan 11, 2008, 10:27:19 AM (16 years ago)
Author:
Marty Alchin
Comment:

Added a note about app_label and module

Legend:

Unmodified
Added
Removed
Modified
  • DynamicModels

    v10 v11  
    9696 * {{{admin}}} - A dictionary of admin options, as if they were provided to the inner {{{Admin}}} class (again, see [#Admininterface Admin drawback] below)
    9797
     98A note about {{{app_label}}} and {{{module}}}: Django always needs an {{{app_label}}} for its own use. If it's not explicitly supplied, it will be pulled from part of the model's {{{__module__}}} attribute, so ''at least one of the two must always be provided''. Otherwise, you'll get a {{{KeyError: ''}}} error when you try to create the model. Supplying {{{app_label}}} will always work just fine, regardless of whether {{{module}}} is provided. But if you supply ''only'' {{{module}}}, you'll have to make sure that it lines up with an entry in {{{INSTALLED_APPS}}}, so that Django can determine {{{app_label}}} correctly.
     99
    98100Models can be created using this class with any number of features, as shown by the examples below.
    99101
    100102{{{
    101103#!python
    102 >>> model = create_model('Empty')
     104>>> model = create_model('Empty', app_label='dynamic')
    103105>>> model.__module__
    104106''
    105107>>> model._meta.app_label
    106 ''
     108'dynamic'
    107109>>> len(model._meta.fields) # Remember, an "id" field is created automatically for each model
    1081101
Back to Top