On 13-8-2012 23:14, Kurtis Mullins wrote: > The reason I'm using a Form (specifically a ModelForm) is to make my job of > setting up the Validation a *whole* lot easier. > > Here's the code I basically used. Maybe there's a better way to do it? > > json_object = json.loads(request.POST['some_json_field']) > q = QueryDict('') > q = q.copy() > q.update(json_object) > form = MyModelForm(q) >
Hmm. You gain: - an errors dict At the cost of: - form field instance creation - widget instance creation You can save some resources by investing in a JSONForm class and I'm wondering if the following does not do the job: json_object = json.loads(request.POST['fieldname']) obj = MyModel(**json_object) obj.full_clean() obj.save() -- Melvyn Sopacua -- 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.