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 Basics What a View! What Are URLs?

Code does not work!

Typed everything in exactly in urls.py, and got the error: ImportError: cannot import name 'views'.

NO, this is NOT an indentation issue.

Can you please post your code? Remember to wrap your code with 3 backticks (```) on the line before and after the code snippet.

Example:

```

print("Hello")

```

And make sure to add python after the first set of ticks

'' 'python

Jeff Muday
Jeff Muday
Treehouse Moderator 28,720 Points

Not all the files you need for that step are generated automatically.

Did you create a 'views.py' file in the learning_site project folder? Note, the file "views.py" is not automatically created in the project folder when you run the command below

$ django-admin startproject learning_site

Kenneth adds the 'views.py' file in the previous video called "Hello Django" at about 1:00 minute into the video.

When you do a "startapp" command, the view.py is automatically generated in the app folder. In my opinion, why they did projects and apps differently is to suggest a design approach which promotes "DRY" (don't repeat yourself) and reusability for apps.

Actually, it isn't required to put the "python" thing in front of the first set of ticks.

If you don't provide it it will look like this:

print("Hello")

However, if you do, it will look like this:

print("Hello")

To keep things simple I just explained the one without the "python" thing.

2 Answers

Erika Suzuki
Erika Suzuki
20,299 Points

Please attach your code.

Try:

          from django.http import HttpResponse