ModelChoiceField - large lookup tables

2009-03-24 Thread PNM

Before I re-invent the wheel: is there any generally accepted or
recommended generic way to handle ModelChoiceFields with very large
datasets in Django?

My current example is an address>post/ZIP-code relationship where
Django's automatic field creation pulls in the whole postcode table
with thousands of rows into a ModelChoiceField.

The postcode field changes relatively seldom, so a sensible solution
would seem to be some sort of passive display-only field which mirrors
the choice field's functionality (show the link's __unicode__ and hold
the link's pk for form validation), and that the mechanism for pulling
in a new value is put somewhere else (eg. a button to open a search-
and-select window). A ModelLookupField?

This must be such a common scenario that I'd be interested in hearing
how other people solve it. I can't find anything in the documenation
on it.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: ModelForm - field sort order

2009-03-23 Thread PNM

Thanks - that's it. Sanity confirmed. Those "new in Django xx"
comments are invaluable (when they're there!) for tired eyes looking
at two superficially identical documents.



On Mar 23, 11:40 am, Russell Keith-Magee 
wrote:
> On Mon, Mar 23, 2009 at 6:55 PM, PNM  wrote:
>
> > I have a sorting problem with a completely basic ModelForm instance
> > (the class has only Meta with model and fields) -- the object's
> > __iter__ seems to be following object.fields (as defined in the
> > model), rather than Meta.fields (as the documentation leads me to
> > expect). Is it me, or is there something wrong here?
>
> What version of Django are you using? The ordering behaviour you
> describe was only added recently to trunk; it isn't (and won't ever
> be) available in v1.0.X.
>
> This should be explicitly marked in the documentation, although it
> appears that it isn't. However, if you compare the relevant section of
> the docs between v1.0 and development:
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a...http://docs.djangoproject.com/en/1.0/topics/forms/modelforms/#using-a...
>
> You will see that the operation of Meta.fields has changed.
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



ModelForm - field sort order

2009-03-23 Thread PNM

I have a sorting problem with a completely basic ModelForm instance
(the class has only Meta with model and fields) -- the object's
__iter__ seems to be following object.fields (as defined in the
model), rather than Meta.fields (as the documentation leads me to
expect). Is it me, or is there something wrong here?

The project is at a very early stage -- pretty much as per the
tutorials at the moment, so I can't see that anything should be
interfering with this.

Example (see comment field):

for x in  TESTADDRESS.htmform  :
print x.label_tag()
print '**'
for x in  TESTADDRESS.htmform.Meta.__dict__.get('fields')  :
print x

Result:


Comment
Address name
Address name2
Address postaddress
Address postcode
Address contact
Address telephone
Address telefax
Address mobile
Address email
Address url
Address nickname
Address organisationnumber
**
address_nickname
address_name
address_name2
address_postaddress
address_postcode
address_contact
address_telephone
address_telefax
address_mobile
address_email
address_url
address_organisationnumber
comment

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---