Tuesday, October 5, 2010

Re: newbie error

Hi,

New_page isn't a valid ID. By default, the id field is a number.

Regards,
Xavier.

Le 5 oct. 2010 à 13:52, chocolatero a écrit :

> Hi Friends! I'm working with django and i have this error:
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/myapp/New_page/
> Django Version: 1.2.3
> Exception Type: ValueError
> Exception Value:
>
> invalid literal for int() with base 10: 'New_page'
>
> Exception Location: /usr/local/lib/python2.6/dist-packages/django/db/
> models/fields/__init__.py in get_prep_value, line 479
> Python Executable: /usr/bin/python
> Python Version: 2.6.4
>
>
> Resume, i want that the identify of my webs will be the title of the
> page. Now, i'm using the "id" of the page, but i want to put the
> page.title instead page.id
>
> The structure of url is :
>
> url(r'^(?P<page_title>[^/]+)/$', 'view_page'),
>
> is correct?
>
>
> and function view_page is:
>
> def view_page(request, page_title):
>
> if request.user.is_authenticated():
> page_qs = Page.objects.filter(Q(id=page_title) &
> (Q(author=request.user)|Q(public=True)))
> else:
> page_qs = Page.objects.filter(id=page_title, public=True)
>
> if page_qs.count() == 0:
> raise HttpResponseNotAllowed()
>
> pag = page_qs[0]
>
> return render_to_response(
> "v/schema.html",
> {"pag":pag},
> context_instance=RequestContext(request))
>
> Someone who wants help me?!!
>
>
>
>
>
>
> --
> 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.
>

--
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.

No comments:

Post a Comment