Browse files

13 - In App URLs

  • Loading branch information...
codingforentrepreneurs committed Dec 15, 2015
1 parent f60287d commit 3518441f53779a5f0c1e3bae006b025b8320c791
Showing with 29 additions and 4 deletions.
  1. +13 −0 src/posts/
  2. +14 −2 src/posts/
  3. +2 −2 src/trydjango19/
@@ -0,0 +1,13 @@
from django.conf.urls import url
from django.contrib import admin
from . import views
urlpatterns = [
url(r'^$', "posts.views.post_list"),
url(r'^create/$', "posts.views.post_create"),
url(r'^detail/$', "posts.views.post_detail"),
url(r'^update/$', "posts.views.post_update"),
url(r'^delete/$', "posts.views.post_delete"),
#url(r'^posts/$', "<appname>.views.<function_name>"),
@@ -4,5 +4,17 @@
# Create your views here.
def post_home(request):
return HttpResponse("<h1>Hello</h1>")
def post_create(request):
return HttpResponse("<h1>Create</h1>")
def post_detail(request): #retrieve
return HttpResponse("<h1>Detail</h1>")
def post_list(request): #list items
return HttpResponse("<h1>List</h1>")
def post_update(request):
return HttpResponse("<h1>Update</h1>")
def post_delete(request):
return HttpResponse("<h1>Delete</h1>")
@@ -14,11 +14,11 @@
2. Import the include() function: from django.conf.urls import url, include
3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
from django.conf.urls import url
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^posts/$', "posts.views.post_home"),
url(r'^posts/', include("posts.urls")),
#url(r'^posts/$', "<appname>.views.<function_name>"),

2 comments on commit 3518441


This comment has been minimized.

anumanwer replied Oct 23, 2016

Hi there, could you please help me? I am trying to make this code work but it is giving me a Type Error.

I am using Django 1.10 and after trying a variety of different ways to fix it, I am still stuck. Should I post my code here? How can I work around it?

Thanks in advance for your support!



This comment has been minimized.


codingforentrepreneurs replied Oct 24, 2016

Stick with the version of Django that's in our training videos otherwise this code will not make sense: look for Try Django 1.9. This repository is made as reference code for that video's series.

Good luck!

Please sign in to comment.