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 details)

Uploaded Source

File details

Details for the file django-exmodel-0.0.2.tar.gz.

File metadata

File hashes

Hashes for django-exmodel-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e165f51f54b9d1e16dd778cef466f1f02fbbc858b164a24ebc60373e07752259
MD5 38050ebbdc87aad918c5144b2841c36c
BLAKE2b-256 1e6c48705a6cff7f72c2855e99151500b41cc0df6457704ae34158c7e1ccb954

See more details on using hashes here.

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