Opened 5 years ago

Closed 5 years ago

#31619 closed Bug (invalid)

Incorrect error message get_object_or_404 if queryset have error

Reported by: dicos Owned by: nobody
Component: Uncategorized Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

from django.db import models


class Article(models.Model):
    title = models.CharField(_(u'title'), max_length=255)
    slug = models.SlugField(unique=True)

    
class ArticleItem(models.Model):
    article = models.ForeignKey(Article, on_delete=models.CASCADE)
    text = models.TextField(_(u'text'), blank=True)


from django.shortcuts import get_object_or_404

qs = Article.objects.prefetch_related('qwe')
get_object_or_404(qs), slug=slug)
ValueError: First argument to get_object_or_404() must be a Model, Manager, or QuerySet, not 'QuerySet'.

Change History (2)

comment:1 by Claude Paroz, 5 years ago

I was not able to reproduce immediately. Could you please confirm you are using the latest Django 3.0.x release, and provide a full stack trace?

comment:2 by dicos, 5 years ago

Resolution: invalid
Status: newclosed

I'm sorry. In current project of my work use old version Django.

Note: See TracTickets for help on using tickets.
Back to Top