django-uuidfield /

Filename Size Date modified Message
uuidfield
0 B
14 B
94 B
30 B
1.5 KB
526 B

django-uuidfield

There are a few UUID fields floating around out on the interwebs.

Here is one packaged up as a pip installable one. It is mostly based on http://gist.github.com/374662, but has some changes, and will get some unit tests.

Installation

Download or clone the repository, and from inside the root folder:

$ python setup.py install

Or, use pip:

$ pip install -e hg+https://bitbucket.org/schinckel/django-uuidfield#egg=django-uuidfield

Even better, do this from inside your virtualenv.

You are using virtualenv, right?

Django setup

You don't really need to install into your INSTALLED_APPS, but you may want to. I generally put everything in there that I use, just so any tests on it will be run when you test your project.

Then, in your model file:

from django.db import models
import uuidfield

class MyModel(models.Model):
    uuid = uuidfield.UUIDField()

Advanced use

The following arguments can be passed to the UUIDField:

  • auto - a boolean value as to if values should be generated automatically. These values are created using uuid.uuid4().

Changes

0.6.5: Remove the creation of a "default" in a south migration when it has been set.
See http://south.aeracode.org/ticket/295#comment:8

0.6.4: Raise a ValidationError on a badly formed UUID string, rather than ValueError, in UUIDField.clean.

0.6.1: Treat the deprecation warning from django 1.3+

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.