Re: fixtures for test fail to load

2010-04-30 Thread zinckiwi
> If your fixture only contains B objects, then importing will fail if
> the A objects they're keyed to don't exist. Test databases are blank
> aside from fixtures, so the test DB and blank DB are telling you the
> same thing. You'll need to ensure that you have fixtures not only for
> the models you directly want, but also for any models which have
> relationships to them.

To better phrase the last part:

You'll need to ensure that you have fixtures not only for the models
you directly want, but also for any models which your models are
foreign-keyed to.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: fixtures for test fail to load

2010-04-30 Thread zinckiwi
Your fixture probably contains objects whose model(s) contain foreign
keys to other objects.

class A(models.Model):
   pass

class B(models.Model):
   a = models.ForeignKey(A)

If your fixture only contains B objects, then importing will fail if
the A objects they're keyed to don't exist. Test databases are blank
aside from fixtures, so the test DB and blank DB are telling you the
same thing. You'll need to ensure that you have fixtures not only for
the models you directly want, but also for any models which have
relationships to them.

Regards
Scott


On Apr 28, 7:26 pm, "eka (Esteban)"  wrote:
> Found that loaddata also doesn't work when the DB has no records.
>
> Same error.
>
> On Apr 28, 7:47 pm, "eka (Esteban)"  wrote:
>
> > Hi all,
>
> > Did a dumpdata of my project, then added that to my test and I get:
> > DoesNotExist: XXX matching query does not exist.
> > The strange thing is that manually loading it using loaddata works
> > perfectly.
> > Any clue?
>
> > Note: Using django.test.TestCase

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: fixtures for test fail to load

2010-04-28 Thread eka (Esteban)
Found that loaddata also doesn't work when the DB has no records.

Same error.

On Apr 28, 7:47 pm, "eka (Esteban)"  wrote:
> Hi all,
>
> Did a dumpdata of my project, then added that to my test and I get:
> DoesNotExist: XXX matching query does not exist.
> The strange thing is that manually loading it using loaddata works
> perfectly.
> Any clue?
>
> Note: Using django.test.TestCase
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



fixtures for test fail to load

2010-04-28 Thread eka (Esteban)
Hi all,

Did a dumpdata of my project, then added that to my test and I get:
DoesNotExist: XXX matching query does not exist.
The strange thing is that manually loading it using loaddata works
perfectly.
Any clue?

Note: Using django.test.TestCase

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.