Re: loaddata and auto_now_add=True

2011-10-04 Thread Russell Keith-Magee
A fixture is intended to be a full and complete copy of what you want
in the database, including *all* date/timestamps. If you want data to
be created with creation/update times that reflect the time at which
the test was executed, then you need to create that data in the
setUp() method of your test, or use the setUp() method to modify the
object loaded by the fixture.

Yours,
Russ Magee %-)

On Tue, Oct 4, 2011 at 2:45 PM, Reikje  wrote:
> Ok so bottomline is, you have to add values for this kind of fields if
> you want to use the fixture from both, tests and loaddata?
>
> On Oct 3, 10:53 am, Phang Mulianto  wrote:
>> i think bcoz load data does not use the orm api..while your test use orm to
>> insert data..
>> On Oct 3, 2011 3:43 PM, "Reikje"  wrote:> Hi, I have 
>> a test fixture file which I use in unit tests. In some
>> > Models I have date fields defined like this:
>> > models.DateTimeField(auto_now_add=True) for which I don't specify
>> > values in the fixture file (users.json). This works well as part of
>> > testing but when I want to load the fixture into the real database
>> > using the loaddata command, it will complain about these fields being
>> > null, i.e. Warning: Column 'last_seen_at' cannot be null
>>
>> > Whats the difference between running the fixture file as part of the
>> > test suite and loading it using loaddata. I guess I can work around
>> > this by adding values for these fields but I am lazy :)
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups
>>
>> "Django users" group.> To post to this group, send email to 
>> django-users@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.
>>
>>
>>
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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: loaddata and auto_now_add=True

2011-10-03 Thread Reikje
Ok so bottomline is, you have to add values for this kind of fields if
you want to use the fixture from both, tests and loaddata?

On Oct 3, 10:53 am, Phang Mulianto  wrote:
> i think bcoz load data does not use the orm api..while your test use orm to
> insert data..
> On Oct 3, 2011 3:43 PM, "Reikje"  wrote:> Hi, I have a 
> test fixture file which I use in unit tests. In some
> > Models I have date fields defined like this:
> > models.DateTimeField(auto_now_add=True) for which I don't specify
> > values in the fixture file (users.json). This works well as part of
> > testing but when I want to load the fixture into the real database
> > using the loaddata command, it will complain about these fields being
> > null, i.e. Warning: Column 'last_seen_at' cannot be null
>
> > Whats the difference between running the fixture file as part of the
> > test suite and loading it using loaddata. I guess I can work around
> > this by adding values for these fields but I am lazy :)
>
> > --
> > You received this message because you are subscribed to the Google Groups
>
> "Django users" group.> To post to this group, send email to 
> django-users@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.
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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: loaddata and auto_now_add=True

2011-10-03 Thread Phang Mulianto
i think bcoz load data does not use the orm api..while your test use orm to
insert data..
On Oct 3, 2011 3:43 PM, "Reikje"  wrote:
> Hi, I have a test fixture file which I use in unit tests. In some
> Models I have date fields defined like this:
> models.DateTimeField(auto_now_add=True) for which I don't specify
> values in the fixture file (users.json). This works well as part of
> testing but when I want to load the fixture into the real database
> using the loaddata command, it will complain about these fields being
> null, i.e. Warning: Column 'last_seen_at' cannot be null
>
> Whats the difference between running the fixture file as part of the
> test suite and loading it using loaddata. I guess I can work around
> this by adding values for these fields but I am lazy :)
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.



loaddata and auto_now_add=True

2011-10-03 Thread Reikje
Hi, I have a test fixture file which I use in unit tests. In some
Models I have date fields defined like this:
models.DateTimeField(auto_now_add=True) for which I don't specify
values in the fixture file (users.json). This works well as part of
testing but when I want to load the fixture into the real database
using the loaddata command, it will complain about these fields being
null, i.e. Warning: Column 'last_seen_at' cannot be null

Whats the difference between running the fixture file as part of the
test suite and loading it using loaddata. I guess I can work around
this by adding values for these fields but I am lazy :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.