If you registered your models with adminCreate a widgets.py and put
the following code there
from django.template.loader import render_to_string
from ivl.views import *
def SelectWidgetWithPopUp(url):
class SelectWithPopUp(forms.Select):
def render(self, name, *args, **kwargs):
html = super(SelectWithPopUp, self).render(name, *args,
**kwargs)
popupplus = render_to_string(url, {'field': name})
return html+popupplus
return SelectWithPopUp
url will be the link where it will open a popup for adding new data.
now create the following html file anywhere in your template dir.
<a
href="/admin/yourapp/tblpeople/add/"
class="add-another"
id="add_id_{{ field }}"
onclick="return showAddAnotherPopup(this);">
<img src="/media/img/admin/icon_addlink.gif"
width="10" height="10" alt="Add Another"/>
</a>
href location is where my tblpeople model is and I am pointing the
"add" view.
Now in the admin.py
#Import the widget
from yourapp.widgets import SelectWidgetWithPopUp
#This is the form I will use for people dropdownlist
class PeopleForm(forms.Form):
peopleid=forms.ModelChoiceField(label='Authors',queryset=Tblpeople.objects,
widget=SelectWidgetWithPopUp("people_popup_plus.html"))
people_popup_plus.html is the url for pop up.
--
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.