Django admin sets default form field values based on GET parameters

Django
2011-06-20 17:14 (14 years ago)
Django admin sets default form field values based on GET parameters

When you pass a GET query like

?name=hoge&url=fuga

to the Django admin's new record addition page, it will pre-fill the corresponding fields with these default values.

This works well with bookmarklets.

For example, you can create a bookmarklet like this:

javascript:window.open('https://example.com/admin/spamapp/eggmodel/add/?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href),'_blank','width=800,height=600,menubar=no,toolbar=no,resizable=yes,scrollbars=yes');void(0);

or something similar.

Current rating: 3.0 (1)
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Categories

Archive