Skip to content

get_object_or_404 has type Model instead of Team #22

@chdsbd

Description

@chdsbd

get_object_or_404 is returning type Model when I would expect it to return type Team.

Here's the example:

from django.shortcuts import get_object_or_404

from django.db import models

class Team(models.Model):
    name = models.CharField(max_length=255)
    is_public = models.BooleanField(default=False)


team: Team = get_object_or_404(Team, pk=5)
# example.py:12:1: error: Incompatible types in assignment (expression has type "Model", variable has type "Team")
mypy = "^0.670
mypy_extensions = "^0.4.1"
django-stubs = "^0.3.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions