Re: Using Forms without Request Data

2012-08-14 Thread Kurtis Mullins
Thanks a lot! I was curious on how to grab the raw POST data but didn't spend any time looking into it. This will definitely come in handy. On Tue, Aug 14, 2012 at 12:35 PM, S.Prymak wrote: > Here is the code snippet about JSON validation I use in my application: > > try: > j

Re: Using Forms without Request Data

2012-08-14 Thread S.Prymak
Here is the code snippet about JSON validation I use in my application: try: json_data = json.loads(request.raw_post_data) except Exception, e: return HttpResponseBadRequest() form = forms.AttributeForm(json_data) if not form.is_valid():

Re: Using Forms without Request Data

2012-08-13 Thread Kurtis
I forgot to mention, I do use the Forms to also exclude certain fields. Maybe a JSON Form class would do me some good here, afterall. The one problem is that my time is limited (budget) so I've got to make sure I don't spend too much time chasing down an optimized happy path. Although, it would

Re: Using Forms without Request Data

2012-08-13 Thread Kurtis
On Monday, August 13, 2012 5:37:52 PM UTC-4, Melvyn Sopacua wrote: > > > 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 do

Re: Using Forms without Request Data

2012-08-13 Thread Melvyn Sopacua
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

Re: Using Forms without Request Data

2012-08-13 Thread Kurtis Mullins
On Mon, Aug 13, 2012 at 5:10 PM, Melvyn Sopacua wrote: > > > data argument to a form instance must be a dictionary-like object. Other > then that there's no requirements. > I'm kinda curious why you need a form if you're using a non-html data > format. > > I figured it out :) It was as simple as cr

Re: Using Forms without Request Data

2012-08-13 Thread Melvyn Sopacua
On 13-8-2012 23:04, Kurtis wrote: > Actually, I'm creating a new object with this form. If it helps to > understand the scenario, I'm taking in JSON and creating an object out of > the data. But, I can't just pass the raw POST QueryDict because the data > doesn't map correctly by any means. dat

Re: Using Forms without Request Data

2012-08-13 Thread Kurtis
Actually, I'm creating a new object with this form. If it helps to understand the scenario, I'm taking in JSON and creating an object out of the data. But, I can't just pass the raw POST QueryDict because the data doesn't map correctly by any means. On Monday, August 13, 2012 4:55:27 PM UTC-4,

Re: Using Forms without Request Data

2012-08-13 Thread Melvyn Sopacua
On 13-8-2012 22:34, Kurtis wrote: > This may be a simple question and something I will probably just need more > time to dig in and try out. What's the best way to send data to a form > (specifically ModelForm) without using request.POST? The initial argument work for you? In short, initial sho