Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A django abstract model and form for handling extra content in a model.

Project Description

A django abstract model and form for handling extra content in a model.

Let’s say we have a model MyData which can point to different underlying data types:

from django.db import models
from extracontent.models import ExtraContent
from extracontent.forms import ExtraContentForm

class DataModel1(models.Model):
    value = models.TextField()

class DataModel2(models.Model):
    dt = models.DateField()

class MyData(ExtraContent):
    name = models.CharField(max_length = 20)

class MyDataForm(ExtraContentForm):
    class Meta:
        model = MyData

Then we can do this:

>>> from extracontent import content
>>> elem = MyDataForm({'content_type':content('datamodel1'),
... 'value':'this is a test', name:'a data object'}).save()
>>> elem.extra_content()
<DataModel1: DataModel1 object>
>>> elem.extra_content().value
'this is a test'

Running Tests

Once installed:

>>>from extracontent.tests import run
>>>run()

or from within the tests directory:

python runtests.py

Release History

This version
History Node

0.1

Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
django-extracontent-0.1.tar.gz
(6.7 kB) Copy SHA256 Hash SHA256
Source None Sep 11, 2010
django-extracontent-0.1.zip
(9.8 kB) Copy SHA256 Hash SHA256
Source None Sep 13, 2010

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting