> Ah, yes, I fell back on the add() function only because setattr wasn't
> doing what I needed it to do.  I know I am getting the DoesNotExist
> exception because the related model doesn't exist, but that's the
> problem entirely: I have no way to pass an argument to setattr because
> getattr raises this exception, and it's not going to exist until I
> call
>
> mymodel.some_relation_or_fk = related_model
>
> This is the problem, because I don't know the name of the attribute
> being used to define some_relation_or_fk.  However, since the
> attribute that defines the relation seems to be a property, any
> reference to it acts like a call to a get_function itself, which
> raises the error.  So, given two model instances as per my previous
> post:


Slightly different situation, I think, but I was getting the same
error.

And in my case, when I retrieved an object and a foreign key reference
in the object was NULL, it gave me this error.

What I needed to do was edit the models.py definitions and add a
"null=TRUE" attribute to the Foreign key.

It stopped the exception being thrown then.

Not sure if you did the same to all the Foreign key references for
that object  that your attribute can potentially be would solve your
problem.

Anyway, hope this helps.
- Chai



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to