Electronics & Programming


Open Source electronics development and programming

  • You are not logged in.

#1 Nov. 22, 2005 07:47:51

oggie r.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

admin suggestions

Hi all,
I'm very impressed with 0.90. Works great!
>From the last two weeks (during which I managed to port my access
database, complete with interface - yeah!), I have 3 suggestions wrt
the admin interface:
1) It wasn't obvious how to use the search_fields option with
ForeignKeys. I figured it out eventually, but I guess I missed the
point at the end of the first tutorial (e.g. poll__pub_date__year). You
might want to highlight that in the tutorial a bit more.
2) Adding this gives a lot of flexibility to the admin interface.
(Sorry for the format - I can't get svn diff to work so I'm guessing):
Index: contrib/admin/views/main.py
--- contrib/admin/views/main.py (revision 1350)
+++ contrib/admin/views/main.py (working copy)
@@ -803,5 +803,5 @@
return HttpResponseRedirect(request.path)
- return HttpResponseRedirect(post_url)
+ return HttpResponseRedirect(post_url % pk_value)
if request.POST.has_key("_preview"):

Then you can easily override even using the admin interface, by putting
overrides in the urls.py file above the 'admin' entry and with a
'post_url' dictionary item:
(r'^addnews/$', 'django.contrib.admin.views.main.add_stage', \
{'app_label':'news', 'module_name':'mynews', 'post_url':

3) This one maybe isn't such a useful feature, but it made things easy
for me (again I'm guessing on the svn diff format):
Index: core/meta/__init__.py
--- core/meta/__init__.py (revision 1350)
+++ core/meta/__init__.py (working copy)
@@ -818,4 +818,7 @@
# Run any post-add hooks.
if hasattr(self, '_post_add'):
# Run any post-save hooks.
if hasattr(self, '_post_save'):

And again pretty harmless. I used it to insert new records which
referred to the one I just saved, and didn't have to worry about
getting the last key or anything. Then they were redirected from the
previous 'post_url' %s change.

Hope this helps, and thanks for the great work,


#2 Nov. 23, 2005 23:14:46

oggie r.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

admin suggestions

Oops! I guess I hadn't tried it as much as I thought!
Unfortunately #2 there causes a problem when they aren't overridden (a
TypeError if '%s' is not included in the post_url).
I guess a possible fix is to do a find, e.g.:
if post_url.find('%s') >= 0:
post_url = post_url % pk_value
return HttpResponseRedirect(post_url)
but that is not as clean as I would like.
Anyway it points out that the post_url_continue value may run into the
same problem if it is overridden with a %s argument, however it is
quite unlikely anybody would do that.



Board footer

Moderator control

Enjoy the 22nd of April

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support