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 UserForeignKey is a simple Django app (supporting Django 1.8 and 1.9) that will give you a UserForeignKey model field. This field extends a regular ForeignKey model field, and has the option to automatically set the currently logged in user on insert and/or update.

Currently, Django 1.8 (Python 2.7, Python 3.3+), Django 1.9 (Python 2.7, Python 3.4+) and Django 1.10 (Python2.7, Python3.4+) are supported. We also support the new Django 1.10 type of Middleware .

Quick start

  1. Download and install using pip install
pip install django-userforeignkey
  • or directly from this git repo
pip install git+https://github.com/beachmachine/django-userforeignkey.git
  1. Add django_userforeignkey to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
    ...
    'django_userforeignkey',
]
  1. Add django_userforeignkey.middleware.UserForeignKeyMiddleware to your MIDDLEWARE_CLASSES settings like this (Django 1.10 MIDDLEWARE is also supported):
MIDDLEWARE_CLASSES = (
    ...
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    ...
    'django_userforeignkey.middleware.UserForeignKeyMiddleware',
)

Make sure to insert the UserForeignKeyMiddleware middleware after AuthenticationMiddleware.

Example usage

Just add UserForeignKey to your model like you would with any other foreign key:

from django.db import models
from django_userforeignkey.models.fields import UserForeignKey

class MyModel(models.Model):
    my_data = models.CharField(max_length=64, verbose_name="Very important data that are somehow related to a user")
    user = UserForeignKey(auto_user_add=True, verbose_name="The user that is automatically assigned", related_name="mymodels")

The UserForeignKey behaves just like a normal foreign key element (thus also has properties such as related_name). However, whenever an object is created by calling an authenticated view (admin, REST API, …) which contains a request.user object, the request.user object is automatically associated.

Development and Tests

git clone --recursive https://github.com/beachmachine/django-userforeignkey
cd django-userforeignkey
virtualenv -p python2.7 venv # or virtualenv -p python3.4
source venv/bin/activate
python setup.py install
pip install Django==1.9 # or Django==1.10
cd tests/user_foreign_key_testapp
python manage.py test

You can also use tox for testing, as it will test against Django 1.8, 1.9, 1.10 with Python versions 2.7, 3.4 and 3.5. See tox.ini for details.

Release History

Release History

0.1.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.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-userforeignkey-0.1.2.tar.gz (5.0 kB) Copy SHA256 Checksum SHA256 Source Nov 16, 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