class Answer(models.Model):
question = models.ForeignKey(Question)
answer = models.CharField(max_length=30)
class Response(models.Model):
answer = models.ForeignKey(Answer)
user = models.ForeignKey(User)
time = models.DateTimeField(auto_now_add=True)
class Profile(models.Model):
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
user = models.OneToOneField("auth.User")
age = models.IntegerField(max_length=2)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
zipcode = models.IntegerField(max_length=5)
state = models.CharField(max_length=15)
I have a Response model that is answers to a question and a Profile model for each user and was wondering how to go about the query to get a list of each users answer (they are unique for each question for each user) and their profile info. In the end I want to say what percentage of men answered one way vs another, how states voted, etc. I am able to make a query to see what percentage of users voted for each question, but havent been able to break it down farther. How would I make a query to find something like what percentage of an answer each gender voted for?
If i could join the Profile and Response tables on User I would be able to make a numpy array and analyze it like that, which I think would be helpful as well.