| 5 | There 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 | {{{ |
| 7 | from django.core import meta |
| 8 | |
| 9 | class 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 | |
| 20 | class 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 | }}} |