Re: weird ValueError
stupid error, thank you On Jul 20, 12:23 pm, Daniel Rosemanwrote: > On Jul 20, 11:13 am, Viktor wrote: > > > my view calls > > > survey = get_object_or_404(models.Survey, {'pk': int(survey_id)}) > > > and gives a ValueError: need more than 1 value to unpack, the full > > traceback is athttp://python.pastebin.com/m3f715909 > > > I have no clue what the problem might be, especially as I've seen that > > in the debug views I've seen that is already has the to be returned > > survey instance. Could someone help me please. :) > > get_object_or_404 takes (in addition to the model) the same syntax as > the normal get or filter calls. So you can't just pass a dictionary of > parameters. Try: > survey = get_object_or_404(models.Survey, pk=int(survey_id)) > or, if you must use a dictionary: > survey = get_object_or_404(models.Survey, **{'pk': int(survey_id)}) > to convert the dict into kwargs. > -- > DR. --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: weird ValueError
On Jul 20, 11:13 am, Viktorwrote: > my view calls > > survey = get_object_or_404(models.Survey, {'pk': int(survey_id)}) > > and gives a ValueError: need more than 1 value to unpack, the full > traceback is athttp://python.pastebin.com/m3f715909 > > I have no clue what the problem might be, especially as I've seen that > in the debug views I've seen that is already has the to be returned > survey instance. Could someone help me please. :) > get_object_or_404 takes (in addition to the model) the same syntax as the normal get or filter calls. So you can't just pass a dictionary of parameters. Try: survey = get_object_or_404(models.Survey, pk=int(survey_id)) or, if you must use a dictionary: survey = get_object_or_404(models.Survey, **{'pk': int(survey_id)}) to convert the dict into kwargs. -- DR. --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
weird ValueError
my view calls survey = get_object_or_404(models.Survey, {'pk': int(survey_id)}) and gives a ValueError: need more than 1 value to unpack, the full traceback is at http://python.pastebin.com/m3f715909 I have no clue what the problem might be, especially as I've seen that in the debug views I've seen that is already has the to be returned survey instance. Could someone help me please. :) my model's are (the full code is available at https://launchpad.net/django-questions ) from django.db import models from django.contrib.auth.models import User class FieldType(models.Model): name = models.CharField(max_length=255, unique=True, help_text="A user-friendly name for the field") type = models.CharField(max_length=255, help_text="The field name used by django") validate = models.CharField(max_length=255, blank=True, help_text="The path to the validate function") arguments = models.TextField(blank=True, help_text="Extra arguments passed as json") def __unicode__(self): return u'%s' %(self.name) class Survey(models.Model): title = models.CharField(max_length=255) question = models.ManyToManyField('Question') def __unicode__(self): return u'%s' % self.title class Question(models.Model): label = models.CharField(max_length=255) field = models.ForeignKey(FieldType) required = models.BooleanField(default=True) class Answer(models.Model): question = models.ForeignKey(Question) answer = models.TextField() created = models.DateTimeField(auto_now_add=True) def __unicode__(self): return u'%(question)s: %(answer)s' % {'question': self.question.label, 'answer': self.answer} class Responder(models.Model): ''' A model to register answers to users ''' user = models.ForeignKey(User) answer = models.OneToOneField(Answer) def __unicode__(self): return u'%(user)s on %(question)s: %(answer)' % { 'user': self.user.username, 'question': self.answer.question, 'answer': self.answer.answer, } --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---