thanks, the template error went away but adding this code to views.py
still gives search error.
def search(request):
error = False
if 'q' in request.GET:
q = request.GET['q']
if not q:
error = True
else:
books = Book.objects.filter(title__icontains=q)
return render_to_response('search_results.html',
{'books': books, 'query': q})
return render_to_response('search_form.html',
{'error': error})
Which views.py should i add that code to? -- mysite/views.py OR
mysite/books/views.py ??
Should every folder in mysite have the path set? I mean to ask if I should
have "os.path.join(PROJECT_PATH, 'models')," for databse folder and
"os.path.join(PROJECT_PATH, 'picture')," for my jpg images and "
os.path.join(PROJECT_PATH, 'test'), for the test files and
os.path.join(PROJECT_PATH, 'documentation'), for documentation. Maybe this
is a silly question but its not very clear what to do for the path. thanks.
On Wed, Feb 1, 2012 at 5:51 PM, Joel Goldstick <[email protected]>wrote:
>
>
> On Wed, Feb 1, 2012 at 10:00 AM, yati sagade <[email protected]>wrote:
>
>> I've never run in to a TemplateError for anything other than what I
>> pointed out - maybe in the settings module it is ".../templates" and the
>> name of the directory is "template" (note the 's' in the end) or the other
>> way round. Anyway, check for any misspelling in the template name itself -
>> or whether the template 'search_results.html' is directly under the
>> template directory and not under any subdirectory therein.
>>
>> If you could post the entire debug info (Also the one at the far bottom
>> of the error page), it might be helpful for us.
>>
>>
>> On Wed, Feb 1, 2012 at 8:22 PM, TANYA <[email protected]> wrote:
>>
>>> yes, the path is already there. Maybe the problem is either in views.py
>>> or url.py file if changed it gives different error, but i dont know what to
>>> look for in those two files.
>>>
>>>
>>> On Wed, Feb 1, 2012 at 2:40 PM, yati sagade <[email protected]>wrote:
>>>
>>>> in settings.py, in the TEMPLATE_DIRS setting, add the absolute path to
>>>> your templates directory - something like "/path/to/project/dir/template".
>>>> This MUST be an absolute path. And if your modifying this setting for the
>>>> first time, be sure to leave a comma (,) in the end of that path (Sorry if
>>>> you knew that already :))
>>>>
>>>>
>>>> On Wed, Feb 1, 2012 at 7:59 PM, TANYA <[email protected]> wrote:
>>>>
>>>>> the installed apps has 'mysite.books', in the path and the html
>>>>> files are in a directory under mysite project directory. Is that correct?
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Feb 1, 2012 at 12:06 PM, Ankit Rai <[email protected]>wrote:
>>>>>
>>>>>> Please check your template path in settings.py.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Feb 1, 2012 at 5:29 PM, TANYA <[email protected]> wrote:
>>>>>>
>>>>>>> In views.py, when I add this code gives template error.
>>>>>>>
>>>>>>> def search(request):
>>>>>>> error = False
>>>>>>> if 'q' in request.GET:
>>>>>>> q = request.GET['q']
>>>>>>> if not q:
>>>>>>> error = True
>>>>>>> else:
>>>>>>> books = Book.objects.filter(title__icontains=q)
>>>>>>> return render_to_response('search_results.html',
>>>>>>> {'books': books, 'query': q})
>>>>>>> return render_to_response('search_form.html',
>>>>>>> {'error': error})
>>>>>>>
>>>>>>> I have created search_form.html and search.html and put it in
>>>>>>> "template" directory but get this error ,
>>>>>>>
>>>>>>> TemplateDoesNotExist at /search/
>>>>>>>
>>>>>>> search_form.html
>>>>>>>
>>>>>>> Request Method: GET Request URL: http://127.0.0.1:8000/search/ Django
>>>>>>> Version: 1.3.1 Exception Type: TemplateDoesNotExist Exception
>>>>>>> Value:
>>>>>>>
>>>>>>> search_form.html
>>>>>>>
>>>>>>> Exception Location:
>>>>>>> /usr/local/lib/python2.6/dist-packages/django/template/loader.py
>>>>>>> in find_template, line 138 Python Executable: /usr/bin/python
>>>>>>> --
>>>>>>> TANYA
>>>>>>>
>>>>>>> --
>>>>>>> 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.
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> *Ankit Rai*
>>>>>>
>>>>>> *
>>>>>> *
>>>>>>
>>>>>> --
>>>>>> 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.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> TANYA
>>>>>
>>>>> --
>>>>> 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.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Yati Sagade <http://twitter.com/yati_itay>
>>>>
>>>> (@yati_itay <http://twitter.com/yati_itay>)
>>>>
>>>>
>>>> --
>>>> 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.
>>>>
>>>
>>>
>>>
>>> --
>>> TANYA
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> Yati Sagade <http://twitter.com/yati_itay>
>>
>> (@yati_itay <http://twitter.com/yati_itay>)
>>
>>
>> --
>> 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.
>>
>
> I don't think you have your settings set properly
>
> Copy and post this part of your settings file:
>
> TEMPLATE_DIRS = (
> # Put strings here, like "/home/html/django_templates" or
> "C:/www/django/templates".
> # Always use forward slashes, even on Windows.
> # Don't forget to use absolute paths, not relative paths.
> os.path.join(PROJECT_PATH, 'templates'),
> )
>
> This message looks suspicious:
>
> TemplateDoesNotExist at /search/
>
> search_form.html
>
>
> It looks like you might have something like "/home/search" in your
> settings file. If your templates are in /home/search/templates then you
> need to have a settings file like that
> --
> Joel Goldstick
>
>
> --
> 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.
>
--
TANYA
--
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.