Django

Code

Ticket #7505 (closed: duplicate)

Opened 6 months ago

Last modified 6 months ago

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

Reported by: tie Assigned to: nobody
Milestone: 1.0 Component: Database layer (models, ORM)
Version: SVN Keywords: qsrf-cleanup abstract model manager
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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'>

Attachments

Change History

06/19/08 15:52:54 changed by emulbreh

  • status changed from new to closed.
  • needs_better_patch changed.
  • needs_tests changed.
  • milestone set to 1.0.
  • keywords changed from abstract model manager to qsrf-cleanup abstract model manager.
  • needs_docs changed.
  • resolution set to duplicate.

closing, the patch for #7154 fixes this.


Add/Change #7505 (Abstract class managers have .model pointing to the Abstract rather than the real class)




Change Properties
Action