I am trying to use the django-countries application with Django for the first time but I am getting this error which has me confused.
TypeError at /survey/ Person() takes exactly 1 argument (0 given)
I installed django-countries 2.1.2 via pip in a virtual environment for the project.
INSTALLED_APPS
INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'polls', 'survey', 'django_countries', )
I am using Django 1.6.4.
models.py
from django.db import models from django_countries.fields import CountryField class Person(models.Model): country = CountryField() def __unicode__(self): return self.country
views.py
from django.shortcuts import render from django.db import models from django_countries.fields import CountryField from models import SexChoice, AgeChoice, RelationshipStatusChoice, Person def Person(request): age = AgeChoice() sex = SexChoice() relationship = RelationshipStatusChoice() country = Person() return render(request, 'survey.html', { 'age': age, 'sex': sex, 'relationship': relationship, 'country': country, })
survy.html
<html> <body> <h1>Experiment Survey</h1> <form action="" method="post"> {% csrf_token %} <h3>What age are you?</h3> {{age.as_p}} <h3>What sex are you?</h3> {{sex.as_p}} <h3>What is your current relationship status?</h3> {{relationship.as_p}} <h3>What country are you from?</h3> {{country.as_p}} <input type="submit" value="Submit" /> </form> </body> </html>
P.S. This is similar to an earlier question but I fixed a few issues and updated some details. I deleted the earlier question.