How to approach this problem?

90 views
Skip to first unread message

César García Tapia

unread,
Jan 3, 2014, 12:48:23 AM1/3/14
to django...@googlegroups.com
I'm trying to solve a problem, but I have no idea how to face it. I need some help :-)

I have a model hierarchy like this:

    class Task(models.Model):
        name = models.CharField(max_length=255)
        number_of_steps = models.IntegerField()

    class StepGroup(models.Model):
        task = models.ForeignKey(Task)
        init_date = models.DateField()

    class Step(models.Model):
        group = models.ForeignKey(StepGroup)
        name = models.CharField(max_length=255)

I must write a dialog where I create a number of Step Groups. An InlineFormSet looks the way to go, but as there are two levels of nesting, I don't know how to do that.

Besides, I need the usual stuff with forms: error control (form.name_of_field.errors), autopopulation when editing the Task, etc, so doing it manually with javascript and server-side handling of the POST request would be too complicated and error-prone.

This is the way I need the form (the number of steps in each group is set by the "number_of_steps" field in the Task model):

+-----------------------------------+
| STEP GROUP 1                      |
|                                   |
| Init date: _____________          |
|                                   |
| Step 1: ________________          |
| Step 2: ________________          |
| Step 3: ________________          |
|                                   |
+-----------------------------------+
| STEP GROUP 2                      |
|                                   |
| Init date: _____________          |
|                                   |
| Step 1: ________________          |
| Step 2: ________________          |
| Step 3: ________________          |
|                                   |
+-----------------------------------+
|                                   |
|             +-------------------+ |
|             | Create step group | |
|             +-------------------+ |
+-----------------------------------+

Please, any kind of help, suggestion or link will be very appreciated :-)

César García Tapia

unread,
Jan 5, 2014, 3:07:19 PM1/5/14
to django...@googlegroups.com
Could anybody help me with this problem, please? I know it's not very polite to ask twice, but I'm stuck on this, and I really need to solve it.

Excuse me for the insistence.

C.

Avraham Serour

unread,
Jan 5, 2014, 6:58:22 PM1/5/14
to django...@googlegroups.com
it looks like you need nested inlines, which I believe is not possible yet (https://code.djangoproject.com/ticket/9025)
in the meantime you can try using this (https://github.com/Soaa-/django-nested-inlines)


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a6e7e2ba-70ee-44ea-b420-05dc854ee03e%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

César García Tapia

unread,
Jan 9, 2014, 12:05:15 AM1/9/14
to django...@googlegroups.com
django-nested-inlines doesn't seem to work with Django 1.6

In case anyone is interested, I solved it with the info in this very valuable post:


Hooray for Nathan Yergler :-)

Rafael Durán Castañeda

unread,
Jan 9, 2014, 11:23:41 PM1/9/14
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages