Re: updated poll example to take points for each item, gives more than 1 to upack err
On Feb 26, 7:10 pm, seamusjrwrote: > > But what is points? Where is it coming from? As the traceback shows > > you, you haven't set the points variable anywhere. Where are you > > expecting it to come from? > > -- > > DR. > > I want to iterate thru the points property of the Song object, from > models.py, how can I output that from the views to the db? Below is > from models.py > > class Song(models.Model): > poll = models.ForeignKey(Poll) > name = models.CharField(max_length=200) > points = models.IntegerField() > > def __unicode__(self): > return self.song I'm sorry, I really don't understand what you're trying to do. How do you mean, iterate through? Points is an integer field, there is only one value. If you want me to help you, please post your entire views.py, models.py and template on dpaste.com. Post the link here, along with a full explanation of what you're trying to do, and what you expect the output to be. -- 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: updated poll example to take points for each item, gives more than 1 to upack err
> But what is points? Where is it coming from? As the traceback shows > you, you haven't set the points variable anywhere. Where are you > expecting it to come from? > -- > DR. I want to iterate thru the points property of the Song object, from models.py, how can I output that from the views to the db? Below is from models.py class Song(models.Model): poll = models.ForeignKey(Poll) name = models.CharField(max_length=200) points = models.IntegerField() def __unicode__(self): return self.song --~--~-~--~~~---~--~~ 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: updated poll example to take points for each item, gives more than 1 to upack err
> But what is points? Where is it coming from? As the traceback shows > you, you haven't set the points variable anywhere. Where are you > expecting it to come from? > -- > DR. I want to iterate thru the points property of the Song object, from models.py, how can I output that from the views to the db? Below is from models.py class Song(models.Model): poll = models.ForeignKey(Poll) name = models.CharField(max_length=200) points = models.IntegerField() def __unicode__(self): return self.song --~--~-~--~~~---~--~~ 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: updated poll example to take points for each item, gives more than 1 to upack err
> But what is points? Where is it coming from? As the traceback shows > you, you haven't set the points variable anywhere. Where are you > expecting it to come from? > -- > DR. I want to iterate thru the points property of the Song object, from models.py, how can I output that from the views to the db? Below is from models.py class Song(models.Model): poll = models.ForeignKey(Poll) name = models.CharField(max_length=200) points = models.IntegerField() def __unicode__(self): return self.song --~--~-~--~~~---~--~~ 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: updated poll example to take points for each item, gives more than 1 to upack err
On Feb 26, 5:10 pm, seamusjrwrote: > Ok, I got rid of the pointx variables, replaced them with the > following and restarted the server. > > selected_song_set.points = points > selected_song_set.save() > > Here is the traceback: > > Environment: > > Request Method: POST > Request URL:http://127.0.0.1:8000/polls/1/vote/ > Django Version: 1.1 pre-alpha SVN-9814 > Python Version: 2.5.1 > Installed Applications: > ['django.contrib.admin', > 'django.contrib.auth', > 'django.contrib.comments', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'mysite.polls'] > Installed Middleware: > ('django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware') > > Traceback: > File "/Library/Python/2.5/site-packages/django/core/handlers/base.py" > in get_response > 86. response = callback(request, *callback_args, > **callback_kwargs) > File "/Users/seamus/Sources/django/mysite/../mysite/polls/views.py" in > vote > 18. selected_song_set.points = points > > Exception Type: NameError at /polls/1/vote/ > Exception Value: global name 'points' is not defined But what is points? Where is it coming from? As the traceback shows you, you haven't set the points variable anywhere. Where are you expecting it to come from? -- 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: updated poll example to take points for each item, gives more than 1 to upack err
Ok, I got rid of the pointx variables, replaced them with the following and restarted the server. selected_song_set.points = points selected_song_set.save() Here is the traceback: Environment: Request Method: POST Request URL: http://127.0.0.1:8000/polls/1/vote/ Django Version: 1.1 pre-alpha SVN-9814 Python Version: 2.5.1 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.comments', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'mysite.polls'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "/Library/Python/2.5/site-packages/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/Users/seamus/Sources/django/mysite/../mysite/polls/views.py" in vote 18. selected_song_set.points = points Exception Type: NameError at /polls/1/vote/ Exception Value: global name 'points' is not defined --~--~-~--~~~---~--~~ 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: updated poll example to take points for each item, gives more than 1 to upack err
On Feb 26, 3:41 am, seamusjrwrote: > I am trying to modify the polls example from djangoproject.com to take > a integer point value for each of the 1 thru 5 poll items instead of > having a radio button where u select one. However, I am having > problems with the views.py syntax. I changed the Choice obejct to be > a Song object and changed the name of the choice and votes properties > to be name and points respectively. I keep getting this annoying > "need more than 1 value to unpack" error. Below are some snippets of > code. Please can someone help me out with the views syntax, or do I > need to create a ModelForm/form to deal with getting the input to the > views. > > Thanks in advance, > Seamus > Is there any reason you couldn't actually post the traceback - which shows exactly where the error happens - instead of this load of random code snippets? I don't know if anyone will be bothered to read through it all to find out what's wrong, especially when there's no way your code could run as posted (where do all those pointx variables come from?) Please, post the traceback, and the minimal amount of actual code that produces the error. -- 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 -~--~~~~--~~--~--~---