Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultipleObjectsReturned: get() returned more than one Version -- it returned 2! #2613

Closed
NikitaEgorov opened this issue Jan 26, 2017 · 7 comments
Labels
Community Effort Needed: more information A reply from issue author is required Support Support question

Comments

@NikitaEgorov
Copy link

Details

  • Project URL: local
  • Build URL (if applicable): local
  • Read the Docs username (if applicable): local

Expected Result

View project docs

Actual Result

[26/Jan/2017 01:53:14] ERROR [django.request:256] Internal Server Error: /docs/readthedocs/en/latest/index.html
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/tempuser/checkouts/readthedocs.org/readthedocs/core/views/serve.py", line 92, in inner_view
    return view_func(request, project=project, *args, **kwargs)
  File "/home/tempuser/checkouts/readthedocs.org/readthedocs/core/views/serve.py", line 71, in inner_view
    return view_func(request, subproject=subproject, *args, **kwargs)
  File "/home/tempuser/checkouts/readthedocs.org/readthedocs/core/views/serve.py", line 149, in serve_docs
    version = project.versions.public(request.user).get(slug=version_slug)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 338, in get
    (self.model._meta.object_name, num)
MultipleObjectsReturned: get() returned more than one Version -- it returned 2! 
@NikitaEgorov
Copy link
Author

get() returned more than one Version -- it returned 2!
Request Method:	GET
Request URL:	http://***/docs/myhome/en/latest/
Django Version:	1.8.3
Exception Type:	MultipleObjectsReturned
Exception Value:	
get() returned more than one Version -- it returned 2!
Exception Location:	/usr/local/lib/python2.7/dist-packages/django/db/models/query.py in get, line 338
Python Executable:	/usr/bin/python
Python Version:	2.7.6
Python Path:	
['/home/tempuser/checkouts/readthedocs.org',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
 '/home/tempuser/checkouts/readthedocs.org',
 '/home/tempuser/checkouts/readthedocs.org']

@NikitaEgorov
Copy link
Author

I add additional logs

        log.info('version_slug %s' % (version_slug))
        log.info('project %s' % (project))
        log.info('project.versions %s' % (project.versions))
        log.info('request.user %s' % (request.user))
        log.info('public %s' % (project.versions.public(request.user)))

And get

[26/Jan/2017 02:39:34] INFO [readthedocs.core.views.serve:149] version_slug latest
[26/Jan/2017 02:39:34] INFO [readthedocs.core.views.serve:150] project MyProject1
[26/Jan/2017 02:39:34] INFO [readthedocs.core.views.serve:151] project.versions builds.Version.None
[26/Jan/2017 02:39:34] INFO [readthedocs.core.views.serve:152] request.user myuser
[26/Jan/2017 02:39:34] INFO [readthedocs.core.views.serve:153] public [<Version: Version 2.9 of MyProject1 (785)>, <Version: Version 2.8 of MyProject1 (555)>, <Version: Version latest of MyProject1 (458)>, <Version: Version latest of MyProject2 (561)>]

@NikitaEgorov
Copy link
Author

I fix it

def serve_docs
    ...
    #version = project.versions.public(request.user).get(slug=version_slug)
    version = project.versions.get(slug=version_slug)

@humitos
Copy link
Member

humitos commented Feb 23, 2017

Marking it as Community Effort. Explanation at this comment: #2281 (comment)

@stsewd
Copy link
Member

stsewd commented Apr 16, 2018

@NikitaEgorov the slugs are unique, I don't know how you ended with two projects with the same slug.

@stsewd stsewd added the Needed: more information A reply from issue author is required label Apr 16, 2018
@avloton
Copy link

avloton commented May 4, 2018

I was faced with the same error. Thank you @NikitaEgorov for solving the problem

@agjohnson
Copy link
Contributor

I'm not sure there is anything actionable here. Feel free to submit some test cases if you'd like to see about resolving this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Effort Needed: more information A reply from issue author is required Support Support question
Projects
None yet
Development

No branches or pull requests

5 participants