Hi all,
I've very recently come to to Django from a rails background, and
struggling to do unit testing of Django models without saving to the
database as I'm used to in Rails. Lets say you have 2 linked models, for
example User and UserProfileDetails, then in my tests I want to set up the
structure and not save any of it:
user = User()
user.profile_details = UserProfileDetails()
...
# stuff that tests non-persistence related functionality
But I don't seem to be able to do this, because it will raise a
RelatedObjectDoesNotExist error, saying UserProfileDetails has no user.
Obviously I can get around this by saving the user first, but if I want to
not touch the database in tests is there any way I can achieve this?
(also apologies if this has been asked before - I did a quick search of the
archives and couldn't find anything).
Thanks in advance,
Roland
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/8005dcd3-0fd3-46f1-bc7e-70e59734e386%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.