On Jul 21, 2009, at 4:22 PM, Dan Harris wrote:
> > What do you mean by having the ID "in" the form? I don't quite > understand what you are trying to do. > > On Jul 21, 4:15 pm, mettwoch <[email protected]> wrote: >> Ok, I come back to what I wrote before. If the partner already exists >> it has an id (primary-key or whatever). If it doesn't exist it has no >> id. I'd just like to have the id in the form. Is it a bug, is >> something missing here or am I completely on the wrong track. That's >> basic database form handling. Well I could fallback to using Form >> instead of ModelForm and maybe I'll manage to get that id in the form >> as a hidden field or whatever, but I wonder how such basic things >> seem >> impossible with the ModelForm. >> >> Thanks for Your patience >> >> Marc >> What he's referring to is the fact that, if you're using a ModelForm, the model's ID is not available in the template. And my answer to the question is that I use the ID (or a slug) in both the URL and in the form's "action" argument, so that when it's submitted, you have the info you need in the request. Just as a quick example: (r'^patient/(?P<slug>[-\w]+)/$', 'view'), This will pass the variable "slug" to the view, and the slug is used to identify the patient. If you don't use slugs, the ID works just as well (although it makes for less friendly- looking URLs). --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---

