Hi David,

I have a solution for you that works for everything except ManyToMany
fields (I believe).  If there's an easier way to do this, I'd love to
hear about it, and if anyone has an idea how I could push further to
tackle ManyToMany fields I'd love to hear it.

from: /contrib/admin/views/main.py copy "def add_stage" to your view
(renaming it would probably be smart - I called mine addMainPage).

in your urls.py add something along the lines of:
(r'^admin/mainpage/(?P<module_name>[^/]+)/add/',
('fashion18.views.addMainPage')),

(notice here that I've hard coded "mainpage", so in "def add_stage" I
also hard coded app_label:

def addMainPage(request, module_name, show_delete=False, form_url='',
post_url='../', post_url_continue='../%s/', object_id_override=None):
         app_label = "mainpage"

between "# Add default data" and "# Override the defaults with GET
params, if they exist" add what you need to, in mine the important part
looked like:

new_data.update(dict({"subscription":latest_page.subscription,"poll_id":latest_page.p

oll_id,"button_ad_id":latest_page.button_ad_id,"win_id":latest_page.win_id,"online_only":latest_p
       age.online_only}))

Since no object has been created at this point, I'm unable to copy the
data for the ManyToMany field (or, I suspect, a ManyToOne field).  If
anyone could point me in the right direction for copying the ManyToMany
relationships for the new object I'd appreciate it.

For your author example, you could simply modify the add function to
accept your author object (or just the field you need), then manually
set it like I have (and yours would probably be quite a bit easier).

Cheers,

John


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to