I'm in a situation where the get_defaults method on the RelatedField class is called but
self.rel.to as not been resolved yet and is still a string. I'm using Django 1.6.6 and I cannot upgrade easily (big number of systems in production).
Some important stuff :
- the problem appears when I create a new object inside a py.test fixture
- if I create the same object inside the shell_plus I have no problem
Here is an extract of my model (foreigns A and B are mandatory, C is not) :
class MyModel(models.Model):
fielda = models.ForeignKey(
'otherapp.modela', db_column='fielda')
fieldb = models.ForeignKey(
'otherapp.modelb', db_column='fieldb')
fieldc = models.ForeignKey(
'otherapp.modelc', db_column='fieldc',
null=True, blank=True)
and here is how I use it :
# A is an instance of otherapp.modela
# B is an instance of otherapp.modelb
my_object = MyModel(fielda=A, fieldb=B)
Is there anything more I can provide to help ?
Thank you