You have an ident issue of some sort. pre_ques is out of scope if the 
request.method is not POST.

François

> On May 11, 2015, at 7:24 AM, 田福顿 <tianfu...@gmail.com> wrote:
> 
> This is my code, 
> 
> def test_words(request):
>     if request.method == "POST":
>         i_d = request.user.id
>         pre_word = []
>         pre_mean = []
>         pre_ques = 
> {"word":"","option1":"","option2":"","option3":"","option4":""}
>         key_list = ["option1","option2","option3","option4"]
>         pre_set =WordBase.objects.order_by('?')[:4]
>         for pre_ser_odd in pre_set:
>             pre_word.append(pre_ser_odd.word)
>             pre_mean.append(pre_ser_odd.mean)
>         pre_ques["word"] = random.choice(pre_word)
>         while option_key:
>             option_key = random.choice(key_list)
>             option_value = random.choice(pre_mean)
>             pre_ques[option_key] = option_value
>             key_list.remove(option_key)
>             pre_mean.remove(option_value)
>     context = RequestContext(request)
>     return 
> render_to_response('tag_study/test_words.html',{"pre_ques":pre_ques}, context)
> 
> I have no idea about the error, the tracebank is 
> UnboundLocalError at /tag_study/test_words/
> 
> local variable 'pre_ques' referenced before assignment
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/0f7e7890-322f-4b7f-ad45-b485ed1833ae%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7270DFB9-6473-455B-942B-2A9A189EF97C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to