summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2014-07-15 10:35:29 +0100
committerMarc Tamlyn <marc.tamlyn@gmail.com>2014-09-16 10:08:09 +0100
commited7821231b7dbf34a6c8ca65be3b9bcbda4a0703 (patch)
tree98657032a61094eb7ac9c46d5db5bc12d25d1fa0 /docs/ref
parent0d1561d19739e83cf20150585c9e26894b428bad (diff)
Fixed #19463 -- Added UUIDField
Uses native support in postgres, and char(32) on other backends.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/databases.txt3
-rw-r--r--docs/ref/forms/fields.txt14
-rw-r--r--docs/ref/models/fields.txt25
3 files changed, 41 insertions, 1 deletions
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
index ca909fcd04..7d1578bc59 100644
--- a/docs/ref/databases.txt
+++ b/docs/ref/databases.txt
@@ -92,7 +92,8 @@ below for information on how to set up your database correctly.
PostgreSQL notes
================
-Django supports PostgreSQL 9.0 and higher.
+Django supports PostgreSQL 9.0 and higher. It requires the use of Psycopg2
+2.0.9 or higher.
PostgreSQL connection settings
-------------------------------
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index bd7cb93389..d7fcef2e75 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -888,6 +888,20 @@ For each field, we describe the default widget used if you don't specify
These are the same as ``CharField.max_length`` and ``CharField.min_length``.
+``UUIDField``
+-------------
+
+.. versionadded:: 1.8
+
+.. class:: UUIDField(**kwargs)
+
+ * Default widget: :class:`TextInput`
+ * Empty value: ``''`` (an empty string)
+ * Normalizes to: A :class:`~python:uuid.UUID` object.
+ * Error message keys: ``required``, ``invalid``
+
+ This field will accept any string format accepted as the ``hex`` argument
+ to the :class:`~python:uuid.UUID` constructor.
Slightly complex built-in ``Field`` classes
-------------------------------------------
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index e7717e9d90..fe35f979ca 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -1012,6 +1012,31 @@ Like all :class:`CharField` subclasses, :class:`URLField` takes the optional
:attr:`~CharField.max_length` argument. If you don't specify
:attr:`~CharField.max_length`, a default of 200 is used.
+UUIDField
+---------
+
+.. versionadded:: 1.8
+
+.. class:: UUIDField([**options])
+
+A field for storing universally unique identifiers. Uses Python's
+:class:`~python:uuid.UUID` class. When used on PostgreSQL, this stores in a
+``uuid`` datatype, otherwise in a ``char(32)``.
+
+Universally unique identifiers are a good alternative to :class:`AutoField` for
+:attr:`~Field.primary_key`. The database will not generate the UUID for you, so
+it is recommended to use :attr:`~Field.default`::
+
+ import uuid
+ from django.db import models
+
+ class MyUUIDModel(models.Model):
+ id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
+ # other fields
+
+Note that a callable (with the parentheses omitted) is passed to ``default``,
+not an instance of ``UUID``.
+
Relationship fields
===================