I have a form page with some choice fields in it. On my local machine with python 3.4.3, the choice fields are working very well. On python 3.6.3, the choice fields are listing the choices but; 1. the choices are listed horizontally 2. the choices are not select-able. 3. the choices are not displayed in a field bar.
kindly see below picture copy of the output display. choices error output
form.py
from django import forms
from django.forms import Textarea, TextInput, Select, FileInput
class PostGraduateForm(forms.ModelForm):
class Meta:
model = PostGraduate
fields = '__all__'
exclude = ['is_visible']
widgets = {
'surname': TextInput(attrs={'size': '27', 'style': 'height: 30px;'}),
'firstname': TextInput(attrs={'size': '27', 'style': 'height: 30px;'}),
'middle_name': TextInput(attrs={'size': '27', 'style': 'height: 30px;'}),
'email_address': TextInput(attrs={'size': '27', 'style': 'height: 30px;'}),
'phone_number': TextInput(attrs={'size': '27', 'style': 'height: 30px;'}),
'contact_address': TextInput(attrs={'size': '27', 'style': 'height: 30px;'}),
'course': TextInput(attrs={'size': '27', 'style': 'height: 30px;'}),
'nationality': TextInput(attrs={'size': '27', 'style': 'height: 30px;'}),
'gender': Select(attrs={'style': 'height: 30px; width: 220px;'}),
'faculty': Select(attrs={'style': 'height: 30px; width: 220px;'}),
'form_number': TextInput(attrs={'size': '27', 'style': 'height: 30px;', 'placeholder': ' E.g. PGXXXXXXXXX'}),
'department': Select(attrs={'style': 'height: 30px; width: 220px;'}),
'programme': Select(attrs={'style': 'height: 30px; width: 220px;'}),
'academic_session': TextInput(attrs={'size': '27', 'style': 'height: 30px;'}),
'passport': FileInput(attrs={'style': 'height: 30px; width: 220px;'}),
'project_proposal': FileInput(attrs={'style': 'height: 30px; width: 220px;'}),
'project_title': Textarea(attrs={'cols': 75, 'rows': 20, 'style': 'height: 110px;'}),
}
model.html
class PostGraduate(models.Model):
surname = models.CharField(max_length = 50)
firstname = models.CharField(max_length = 50)
middle_name = models.CharField(max_length = 50, blank = True)
pg_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
email_address = models.EmailField(unique = True, max_length = 50)
phone_number = models.CharField(max_length = 15)
identification = models.CharField(max_length=100, blank=True, unique=True, default=uuid.uuid4().hex[:6].upper(), editable=False)
FEMALE = 'FEMALE'
MALE = 'MALE'
GENDER_CHOICES = ((MALE, 'MALE'), (FEMALE, 'FEMALE'))
gender = models.CharField(max_length = 10, choices=GENDER_CHOICES, default=None)
#password = models.CharField(max_length = 50)
nationality = models.CharField(max_length = 50)
PHARMACEUTICAL_SCIENCES = 'PHARMACEUTICAL SCIENCES'
NATURAL_SCIENCE = 'NATURAL SCIENCE'
MEDICAL_LABOURATORY = 'MEDICAL LABOURATORY'
FACULTY_CHOICES = ((PHARMACEUTICAL_SCIENCES, 'PHARMACEUTICAL SCIENCES'), (NATURAL_SCIENCE, 'NATURAL SCIENCE'), (MEDICAL_LABOURATORY, 'MEDICAL LABOURATORY'))
faculty = models.CharField(max_length = 50, choices=FACULTY_CHOICES, default=None)
form_number = models.CharField(unique = True, max_length = 50)
PHARMACEUTICAL_CHEMISTRY = 'PHARMACEUTICAL CHEMISTRY'
CLINICAL_PHARMACY = 'CLINICAL PHARMACY'
PHARMACOGNOSY = 'PHARMACOGNOSY'
PHARMACEUTICAL_TECHNOLOGY = 'PHARMACEUTICAL TECHNOLOGY'
PLANT_SCIENCE = 'PLANT SCIENCE AND TECHNOLOGY'
CHEMISTRY = 'CHEMISTRY'
BIOCHEMISTRY = 'BIOCHEMISTRY'
DEPARTMENT_CHOICES = (
(PHARMACEUTICAL_CHEMISTRY, 'PHARMACEUTICAL CHEMISTRY'), (CLINICAL_PHARMACY, 'CLINICAL PHARMACY'),
(PHARMACOGNOSY, 'PHARMACOGNOSY'), (PHARMACEUTICAL_TECHNOLOGY, 'PHARMACEUTICAL TECHNOLOGY'),
(PLANT_SCIENCE, 'PLANT SCIENCE AND TECHNOLOGY'), (CHEMISTRY, 'CHEMISTRY'), (BIOCHEMISTRY, 'BIOCHEMISTRY')
)
department = models.CharField(max_length = 500, choices=DEPARTMENT_CHOICES, default=None)
MSc = 'MASTERS (MSc)'
PhD = 'DOCTOR OF PHILOSOPHY (PhD)'
PROGRAMME_CHOICES = ((MSc, 'MASTERS (MSc)'), (PhD, 'DOCTOR OF PHILOSOPHY (PhD)'))
programme = models.CharField(max_length = 500, choices=PROGRAMME_CHOICES, default=None)
academic_session = models.CharField(max_length = 500)
contact_address = models.CharField(max_length = 500)
course = models.CharField(max_length = 500)
project_title = models.TextField(blank = False)
project_proposal = models.FileField(upload_to='Post Graduate/proposal/%d-%m-%Y/', blank = False,)
passport = models.ImageField(upload_to='Post Graduate/passport/%d-%m-%Y/', blank = False,)
created_at = models.DateTimeField(auto_now_add = True)
updated_at = models.DateTimeField(auto_now = True)
is_visible = models.BooleanField(default = False)
def get_absolute_url(self):
return reverse('peruse:post_detail', kwargs={'pk': self.pg_id})
def __str__(self):
return self.surname + ' - ' + self.firstname
def id(self):
return self.id