Re: Instantiate a model using a string (or a dict)??

2011-05-08 Thread Eiji Kobayashi
Wow. Thank you all so much, esp. sensei Oleg! Eiji On Sun, May 8, 2011 at 10:11 AM, Oleg Lomaka wrote: > To extend Shawn's answer on your example :) > > params = {'username': 'admin', 'email': 'x...@xyz.com', 'password': > 'xyz123'} > # then > new_user = User(**params) >

Re: Instantiate a model using a string (or a dict)??

2011-05-08 Thread Oleg Lomaka
To extend Shawn's answer on your example :) params = {'username': 'admin', 'email': 'x...@xyz.com', 'password': 'xyz123'} # then new_user = User(**params) new_user.save() # or User.objects.create(**params) On Sun, May 8, 2011 at 1:44 PM, Eiji Kobayashi wrote: > Hi! > >

Re: Instantiate a model using a string (or a dict)??

2011-05-08 Thread Shawn Milochik
You can do it with a dictionary. Just pass it using **kwargs. -- 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

Instantiate a model using a string (or a dict)??

2011-05-08 Thread Eiji Kobayashi
Hi! Sorry. Another question, please. Is it possible to create a model instance using a string parameter? Example, I would like to be able to do something like: param = "username='admin', email='x...@xyz.com', password='xyz123'" new_user = User(param) Of course this won't work. But is there a