hi,
given a model like so:
Person:
name = charfield
hobbies = manytomany to the Hobby model
and a hobby model:
Hobby
name = charfield
to create a person instance from the command line I do:
newperson = Person.objects.create(name='myname')
and then to add 2 hobbies
hobbies = []
hobbies.append(Hobby.objects.get(name='painting'))
hobbies.append(Hobby.objects.get(name='singing'))
for hob in hobbies:
newperson.hobbies.add(hob)
This works, but is there any shortcut for this?
--
regards
kg
http://lawgon.livejournal.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---