Hello,

I can't seem to understand how to do this with newforms 'properly':

1) A base model, call it Apartment.
2) A model called Person, who lives in an Apartment, i.e., a 
ForeignKey(Apartment)

Now, what I want to do is to get a form like the admin has with 
edit_inline, so something like:

    person_form_instances = [person_form("pf%d" % i) for i in xrange(5)]

Which sort of works, but it doesn't really give me the same options and 
so forth that I get with the admin's interface.

Sure, I could implement this on my own, but I'm just thinking, isn't 
this a sort of commons situations? Shouldn't newforms try to be a tad 
bit more convenient in this situation?

Oh and a related question, when we do this:

    if request.method == 'POST':
        form = FooForm(request.POST)
        # ...
    else:
        form = FooForm()
    # render with {'form': form}

Couldn't this be collapsed into:

    d = (request.method == 'POST' and request.POST) or {}
    form = FooForm(d)

    if d:  # Or alternatively request.method == 'POST'.
        if form.is_valid():
            return HttpResponseRedirect("...")
    # render with {'form': form}

For one form that doesn't make sense, obviously - but when they get 
more, you start to get code duplication, seeing as each form needs two 
lines on both 'sides' of the if statement.

Sincerely,
Ludvig Ericson

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