Re: Public method for getting model field names in order of definition

2009-11-23 Thread Anssi Kaariainen
> Thanks for the example, but that's not a ModelForm. > > Richard Another try, view.py: from django.forms.models import model_to_dict def view(request): data = Foo.objects.all()[0] print data.start form = Example(data=model_to_dict(data)) return render_to_response('t.html', {'for

Re: Public method for getting model field names in order of definition

2009-11-23 Thread Richard Laager
On Mon, 2009-11-23 at 04:56 -0800, Anssi Kaariainen wrote: > Here is a working example. > data = {'field1': 'Foo', 'field2': 10} > form = Example(data=data) Thanks for the example, but that's not a ModelForm. Richard -- You received this message because you are subscribed to the Google

Re: Public method for getting model field names in order of definition

2009-11-23 Thread Anssi Kaariainen
Here is a working example. I am using svn version of Django, but IIRC this works also in 1.0. views.py: from django.shortcuts import render_to_response from django import forms class Example(forms.Form): field1 = forms.CharField() field2 = forms.IntegerField(label='Labeled') def view(re

Re: Public method for getting model field names in order of definition

2009-11-22 Thread Richard Laager
On Sat, 2009-11-21 at 05:57 -0800, Anssi Kaariainen wrote: > If I am not completely mistaken you can use your ModelForm with > field.label and field.data to get read-only view of the model. I was trying to do something like this today and didn't have any luck. Do you have a pointer to a working sa

Re: Public method for getting model field names in order of definition

2009-11-21 Thread Richard Laager
On Wed, Oct 21, 2009 at 6:38 AM, David Chandek-Stark wrote: > one should (probably) use the > "attname" attribute of a field for its name rather than the "name" > attribute. Why's that? I'm using the "verbose_name" attribute of the field and capitalizing the first letter to match the admin inter

Re: Public method for getting model field names in order of definition

2009-11-21 Thread Anssi Kaariainen
On Nov 21, 6:25 am, Rob Hudson wrote: > But if you wanted to redisplay that information back to the user in a > read-only form, there is no iterative way to do so (as far as I know). >  Instead you must specifically "hard code" each field: > >     >         Field 1 >         {{ profile.field1 }

Re: Public method for getting model field names in order of definition

2009-11-20 Thread Rob Hudson
On Wed, Oct 21, 2009 at 6:38 AM, David Chandek-Stark wrote: > > The values_list() query set method is useful for dumping data to CSV, > etc.  However, I find that I often want to use it without specifying > the field names (to get them all) and yet also include the field names > as the first row i

Public method for getting model field names in order of definition

2009-10-21 Thread David Chandek-Stark
The values_list() query set method is useful for dumping data to CSV, etc. However, I find that I often want to use it without specifying the field names (to get them all) and yet also include the field names as the first row in my data export. There is no "public" method for getting all the nam