Opened 15 years ago
Closed 15 years ago
#11230 closed (invalid)
Assigning the super class of a Proxy class to a ForeignKey fails.
Reported by: | David Novakovic | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.0 |
Severity: | 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 from proj.myapp.models import ProxyClass class NewClass(models.Model): proxy = models.ForeignKey(ProxyClass,related_name="newclass",unique=True)
Failure stacktrace on save():
>> n.proxy = p # p is actually an instance of SuperClass Traceback (most recent call last): File "<stdin>", line 1, in <module> File "...lib/common/django/db/models/fields/related.py", line 272, in __set__ self.field.name, self.field.rel.to._meta.object_name)) ValueError: Cannot assign "SuperClass": "NewClass.proxy" must be a "Proxy" instance.
First ticket for me, so let me know if I can provide more info.
Cheers
Change History (4)
comment:1 by , 15 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|
comment:2 by , 15 years ago
comment:3 by , 15 years ago
To clarify a few more details:
- The model validates fine, tables are created with syncdb etc.
- The SuperClass is a fully fledged db.models.Model.
- Proxy is a proxy class that extends SuperClass but has no table in the DB.
class Proxy(SuperClass): def proxy_behaviour(self): pass class Meta: proxy = True
Hope that helps a bit more...
comment:4 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
This is perfectly consistant behavior, if you expect a specific class (proxy or otherwise) and you assign a superclass of it it will not be accepted.
Note:
See TracTickets
for help on using tickets.
Sorry - that should be on assignment, not save.