﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20228	Admin interface doesn't prevent duplicates with unique_for_date	Marek Onuszko	Deepak	"I'm using Python 2.7.3 and Django 1.4.5-1 from Debian repositories. I can add multiple entries with identical values and the admin interface doesn't complain. I tried with both 'slug' and 'title'.
It sounds just like the bug from 4 years ago: https://code.djangoproject.com/ticket/10134

Note that while my field is DateTimeField (with time), the wording of the description at 
https://docs.djangoproject.com/en/dev/ref/models/fields/#unique-for-date leads me to believe it should consider only the .date component of the DateTimeField.


{{{

# models.py

from django.db import models

from django.utils.timezone import now as utcnow
now = utcnow() # replacing - date.now() causes problems with auto_now_add

class Entry(models.Model):
    created_at = models.DateTimeField(default=now, editable=False)
    title      = models.CharField(max_length = 50)
    content    = models.TextField()
    slug       = models.SlugField(unique_for_date='created_at')

    def __unicode__(self):
        return self.title
    class Meta:
        ordering = ['-created_at']

# admin.py

from news.models import Entry
from django.contrib import admin

class EntryAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('title',)}

    list_filter = ['created_at']
    date_hierarchy = 'created_at'

admin.site.register(Entry, EntryAdmin)

}}}"	Bug	closed	Documentation	1.4	Normal	fixed			Accepted	1	0	0	0	0	0
