Changes between Version 1 and Version 2 of CookBookMultiLevelMultiComponentDataModel


Ignore:
Timestamp:
08/04/05 15:41:51 (10 years ago)
Author:
oubiwann
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBookMultiLevelMultiComponentDataModel

    v1 v2  
    33== Multiple Levels and Multiple Components ==
    44
     5There are times when you have data/content that has many-to-one relationships. This is very easy to accomodate, just as [http://www.djangoproject.com/documentation/models/many_to_one/ this example] demonstrates. Here is code similar to that of the example:
     6{{{
     7from django.core import meta
     8
     9class Document(meta.Model):
     10    fields = (
     11        meta.CharField('short_name', maxlength=30),
     12        meta.CharField('title', maxlength=100),
     13    )
     14
     15    def __repr__(self):
     16        return self.title
     17
     18    admin = meta.Admin()
     19
     20class Paragraph(meta.Model):
     21    fields = (
     22        meta.ForeignKey(Document, edit_inline=True, num_in_admin=3, num_extra_on_change=1),),
     23        meta.TextField('content'),
     24    )
     25
     26    def __repr__(self):
     27        return self.headline
     28}}}
Back to Top