#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 , 17 years ago
| Keywords: | qsrf-cleanup added |
|---|---|
| milestone: | → 1.0 |
| Resolution: | → duplicate |
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
closing, the patch for #7154 fixes this.