#9861: Requests make feature: Using a subset of fields on the Model ---------------------------------------------------+------------------------ Reporter: freeren | Owner: nobody Status: new | Milestone: Component: Database layer (models, ORM) | Version: SVN Keywords: Using a subset of fields on the Model | Stage: Unreviewed Has_patch: 0 | ---------------------------------------------------+------------------------ The classes inheritance are useful when you want to put some common information into a number of other models.
{{{ class FlatPage(models.Model): url = models.CharField(_('URL'), max_length=100, db_index=True) title = models.CharField(_('title'), max_length=200) content = models.TextField(_('content'), blank=True) enable_comments = models.BooleanField(_('enable comments')) template_name = models.CharField(_('template name'), max_length=70, blank=True, help_text=_("Example: 'flatpages/contact_page.html'. If this isn't provided, the system will use 'flatpages/default.html'.")) registration_required = models.BooleanField(_('registration required'), help_text=_("If this is checked, only logged-in users will be able to view the page.")) sites = models.ManyToManyField(Site) class SubFlatPage(models.Model): url = models.CharField(_('URL'), max_length=100, db_index=True) title = models.CharField(_('title'), max_length=200) content = models.TextField(_('content'), blank=True) sites = models.ManyToManyField(Site) other = models.CharField(_('other'), max_length=200) }}} Using a subset of fields on the model (abstract=True OR abstract=False ) like : [http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a -subset-of-fields-on-the-form] # Use the fields attribute of the Model's inner Meta class. This attribute, if given, should be a list of field names to include in the SubModel. # Use the exclude attribute of the Model's inner Meta class. This attribute, if given, should be a list of field names to exclude from the SubModel. # Can append a little other fields. -- Ticket URL: <http://code.djangoproject.com/ticket/9861> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---