Saturday, June 4, 2011

confused over use of XYZ.objects.get() method

according to the docs, .get(**kwargs) is the signature.

I have a model where I have 2 foreign keys that are unique together:

class CaaAnswer(models.Model):
question = models.ForeignKey(CaaQuestion)
assessment = models.ForeignKey(Assessment)
mds = models.CharField(max_length=3, blank=True, default='')
user = models.IntegerField(default=0)

class Meta:
db_table = 'caaanswers'
managed = IS_CAA_MANAGED
unique_together = ("question", "assessment")

question = models.CaaQuestion(pk=210)
assessment = models.Assessment.objects.get(pk=18424)
ok answer = models.CaaAnswer.objects.filter(question=question,
assessment=assessment)
fail answer = models.CaaAnswer.objects.filter(question_id=210,
assessment_id=18424)
fail answer = models.CaaAnswer.objects.get(question=question,
assessment=assessment)

FieldError: Cannot resolve keyword 'assessment_id' into field. Choices
are: assessment, id, mds, question, user

Whenever a user takes a certain (frequent) action I have to execute
this for ~1000 records and compute the "mds" field individually for
each record. I would like to make it efficient.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate