Hi all,

I´m currently writing an app to track expenses (using Django). For
this I´ve a simple datamodel which basically consists of two model
classes: Register and Entry. The idea is that you can book expenses in
various Registers, one Entry representing a particular Expense.

Now my issue is the following. I´d like to provide for a page where
you can bulk-create say 5 expense Entries at onces. I.e. a form with 5
rows, each row being a complete input line for a single expense Entry,
with a select box for selecting the Register the new entry should
belong to and fields for the amount, currency etc.

[Side note: This seems similar to inline edit of related objects (as
done in part 2of the tutorial, Adding related objects), however is a
bit different since in my case the object those Entries will be related
to already exists and the entries themselves do not (where as in the
examples both the poll and the choices are created at the same time).]

Now, I´m familiar with FormEncode and that let me define a form like
(simplified pseudocode):
<form>
<select name="entry-0.register_id">...</select><input
name="entry-0.amount" />
<select name="entry-1.register_id">...</select><input
name="entry-1.amount" />
...
<select name="entry-4.register_id">...</select><input
name="entry-4.amount" />
</form>

Decoding the POSTed data using the provided decode function returns a
list of dicts (each dict representing a to-be-created Entry). I.e.
[{"register_id": r111, "amount":a111}, {"register_id": r222,
"amount":a222}, ..., ..., ...]. On receiving the POST data it is as
simple as having the data decoded (and validated at the same time) by
FormEncode, cycle through the returned list and create each entry using
the dict´s contents.

Can I do something similar with the Manipulator framework (or other
part of Django)? And if so, how?

Oh - and another (slightly related) question: how do I do something
similar in effect to "for n in range(0, 4)" in a template? Currently I
(ab)use an array with length 4 for this (just iterating over it and
only using the loop counter), but there is probably a nicer solution.

Thanks in advance,

Rgds,
Jeroen


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to