Reputation: 23
import jobs.views
urlpatterns = [
path('admin/', admin.site.urls),
path('nick', jobs.views.nick, name='nick'),
]
enter code here
def nick(request):
return render(request, 'jobs/nick.html')
I got: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/nick/
Using the URLconf defined in FadhelPro.urls, Django tried these URL patterns, in this order:
admin/ nick/ [name='nick'] The empty path didn't match any of these.
Upvotes: 0
Views: 125
Reputation: 116
If python -V is 3.x or above then:
urlpatterns = [
path('admin/', admin.site.urls),
path('nick/', jobs.views.nick, name='nick'),
]
def nick(request):
return render(request, 'jobs/nick.html')
If python -V is 2.x or above then:
urlpatterns = [
path(r'^admin/', admin.site.urls),
path(r'^nick/', jobs.views.nick, name='nick'),
]
def nick(request):
return render(request, 'jobs/nick.html')
Html templates could not be rendered without an app but you can write the code of the html in a http response!
If you create an app instead that will be more hacky and good.If this doesn't work then you go for an app and Get some tutorials of django before you mess up!!
Upvotes: 0
Reputation: 49
Instead of:
path('nick', jobs.views.nick, name='nick')
Try:
path(r'^nick/', jobs.views.nick, name='nick'),
Upvotes: 0