hi,
i want to make a custom form in admin.py for modify the form of a model that should show a combobox with all urlpattern name defined in urls.py.
I tryed with this code (i'm a python/django newbie, sorry ;)):
def fasullo():
pass
class NameURLForm(forms.ModelForm):
class Meta:
model = NameURL
fields = ['nameStart', 'nameEnd']
def clean_date(self):
pass
def __init__(self, *args, **kwargs):
super(NameURLForm, self).__init__(*args, **kwargs)
listURL = []
for name, L in get_resolver(None).reverse_dict.items():
if type(name) != type(fasullo):
if name != None and name != "":
listURL.append(name)
self.fields['nameStart'] = forms.ChoiceField(choices=listURL)
self.fields['nameEnd'] = forms.CharField(label="nameEnd", max_length=80,required=True,
widget=forms.Select(choices=[(i,listURL[i]) for i in range(len(listURL))]))
any hint?