Skip to main content

Makes your Django models extendable.

Project description

The ex-model lets you extend models in apps by adding mixins to them. The mixins can override fields and methods of the original model.

Example:

# file: staff.models
from django.db import models
from exmodel import Model, extend_model


class Person(Model):
    name = models.CharField(max_lenth=10)

    def __unicode__(self):
        return self.name

    class Meta:
        app_label = 'staff'
        verbose_name = 'Person name'


class PersonMixin(object):
    name = models.CharField(max_lenth=500)
    alias = models.CharField(max_lenth=500)

    def __unicode__(self):
        return u'%s (%s)' % (self.name, self.alias)

    class Meta:
        verbose_name = 'Person name and alias'


extend_model('staff.Person', PersonMixin)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-exmodel-0.0.2.tar.gz (8.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page