0

I have such models: Article, Link & ArticleLink. Article can have many links attached to it and I need to save them from one form.

I have created all the relations and a ModelForm for Article, but the trick part is that links have two fields: Name and URL. I can't figure out what kind of form structure must be used, I tried hidden inputs with name "links[name]" and "links[url]" but did not work.

Where should I look? Is there any working example for this? Django docs does not help with this particular situation.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Vilis
  • 1,062
  • 2
  • 12
  • 21

1 Answers1

0

You should take a look at inline formsets.

tuxcanfly
  • 2,494
  • 1
  • 20
  • 18
  • Yes, inline formsets looks like the closest solutions, but there are two problems - I am rendering my form manually (have to) and there is a little bit strange field naming "form-0-name", "form-1-name". I was just thinking about looping through all the links and save them manually but I am not able to pass input array, it seems that django does not support it. – Vilis May 18 '13 at 07:42