Changes between Version 10 and Version 11 of DynamicModels
- Timestamp:
- Jan 11, 2008, 10:27:19 AM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DynamicModels
v10 v11 96 96 * {{{admin}}} - A dictionary of admin options, as if they were provided to the inner {{{Admin}}} class (again, see [#Admininterface Admin drawback] below) 97 97 98 A 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 98 100 Models can be created using this class with any number of features, as shown by the examples below. 99 101 100 102 {{{ 101 103 #!python 102 >>> model = create_model('Empty' )104 >>> model = create_model('Empty', app_label='dynamic') 103 105 >>> model.__module__ 104 106 '' 105 107 >>> model._meta.app_label 106 ' '108 'dynamic' 107 109 >>> len(model._meta.fields) # Remember, an "id" field is created automatically for each model 108 110 1