Thanks again.  It works after the the second underscore.

On Apr 26, 8:18 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Sun, Apr 26, 2009 at 8:17 PM, tekion <tek...@gmail.com> wrote:
>
> > Doh!!!, I can't believe I missed that.  Thanks that work.
>
> > I ran into another issue with Page.objects.filter, namely:
> > Exception Value:
> > Cannot resolve keyword 'name_contains' into field. Choices are:
> > content, name
>
> > I used name and it works.  I am assuming the "name_contains" is
> > deprecated in Django 1.1?  Thanks.
>
> > On Apr 26, 7:39 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> > > On Sun, Apr 26, 2009 at 7:37 PM, tekion <tek...@gmail.com> wrote:
>
> > > > All,
> > > > I am trying to follow a tutorial,  below is the code snippet:
> > > > # Create your views here.
> > > > from play_django.mywiki.models import Page
> > > > from django.shortcuts import render_to_response
> > > > from django.http import HttpResponseRedirect
> > > > from django import forms
> > > > import markdown
>
> > > > class SearchForm(forms.Form):
> > > >        text =  forms.CharField(label="Enter Search Form")
>
> > > > def search_page(request):
> > > >        if request.method == "POST":
> > > >                f = SearchForm(request.POST)
> > > >                if  f.is_valid:
> > > >                        pages = Page.objects.filter(name_contains =
> > > > f.cleaned_data['text'])
> > > >                        return render_to_response("search.html",
> > {"form":f,
> > > > "pages":pages})
> > > >                else:
> > > >                        return render_to_response("search.html",
> > {"form":f})
> > > >        f = SearchForm()
> > > >        return render_to_response("search.html", {"form":f})
>
> > > > Below is the error:
> > > > AttributeError at /play_django/SearchPage/
>
> > > > 'SearchForm' object has no attribute 'cleaned_data'
>
> > > > Request Method:         POST
> > > > Request URL:    http://127.0.0.1:8000/play_django/SearchPage/
> > > > Exception Type:         AttributeError
> > > > Exception Value:
>
> > > > 'SearchForm' object has no attribute 'cleaned_data'
>
> > > > Exception Location:     C:\Documents and Settings\kchan\My Documents
> > > > \Scripts\play_django\..\play_django\mywiki\views.py in search_page,
> > > > line 15
> > > > Python Executable:      C:\Python26\python.exe
> > > > Python Version:         2.6.2
> > > > Python Path:    ['C:\\Documents and Settings\\kchan\\My Documents\
> > > > \Scripts\\play_django', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\
> > > > \Python26\\DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win',
> > > > 'C:\\Python26\\lib\\lib-tk', 'C:\\Python26', 'C:\\Python26\\lib\\site-
> > > > packages']
> > > > Server time:    Sun, 26 Apr 2009 17:29:12 -0400
>
> > > > Any thoughts as to why it is not recognizing cleanted_data? Thanks in
> > > > advance.
>
> > > You need to call is_valid, it is a method, not a property, so that should
> > be
> > > if f.is_valid().
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right
> > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
> You dropped a second underscore, it should be name__contains, to use that
> lookup.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to