Re: Templates not found

52 views
Skip to first unread message

Sithembewena Lloyd Dube

unread,
Dec 10, 2012, 9:46:40 PM12/10/12
to django...@googlegroups.com
By the way, the specific exception text and trace are:

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  101.                             request.path_info)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
  300.                     sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
  300.                     sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
  209.             return ResolverMatch(self.callback, args, kwargs, self.name)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in callback
  216.         self._callback = get_callable(self._callback_str)
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" in wrapper
  27.         result = func(*args)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in get_callable
  108.                     (lookup_view, mod_name))

Exception Type: ViewDoesNotExist at /
Exception Value: Could not import myproject.views.home. Parent module myproject.views does not exist.





On Tue, Dec 11, 2012 at 4:36 AM, Sithembewena Lloyd Dube <zeb...@gmail.com> wrote:
Hi all,

I have a Django project running Django 1.4.1. (just upgraded). My TEMPLATE_DIRS entry is:

'/home/mymachine/Code/myproject/templates/myapp',

and that is exactly where the index template of the new project is even when i use Firefox to locate it.

In my home view, I call render_to_response as follows:

'def home(request):
    return render_to_response('tracks/index.html', {})',


This raises an exception of type ViewDoesNotExist. If I run python manage.py shell, import the view and call it with None as an argument for request, it shows that a response object is returned. Yet, the browser will not render it.

>>> from tracks.views import home as h
>>> h(None)
<django.http.HttpResponse object at 0x95fdeac>
>>> dir(h(None))
['__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__getstate__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_base_content_is_iter', '_charset', '_container', '_convert_to_ascii', '_get_content', '_headers', '_set_content', 'close', 'content', 'cookies', 'delete_cookie', 'flush', 'get', 'has_header', 'items', 'next', 'set_cookie', 'set_signed_cookie', 'status_code', 'tell', 'write']

Am I missing something?

Thanks.

--
Regards,
Sithu Lloyd Dube



--
Regards,
Sithu Lloyd Dube

Sithembewena Lloyd Dube

unread,
Dec 10, 2012, 10:04:34 PM12/10/12
to django...@googlegroups.com
On Tue, Dec 11, 2012 at 4:36 AM, Sithembewena Lloyd Dube <zeb...@gmail.com> wrote:
Hi all,

I have a Django project running Django 1.4.1. (just upgraded). My TEMPLATE_DIRS entry is:

'/home/mymachine/Code/myproject/templates',


and that is exactly where the index template of the new project is even when i use Firefox to locate it.

In my home view, I call render_to_response as follows:

'def home(request):
    return render_to_response('myapp/index.html', {})',


This raises an exception of type ViewDoesNotExist. If I run python manage.py shell, import the view and call it with None as an argument for request, it shows that a response object is returned. Yet, the browser will not render it.

>>> from tracks.views import home as h
>>> h(None)
<django.http.HttpResponse object at 0x95fdeac>
>>> dir(h(None))
['__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__getstate__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_base_content_is_iter', '_charset', '_container', '_convert_to_ascii', '_get_content', '_headers', '_set_content', 'close', 'content', 'cookies', 'delete_cookie', 'flush', 'get', 'has_header', 'items', 'next', 'set_cookie', 'set_signed_cookie', 'status_code', 'tell', 'write']

Am I missing something?

Thanks.

--
Regards,
Sithu Lloyd Dube

Sergiy Khohlov

unread,
Dec 11, 2012, 6:31:45 AM12/11/12
to django...@googlegroups.com
take a look you have error related to myproject.view.home but
importing track.view.home ....

2012/12/11 Sithembewena Lloyd Dube <zeb...@gmail.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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

Sithembewena Lloyd Dube

unread,
Dec 11, 2012, 7:44:47 AM12/11/12
to django...@googlegroups.com
Hi Segiy,

Thanks for the response. "myproject" is only an alias I used while posting the code on here, in the project code it is actually "tracks".

Sithembewena Lloyd Dube

unread,
Dec 10, 2012, 9:36:56 PM12/10/12
to django...@googlegroups.com
Hi all,

I have a Django project running Django 1.4.1. (just upgraded). My TEMPLATE_DIRS entry is:

'/home/mymachine/Code/myproject/templates',

and that is exactly where the index template of the new project is even when i use Firefox to locate it.

In my home view, I call render_to_response as follows:

'def home(request):
    return render_to_response('tracks/index.html', {})',

Sergiy Khohlov

unread,
Dec 11, 2012, 10:53:52 AM12/11/12
to django...@googlegroups.com
please paste your urls.py

Sithembewena Lloyd Dube

unread,
Dec 12, 2012, 9:11:54 AM12/12/12
to django...@googlegroups.com
urls.py:

urlpatterns = patterns('',
    # Examples:
    url(r'^$', 'musicsite.views.home', name='home'),
    # url(r'^musicsite/', include('musicsite.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
)

I even considered indentation problems, but I have checked that and it is fine.

Sergiy Khohlov

unread,
Dec 12, 2012, 9:51:14 AM12/12/12
to django...@googlegroups.com
could you please repeat your not view error ?
Look like urls,oy has no access to views.py

Many thanks,
Serge


+380 636150445
skype: skhohlov


2012/12/12 Sithembewena Lloyd Dube <zeb...@gmail.com>:

donarb

unread,
Dec 12, 2012, 11:38:03 AM12/12/12
to django...@googlegroups.com
When you used the shell, you imported 'tracks.views' but in your urls.py, you have musicsite.views.home. The two don't match.

Sithembewena Lloyd Dube

unread,
Dec 18, 2012, 6:06:39 PM12/18/12
to django...@googlegroups.com
Thank you Sergiy and @donarb - my urls.py file was wrng as described by @donarb.

To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/GvUfAf_KOFQJ.

To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Reply all
Reply to author
Forward
0 new messages