On Oct 5, 12:52 pm, chocolatero <[email protected]> wrote:
> 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?!!
In your two calls to filter, you're trying to get all objects where
the id is equal to your page_title value. Obviously, that can't work.
You want to query against the model field that contains that page
title:
Page.objects.filter(title=page_title, public=True)
(or whatever your title field is called).
--
DR.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.