I have a project with a few apps, one of them is called blog. I'm trying to render a page for each single blogpost.
models.py (MyProject/Blog/Models)
class Blog(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
author = models.ForeignKey(User, max_length=40, blank=False)
title = models.CharField(max_length=40, blank=False)
views.py (MyProject/Blog/Views)
def get_blog(request, blog_id):
print "THIS STRING IS A TEST"
blogpost = Blog.objects.get(pk=blog_id)
context = {'blogpost': blogpost}
return render(request, 'blog_page.html', context)
urls.py (MyProject/Urls)
urlpatterns = [
url(r'^$', 'app_1.views.home', name='home'),
url(r'^blog/(?P<blog_id>\d+)/$','blog.views.get_blog'),
]
One of my blogposts has the following uuid: 98bfad8b-c44c-41d0-98d0-158379c3e362
Yet when I go to "example.com/BLOG/98bfad8b-c44c-41d0-98d0-158379c3e362", nothing happens.
It also doesn't print out 'THIS STRING IS A TEST', which tells me the view doesn't even get called.
It's my first time dealing with non-static URLS. What am I missing here?
Thanks in advance.