On Sat, 2007-05-19 at 13:11 +0200, Bram - Smartelectronix wrote:
> Russell Keith-Magee wrote:
> >> how do I -in fixtures- explain a variable needs to come from another table?
> >> I don't want to write "content_type: 15" as elsewhere!
> > 
> > That's the way its done. GenericRelation is a convenience wrapper
> > around the content type and object id database entries; you need to
> > provide values for those two columns, and they're both specified as
> > integers.
> 
> True, but right now I have the initial_data written as:
> 
> INSERT INTO ... VALUES ((select id from django_content_type where name = 
> 'profile'), ......);
> 
> Which stays OK, even if I add/remove Models (which change the 
> content_type table content!)
> 
> > There has been some talk recently about establishing a common
> > interface for datatype coercion; providing a more natural interface
> > for datatype deserialization is one possible use case for coercion of
> > this type. However, there hasn't been any decisions made as yet. If
> > you want to make a suggestion, feel free to join into the discussion
> > on django-dev.
> 
> What about letting users use python scripts to generate the initial data 
> (if really needed/wanted)?
> 
> ---<initial_data.py>--------------------------------------
> 
> json = """
> [
>    {
>      content_type: {{profile_contenttype.id}}
>    }
>    // more regular json goes here
> ]
> """
> 
> from django.template import Context, Template
> from django.contrib.contenttypes.models import ContentType
> 
> def get_json():
>    c = Context({'profile_content_type': ContentType.objects.get.....})
>    t = Template(json )
>    return t.render(c)
> 
> ---</initial_data.py>--------------------------------------
> 
> 
> I know that this kind of goes against what fixtures should be, but it 
> would be pretty flexible...

You can already do this as part of your test setup. Tests are just
Python files, after all, so you can do whatever extra customisation you
like in there.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to