Wednesday, July 5, 2017

Re: Noobie question, can't get url request to work, 404

to be honest I haven't used Django in a while so take what I'm saying as wrong - but shouldn't the url be

url(r'hello/$', views.hello, name='hello'),

Not sure you need "^" although I doubt it hurts.

Johnf


On 07/05/2017 02:23 PM, ahickman3@tamu.edu wrote:
So I literally just started django, I know 0 about backend dev, but im going through the djangobook tutorial (also, please excuse me if I use the wrong syntax). He shows us how to get content to show up on our temporary domain (a simple Hello World).

The hello world setup looks like so, with the file named views.py, located in the same directory as urls.py

from django.http import HttpResponse    def hello(request):      return HttpResponse("Hello world")

And the urls.py file looks like this

from django.conf.urls import url  from django.contrib import admin    from mysite.views import hello    urlpatterns = [      url(r'^admin/', admin.site.urls),      url(r'^hello/$', hello),  ]  

I feel like somethings wrong with the path, or something like that? I'm kinda of clueless at this point though, I've been working on it for a while. I don't even know how to go about de-bugging, since this is vastly different from coding a simple "get all the odd numbers from a list" problem.

Thanks

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7c751df1-c209-455c-bf83-f5fa2ddf3d8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment