Skip to content
Browse files

Added clarification to the docs, pointing out that unique_for_date on…

…ly considers the date portion of DateTime fields.
  • Loading branch information...
1 parent d48b723 commit 291250f7b66a6b81d2fc64eecc82cb2b4bd6c090 @cannona cannona committed
Showing with 4 additions and 0 deletions.
  1. +1 −0 AUTHORS
  2. +3 −0 docs/ref/models/fields.txt
@@ -121,6 +121,7 @@ answer newbie questions, and generally made Django that much better:
Chris Cahoon <>
Juan Manuel Caicedo <>
Trevor Caira <>
+ Aaron Cannon <>
Brett Cannon <>
Ricardo Javier Cárdenes Medina <>
Jeremy Carbaugh <>
3 docs/ref/models/fields.txt
@@ -287,6 +287,9 @@ For example, if you have a field ``title`` that has
``unique_for_date="pub_date"``, then Django wouldn't allow the entry of two
records with the same ``title`` and ``pub_date``.
+Note that if you set this to point to a :class:`DateTimeField`, only the date
@aaugustin Django member

Does unique_for_date work properly on DateTimeField when USE_TZ = True?

Since I wasn't aware of this feature a few minutes ago, I suspect it doesn't; if so, the docs shouldn't imply it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+portion of the field will be considered.
This is enforced by model validation but not at the database level.

2 comments on commit 291250f


Good point. We should probably have some tests to go along with this. I'll see what I can come up with.

Django member

Filed here:

unique_for_date is explicitly documented to work with DateTimeField. This commit merely brought that fact to my attention.

Please sign in to comment.
Something went wrong with that request. Please try again.