I have successfully configured a way to upload files to a website that I am 
making. However we would like to include a drop-down menu on the site. 
However, we want to include in the form of a drop-down menu called 
"mismatch choice":


models.py: for drop-down menu

             class Mismatches(models.Model):

          MISMATCH_CHOICES = (

           ('0', '0'),

           ('1', '1'),

           ('2', '2'),

           ('3', '3'),

           )

          mismatch = models.IntegerField(max_length=1, default='0', choices 
= MISMATCH_CHOICES)


forms.py for drop-down menu:

              class MismatchesForm(ModelForm): #unsure how to reference a 
class in our in-app-urls.py

            class Meta:

        model = Mismatches

        fields = ['mismatch']

'model=Mismatches' links to the Mismatches class in models and the 'field' 
gives the options.


views.py for drop-down menu

                 class Mismatch_Choice(FormView):

                   template_name = 'list.html'

                   form_class = MismatchesForm



"template_name = 'list.html'" links the html page called list.html. 
'form_class' links to the form 'MismatchesForm'.

html for drop-down menu

                <form action="" method="post">{% csrf_token %}

                  {{ form.mismatch }}

                  <input type="submit" value="Submit" />

                </form>


We used a tutorial as a template for our code but it won't display on our 
html page even though we have referenced it with {{ form.mismatch}} which 
links to the variable 'mismatch' which is set in our form as the 'model' 
and hence links to the options given in models.py. 

We are wondering if the html page is not seeing the drop-down menu because 
it's set as a class in the forms.py but we haven't referenced a class in 
our in-app urls.py (is there a way to do this?)...

NOTE: all migrations were accordingly applied and the server was restarted 
multiple times

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e7785168-32ed-4a42-8406-291ca8140051%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to