I have authentication app with
models:
LIVING_COUNTRIES = [
('AFGANISTAN', 'Afganistan'),
('ALBANIA', 'Albania'),
('ALGERIA', 'Algeria'),
('ANGORRA', 'Andorra'),
('ANGOLA', 'Angola')]
class Employee(models.Model):
first_name = models.CharField(max_length=100, blank=True)
last_name = models.CharField(max_length=100, blank=True)
username = models.CharField(max_length=30, blank=True)
email = models.EmailField(max_length=140, blank=True)
# phone_number = PhoneNumberField(null=True)
date_of_birth = models.DateField(blank=True, default='1929-22-22')
education = models.CharField(max_length=50, blank=True)
country_living = models.CharField(max_length=50, choices=LIVING_COUNTRIES, default='UNITEDSTATESOFAMERICA', blank=True)
created_at = models.DateTimeField(auto_now_add=True, blank=True)
password = models.CharField(max_length=30, null=True)
Now I want to display country_living field in my html form.
I have tried like this:
<select name="category" id="id_category">
{% for category in living_countries.country_living %}
<option value="{{ category.country_living }}">{{ category.country_living }</option>
{% endfor %}
</select>
def get(self, request):
context = {}
living_countries = models.Employee.objects.all()
context['living_countries'] = living_countries
return render(request, 'authentication/employee_register.html', context)
But it doesn't work. Does anyone know how to access and display this field?