Django Version: 1.8.16 Python Version: 2.7.5
All document is public, you can read all of it even you are not login, but when you login, if you don't have super admin permission, the error message come out
Exception
Request Method: GET
Request URL: http://rtd.chan.net/en/latest/
Django Version: 1.8.16
Exception Type: MultipleObjectsReturned
Exception Value:
get() returned more than one Version -- it returned 2!
Exception Location: /www/rtd/lib/python2.7/site-packages/django/db/models/query.py in get, line 338
Python Executable: /www/rtd/bin/uwsgi
Python Version: 2.7.5
Python Path:
['.',
'',
'/www/rtd/lib64/python27.zip',
'/www/rtd/lib64/python2.7',
'/www/rtd/lib64/python2.7/plat-linux2',
'/www/rtd/lib64/python2.7/lib-tk',
'/www/rtd/lib64/python2.7/lib-old',
'/www/rtd/lib64/python2.7/lib-dynload',
'/usr/lib64/python2.7',
'/usr/lib/python2.7',
'/www/rtd/lib/python2.7/site-packages']
Code
def get(self, *args, **kwargs):
"""
Performs the query and returns a single object matching the given
keyword arguments.
"""
clone = self.filter(*args, **kwargs)
if self.query.can_filter():
clone = clone.order_by()
num = len(clone)
if num == 1:
return clone._result_cache[0]
if not num:
raise self.model.DoesNotExist(
"%s matching query does not exist." %
self.model._meta.object_name
)
raise self.model.MultipleObjectsReturned(
"get() returned more than one %s -- it returned %s!" %
(self.model._meta.object_name, num)
)
line 338 is (self.model._meta.object_name, num)
I try to Google the exception message, the coding solution is to change get
to filter
, but it cause another exception and I don't think it's the real solution, how to fix it?