Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Class-based Views Classy Views Basic View

Nthulane Makgato
PLUS
Nthulane Makgato
Courses Plus Student 19,602 Points

Class Based Views URL

Struggling to find the last part of this question. I know that the answer is easy but I still haven't gotten it right. Please help.

The bigger problem though is that i've recently been struggling to find help on the "Treehouse Community" as in I can't find similar questions and learn from them. I'm convinced that I would have solved this much quicker than have to wait for a response. I usually copy and paste part of the task or the task name("Basic Views") but recently there haven't been many similar questions. Are people just coasting through these tasks, am I using it wrong, has the search algorithm changed or what?

Please help on one or both.

myproject/urls.py
from django.conf.urls import url, include

from . import views

urlpatterns = [
    url('/', views.WelcomeView.as_view(), name='/')
]
myproject/views.py
from django.views.generic import View
from django.http import HttpResponse

class WelcomeView(View):
    def get(self, request):
        return HttpResponse("Hello")

1 Answer

Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

You're very close! The problem is in the url. He is asking you to make the path "/" which would be something like this:

from django.conf.urls import url, include

from . import views

urlpatterns = [
    url(r'^$', views.WelcomeView.as_view())  # name="" is not required in this task
]

I remember it being really hard to find solutions about django when I went through the course. I prefer searching through the django-docs since it's somewhat easy to find what you're looking for + the django-docs are just amazing imho! :-D

https://docs.djangoproject.com/en/1.11/ (this is for django v. 1.11 - just change the version number to the version you're using)

Keep on coding! :-D