Closed GoogleCodeExporter closed 8 years ago
Thank you, this is now fixed in trunk.
Original comment by npbor...@gmail.com
on 2 Sep 2008 at 4:41
Is this really fixed? I think the problem is that the publish field is a
datetime
object so it's almost always unique. If you want to make sure the URL is
unique you
need to use a DateField instead of DateTime Field. Otherwise you haven't
solved the
MultipleObjectsReturned problem.
In [23]: from basic.blog.models import Post
In [24]: from django.contrib.auth.models import User
In [25]: u=User.objects.all()[0]
In [26]: from datetime import datetime
In [27]: q=Post(title='foobar',slug='fbar',author=u,publish=datetime.now())
In [28]: p=Post(title='foobar',slug='fbar',author=u,publish=datetime.now())
In [29]: q.save()
In [30]: p.save()
In [31]: Post.objects.get(slug='fbar')
---------------------------------------------------------------------------
MultipleObjectsReturned Traceback (most recent call last)
/Users/mandric/dev/jschool/code/projects/kdmc/<ipython console> in <module>()
/opt/local/lib/python2.5/site-packages/django/db/models/manager.py in get(self,
*args, **kwargs)
91
92 def get(self, *args, **kwargs):
---> 93 return self.get_query_set().get(*args, **kwargs)
94
95 def get_or_create(self, **kwargs):
/opt/local/lib/python2.5/site-packages/django/db/models/query.py in get(self,
*args,
**kwargs)
309 % self.model._meta.object_name)
310 raise self.model.MultipleObjectsReturned("get() returned more than
one %s -- it returned %s! Lookup parameters were %s"
--> 311 % (self.model._meta.object_name, num, kwargs))
312
313 def create(self, **kwargs):
MultipleObjectsReturned: get() returned more than one Post -- it returned 2!
Lookup
parameters were {'slug': 'fbar'}
Original comment by mand...@gmail.com
on 16 Feb 2009 at 6:09
Original issue reported on code.google.com by
AxisOfEn...@gmail.com
on 30 Aug 2008 at 6:44