Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7505 closed (duplicate)

Abstract class managers have .model pointing to the Abstract rather than the real class

Reported by: tie Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: qsrf-cleanup abstract model manager
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Consider this example:

from django.db import models

class CustomManager(models.Manager):
    def get_query_set(self):
        print "My model is: ", self.model
        return super(CustomManager, self).get_query_set()

class Abstract (models.Model):
    class Meta:
        abstract = True
    objects = CustomManager ()

class Place(Abstract):
    name = models.CharField(max_length=50)
    address = models.CharField(max_length=80)

When this code is evaluated in ./manage.py shell, we get:

>>> models.Place.objects.model
<class 'demoproject.gentest.models.Abstract'>

>>> Place.objects.all()
My model is:  <class 'demoproject.gentest.models.Abstract'>

The normal behavior would be models.Place.objects.model to point to the "real" class - <class 'demoproject.gentest.models.Place'>

Change History (2)

comment:1 by Johannes Dollinger, 16 years ago

Keywords: qsrf-cleanup added
milestone: 1.0
Resolution: duplicate
Status: newclosed

closing, the patch for #7154 fixes this.

comment:2 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

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