On 7/20/07, John M <[EMAIL PROTECTED]> wrote:
>
> http://.../model3/add/#    - calls a view to add a new model3, with
> foreign key model2 of #
> http://.../model3/edit/#    - calls a view to edit a model3 of ID#
>
> It seems simple enough, but wanted to get everyones feedback on
> anything I'm missing, or is it just this simple?

It's pretty much that simple, although there are a few details I would suggest:

- You have add and edit views, but no 'view' view - i.e., just show me
the object. The best place for this is probably http://.../model1/#
for model1, ID # (repeated for other models). Alternatively, if there
is no such thing as a non-editing view - if you want an object to be
editable whenever it is viewed, just make the http://.../model1/# view
the edit view. If you do this, make sure you do a HttpResponseRedirect
when you POST to prevent the POST request ending up in the browser
history.

- You might want to have a think about your method of foreign key
hinting using the URL. Each URL should be a unique, cachable resource
- in this case, "add an instance of model3". Adding
transient/suggested data to your URL would generally violate this
principle. On top of that, what do you do to the URL space if you need
to specify 2 foreign keys?

A alternate approach would be to pass in the preferred foreign key as
part of the GET dictionary i.e., your request would be:
/model3/add/?model1=3. That way, there is only 1 URL resource (the add
page at /model3/add/), and the view can still work if you have no or
multiple specified foreign key references (just modify the handling of
the GET dictionary to inspect 0, 1 or many keys).

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to