This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

django-multiforeignkey

Django ForeignKey that links to one of several specified models:

class Comment(models.Model):
        user = models.ForeignKey(User)
        text = models.TextField()

        # users may leave comments for blog posts, articles or votings
        object = MultiForeignKey(Post, Article, Voting)

Unlike GenericForeignKey, the field uses native database foreign keys and provides maximum speed and reliability.

WARNING

This is a preliminary alpha version which most probably doesn’t fully work as advertised. I had to publish it unfinished because I had to use it in my project.

Installation

pip install django-multiforeignkey

Usage

Add multiforeignkey to INSTALLED_APPS:

# settings.py

INSTALLED_APPS = [
        ...
        'multiforeignkey',
]

Add a field to your models:

# comments/models.py

from multiforeignkey.models import MultiForeignKey

class Comment(models.Model):
        user = models.ForeignKey(User)
        text = models.TextField()

        # users may leave comments for blog posts, articles or votings
        object = MultiForeignKey(Post, Article, Voting)

Create the corresponding database tables:

./manage.py makemigrations && ./manage.py migrate

Use the new field as if it were a real database field:

comment = Comment.objects.filter(object=post)
assert comment.object is post
comment.object = voting
assert comment.object is voting
comment.save()

or use specific subfields:

comment = Comment.objects.filter(post=post)
assert comment.post is post
assert comment.article is None
assert comment.voting is None
comment.voting = voting
assert comment.post is None
assert comment.article is None
assert comment.voting is voting
comment.save()
Release History

Release History

0.0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-multiforeignkey-0.0.2.tar.gz (3.2 kB) Copy SHA256 Checksum SHA256 Source Sep 15, 2016

Supported By

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