unique_for_date

15 views
Skip to first unread message

Alessandro Ronchi

unread,
Nov 4, 2009, 6:47:34 AM11/4/09
to django...@googlegroups.com
unique_for_date checks only the date in a datetime field or also for the time?

--
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.com
http://www.linkedin.com/in/ronchialessandro

David

unread,
Nov 4, 2009, 12:52:22 PM11/4/09
to Django users
Hello

I was wondering if unique_for_date is not working or if I am not
understanding how it is meant to be used.

My model:

class Entry(models.Model):
title = models.CharField(max_length=255)
content = models.TextField()
pubDate = models.DateTimeField(auto_now=False,auto_now_add=True)
editDate = models.DateTimeField(auto_now=True)
published = models.BooleanField()
slug = models.SlugField(unique_for_date='pubDate')
blog = models.ForeignKey(Blog)
def __unicode__(self):
return self.title

When I am in django admin I am able to make multiple entries with the
same slug. I've tried changing the uniqueness to title and both and it
still allowed me to create multiple entries.

Thank you

David

unread,
Nov 4, 2009, 1:28:26 PM11/4/09
to Django users
Hi Alessandro

I just tried converting pubDate to a DateField and it didn't solve the
problem.

Does unique_for_date apply to only the admin interface ? Or, just
everything else ?

I am testing this purely with the admin interface.

Thanks

Ramiro Morales

unread,
Nov 4, 2009, 3:03:01 PM11/4/09
to django...@googlegroups.com
On Wed, Nov 4, 2009 at 2:52 PM, David <cth...@googlemail.com> wrote:
>
> Hello
>
> I was wondering if unique_for_date is not working or if I am not
> understanding how it is meant to be used.

What version of Django are you using?

--
Ramiro Morales | http://rmorales.net

David

unread,
Nov 4, 2009, 3:43:44 PM11/4/09
to Django users
Hi Ramiro

I'm using Django 1.1.1
Reply all
Reply to author
Forward
0 new messages