Looks like someone already asked this question (and got an answer); https://groups.google.com/forum/?fromgroups=#!topic/django-users/ef-Yedt_0uo
Here is a good place to start learning about forms - plenty of examples etc; https://docs.djangoproject.com/en/dev/ref/forms/api/ Hope this helps! Cal On Tue, Oct 9, 2012 at 7:43 PM, sri <devanasrika...@gmail.com> wrote: > Hi, > > I am new to Django/Web development and i am trying to create a drop down > menu in my sample website and got stuck about the best way to develop it. > > My idea is to have a drop down of the city names on the homepage. City > Names can be selected from the model character field having choices. > > The model looks like below : > > CITY_NAMES = ( > (u'L', u'London'), > (u'NU', u'Newcastle Upon Tyne'), > (u'M', u'Manchester'), > ) > > class samplemodel(models.Model): > city_names = models.CharField(max_length =2, choices = > CITY_NAMES,default = 'L') > > And my URL file looks like below. > > url(r'^(?P<city_name>\c+)/', 'cityhomepage'), > url(r'^$', 'cityhomepage') > > And my views looks like below > > def cityhomepage(request, city_name = 'London'): > /** do something **/ > > From the drop down when user selects a specific city, then i want to call > the view "cityhomepage" by passing the city_name selected by the user as > argument. > > Could you please suggest, what i need to write in my templates or forms.py > files to get the outcome. > > Thanks > Sreekanth > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/E5n-baE-Zc0J. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.