trying to load a view

1,099 views
Skip to first unread message

dk

unread,
Sep 21, 2014, 9:57:01 PM9/21/14
to django...@googlegroups.com
my application named polls
in polls/views.py
i have:

from django.http import HttpResponse
import datetime

def hello(request):
    now = datetime.datetime.now()
    html = "<html><body>It is now %s.</body></html>" % now
    return HttpResponse(html)


my project call restaurants
restaurants/urls.py:

from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
import polls.views
urlpatterns = patterns('',
    url(r'^hello/$', include(polls.views.hello)),
    url(r'^admin/', include(admin.site.urls)),
)

and i get this error.
Request URL:http://127.0.0.1:8000/hello/
Django Version:1.7
Exception Type:ImproperlyConfigured
Exception Value:
The included urlconf '<function hello at 0x031DDB70>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

all the tutorials and webpages mention this tutorials, saying that should work, any ideas what might be?

thanks.

James Schneider

unread,
Sep 21, 2014, 10:22:30 PM9/21/14
to django...@googlegroups.com
Please post your urls.conf files. Based on the error they are probably empty, or you are doing something funny with imports.

-James
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/205e4901-a436-4260-8d08-aff06cd3ca3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dk

unread,
Sep 21, 2014, 10:35:55 PM9/21/14
to django...@googlegroups.com
here is my project in a rar.

dont know if might be something with django 1.7

thanks =) 
restaurants.rar

Collin Anderson

unread,
Sep 22, 2014, 11:55:34 AM9/22/14
to django...@googlegroups.com
    url(r'^hello/$', include(polls.views.hello)),
should be:
    url(r'^hello/$', polls.views.hello),


dk

unread,
Sep 25, 2014, 12:59:23 AM9/25/14
to django...@googlegroups.com
thanks  now when i go to the website
 http://127.0.0.1:8000/hello/  does work,     so the include work for including the urls file inside the applications?

and if i go to
i get the 404 error

Page not found (404)

Request Method:GET
Request URL:http://127.0.0.1:8000/

Using the URLconf defined in restaurants.urls, Django tried these URL patterns, in this order:

  1. ^admin/
  2. ^hello/$

The current URL, , didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.


is that how suppouse to be? or should i be getting the message that django gives at the beggining? 

It worked!

Congratulations on your first Django-powered page


thanks for the help.  =)

Collin Anderson

unread,
Sep 25, 2014, 4:31:49 PM9/25/14
to django...@googlegroups.com
Nothing is defined for url(r'^$'), so you should be getting that error. This should work though: http://127.0.0.1:8000/hello/
Reply all
Reply to author
Forward
0 new messages