Preston,

I had a similar problem to solve when working on a research project
that collected a lot of data from companies, much of which was
missing. As I understand it, your data set is effectively a sparse,
two-dimensional matrix [1], and you want to be able to edit this in
the browser. I'd suggest you make the idea of the matrix more
concrete, and perhaps have a separate model/class that provides array-
like access to this, perhaps even caching all the data. Then you've
two separate problems to solve:

a) Be able to convert between the array-like representation and the
database representation.
b) Be able to edit the array-like representation in the browser, and
get bit back.

I'm a newbie at Django but as I understand it, for a), since you'll be
working with more than just one record, you'd want a "manager" to be
involved somewhere here. And for b) you'd have a model that's not
stored in the database, and a custom form that works with your matrix
class.

[1] http://en.wikipedia.org/wiki/Sparse_matrix

I'm a little rusty on this but a relevant design pattern is
http://en.wikipedia.org/wiki/Builder_pattern.

I need a similar control for an upcoming project, so I'm interested to
know what you and others come up with.

Toby (Seattle, WA)

On Nov 16, 6:12 am, derek <gamesb...@gmail.com> wrote:
> Preston
>
> Having not done this before (but maybe needing to soon...) the grid
> approach seems the best solution.
>
> Actually this is not really a Django issue per se; more a "mismatch"
> between the "excel-type" view and the underlying database reality.
> Django is just the middle-man, translating "filled-in holes" to clean
> database records.
>
> I would think there must be a neat JQuery interface one could
> construct for the view?
>
> Derek
>
> On Nov 16, 1:01 am, Preston Holmes <pres...@ptone.com> wrote:
>
> > This is a cart/horse pattern I run now and then, and while I can think
> > of several sort of ugly ways to do it, I'm wondering if someone has a
> > clean solution in Django.
>
> > I'm going to use a gradebook as an example.  The goal is to present a
> > user with a grid of lets say students and assignments to enter
> > grades.  The models would be
>
> > - Students
>
> > - Assignments
>
> > - Grades (a M2M between students and assignments)
>
> > Now on the grade entry form, with multiple students and assignments,
> > the grades don't yet exist for all students, and may not all be
> > entered.  How does one generate the form for the possibilities,
> > without pre-creating all the empty grades.
>
> > It would be nice to use modelform here, but it seems that that the
> > only way to do it is just with a form and then create objects for
> > grades that get filled out in the view.  How do others solve this
> > problem of representing a "possible future" object in a form that is
> > then only optionally created if filled out.
>
> > -Preston

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to