-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
I wanted to use compositekey in the following model:
from compositekey import db
class Relationship(models.Model):
class Meta:
db_table = 'follows'
id = db.MultiFieldPK("u", "tu")
u = models.IntegerField(db_column='user_id')
tu = models.IntegerField(db_column='target_user_id')
d = models.DateTimeField(db_column='created', default=datetime.utcnow)It's a new model and none of my other models have any fk relation to it.
However when I add this I get an exception when I try a manage.py shell etc
File "/Users/anentropic/Documents/Dev/Work/myproj/otherapp/models.py", line 57, in <module>
class UnrelatedModel(AnotherUnrelatedModel):
File "/Users/anentropic/.virtualenvs/myproj/lib/python2.7/site-packages/django/db/models/base.py", line 167, in __new__
new_class.add_to_class(field.name, copy.deepcopy(field))
File "/Users/anentropic/.virtualenvs/myproj/lib/python2.7/site-packages/django/db/models/base.py", line 219, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/anentropic/.virtualenvs/myproj/lib/python2.7/site-packages/compositekey/db/models/fields/related.py", line 31, in contribute_to_class
assert not self.fields_ext or not self._fields,\
AttributeError: 'ForeignKey' object has no attribute 'fields_ext'
As best I can tell it looks like maybe the fk monkeypatch has arrived too late to affect models which have already been imported by the time I reach my first model using a composite key?
if so it's odd that this isn't mentioned in the docs?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels