Hi Eliezer,

The trick is to add a ModelAdmin for Exercise.

The obvious consequence of this is that you'll get a "top level" menu
option to add exercises. However, a side effect is that everywhere that you
have a model with a foreign key to exercise (like in your Segment inline),
you'll get a little green "plus" sign next to the foreign key selector. If
you click on that plus, you'll get a popup that will let you create a new
Exercise. The popup will have the same layout as the "Add Exercise" page
you get if you go through the top level menu, but without the navigation
elements.

When you hit "save" on the new Exercise, the foreign key you clicked on
will be updated to point at the newly added exercise instance.

Yours,
Russ Magee %-)


On Wed, Oct 8, 2014 at 10:02 AM, Eliezer Kanal <eyka...@gmail.com> wrote:

> I'm writing a rudimentary exercise app in django, with the following table
> structure:
>
> Routine Exercise Segment
> ===== ===== =====
> routine_name exercise_name routine_id (fk)
> routine_id exercise_id exercise_id (fk)
> order
> duration
>
> * (fk) = foreign key
>
> In practice, this looks as follows:
>
>
> <https://lh3.googleusercontent.com/-TBTlJazPPBA/VDSaG6O_PFI/AAAAAAAAAUE/UftSycm-NYg/s1600/Screen%2BShot%2B2014-10-06%2Bat%2B8.48.54%2BPM.png>
> A Routine contains numerous Segments, and each segment contains one
> Exercise, the order number (where the segment appears in the routine –
> first, second, third, etc), and the duration of that segment.
>
> My question is, is there an way to allow someone to add a new exercise
> type from the "Add routine" view? I.e., if I'm making a new routine, I
> don't necessarily want to have to drop out and go to the Exercise table
> view to add a new exercise to the list. Thanks in advance!
>
> Elli
>
>
> *Note: This was cross-posted to StackOverflow
> <http://stackoverflow.com/questions/26227062/insert-to-foreign-key-linked-table-in-django-admin-interface>,
> with very few views there. I thought I'd try here as well.*
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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/4955d625-d898-4fdf-b186-a8db536363b9%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4955d625-d898-4fdf-b186-a8db536363b9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CAJxq849nvs8Bu3NSv3gwXRfx6tjTiXX%3DOkMsiQP_uRX59nQtBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to