Django admin sets default form field values based on GET parameters

Django
2011-06-21 02:14 (13 years ago) ytyng

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

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011