On Dec 8, 2007 11:51 PM, James Bennett <[EMAIL PROTECTED]> wrote:
> That's exactly what I'd imagined. Your example can be solved right now
> by the following:
>
> class LatLongForm(ModelForm):
>     class Meta:
>         fields = ('latitude', 'longitude')
>
> model_class = figure_out_latlong_model()
> form = LatLongForm(instance=model_class())

Joseph pointed out that I had a brain fart when I wrote this specific
snippet, because 'fields' without 'model' is somewhat nonsensical.

So, to clarify...

Right now:

1. Define a ModelForm subclass and set it up with the generic fields
you care about, but without binding to a particular model.
2. At runtime, figure out what model you're using.
3. Pass an instance of that model to the __init__() of your subclass,
as the first positional argument.

After the change>

1. Define a ModelForm subclass and set it up with the generic fields
you care about, but without binding to a particular model.
2. At runtime, figure out what model you're using.
3. Pass an instance of that model to the __init__() of your subclass,
as the keyword argument 'instance' or as the last positional argument
in a full list of all arguments to __init__().

So again, no real net change. Tweaking my patch to support this should
be relatively easy.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to