Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Django Tutorial: global name '[projectname]' is not defined when redirecting to results view. [RSS Feed]

#1 June 14, 2010 08:55:58

Sithembewena L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django Tutorial: global name '[projectname]' is not defined when redirecting to results view.


Hi all,

I am using Django 1.2 to write the Django tutorial poll app. At the end of
my *vote* view, I have the following line of code:
*
return
HttpResponseRedirect(reverse(myproject.polls.views.results(args=(p.id,))))
*

When I navigate tohttp://127.0.0.1:8000/polls/1/vote/, I am able to vote,
but during the redirect to the results page of that poll, I get an exception
as follows:

*"global name 'myproject' is not defined"*

I discovered that I can get around this by importing my project, but somehow
that feels wrong - and the tutorial explicitly says to use the full name of
the view including the prefix as an argument to the reverse() function.

What could be wrong?

Thanks

--
Regards,
Sithembewena Lloyd Dubehttp://www.lloyddube.com--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 June 14, 2010 09:07:49

Daniel R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django Tutorial: global name '[projectname]' is not defined when redirecting to results view.


On Jun 14, 8:55 am, Sithembewena Lloyd Dube <zebr...@gmail.com> wrote:
> Hi all,
>
> I am using Django 1.2 to write the Django tutorial poll app. At the end of
> my *vote* view, I have the following line of code:
> *
> return
> HttpResponseRedirect(reverse(myproject.polls.views.results(args=(p.id,))))
> *
>
> When I navigate tohttp://127.0.0.1:8000/polls/1/vote/, I am able to vote,
> but during the redirect to the results page of that poll, I get an exception
> as follows:
>
> *"global name 'myproject' is not defined"*
>
> I discovered that I can get around this by importing my project, but somehow
> that feels wrong - and the tutorial explicitly says to use the full name of
> the view including the prefix as an argument to the reverse() function.
>
> What could be wrong?
>
> Thanks

You have not done what the tutorial says. It says to use the full
**name** of the function. For some reason, you are trying to *call*
the function and pass the parameters. That will end up passing the
output of the function to reverse(), which is certainly not what you
want.

Instead, do what the tutorial says:
return HttpResponseRedirect(reverse("myproject.polls.views.results",
args=(p.id,)))
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 June 14, 2010 09:14:34

Sithembewena L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django Tutorial: global name '[projectname]' is not defined when redirecting to results view.


Thanks Daniel, that is absolutely right.

On Mon, Jun 14, 2010 at 10:07 AM, Daniel Roseman <dan...@roseman.org.uk>wrote:

> On Jun 14, 8:55 am, Sithembewena Lloyd Dube <zebr...@gmail.com> wrote:
> > Hi all,
> >
> > I am using Django 1.2 to write the Django tutorial poll app. At the end
> of
> > my *vote* view, I have the following line of code:
> > *
> > return HttpResponseRedirect(reverse(myproject.polls.views.results(args=(
> p.id,))))
> > *
> >
> > When I navigate tohttp://127.0.0.1:8000/polls/1/vote/, I am able to
> vote,
> > but during the redirect to the results page of that poll, I get an
> exception
> > as follows:
> >
> > *"global name 'myproject' is not defined"*
> >
> > I discovered that I can get around this by importing my project, but
> somehow
> > that feels wrong - and the tutorial explicitly says to use the full name
> of
> > the view including the prefix as an argument to the reverse() function.
> >
> > What could be wrong?
> >
> > Thanks
>
> You have not done what the tutorial says. It says to use the full
> **name** of the function. For some reason, you are trying to *call*
> the function and pass the parameters. That will end up passing the
> output of the function to reverse(), which is certainly not what you
> want.
>
> Instead, do what the tutorial says:
> return HttpResponseRedirect(reverse("myproject.polls.views.results",
> args=(p.id,)))
> --
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>
>


--
Regards,
Sithembewena Lloyd Dubehttp://www.lloyddube.com--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Django Tutorial: global name '[projectname]' is not defined when redirecting to results view. [RSS Feed]

Board footer

Moderator control

Enjoy the 19th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support