Changes between Version 2 and Version 3 of DynamicModels


Ignore:
Timestamp:
May 9, 2007, 2:57:10 PM (18 years ago)
Author:
Marty Alchin <gulopine@…>
Comment:

Added a link to DevModelCreation

Legend:

Unmodified
Added
Removed
Modified
  • DynamicModels

    v2 v3  
    88== The basic technique ==
    99
    10 Internally, Django uses metaclasses to create models based on a class you provide in your source code. Without getting into too many details, that means that rather than your classes being the actual models, Django receives a description of your class, which it uses to create a model in its place.
     10Internally, Django uses metaclasses to create models based on a class you provide in your source code. Without getting into too many details, that means that rather than your classes being the actual models, Django receives a description of your class, which it uses to create a model in its place. For more details, see the writeup on [wiki:DevModelCreation Model Creation].
    1111
    1212Thankfully, Python treats classes like any other object, so we can force this process to occur even when the class wasn't defined in source. All we really need is to give Django a description of a class, and let it do all the work of creating the model for us. Here's some bare-bones code.
Back to Top