Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Django tutorial) importing 'views' from 'polls' app - syntax error PyCharm

Is it incorrect to use:

from [app name] import views

when you're inside that app?

I'm following the tutorial from the Django documentation website; and everything is working; however, I'm getting a syntax error (it still works though) every time I do the following:

enter image description here

*I'm using PyCharm

like image 367
Roronoa Zoro Avatar asked Jun 09 '13 17:06

Roronoa Zoro


People also ask

How will you import views in Django?

from django.shortcuts import render # Create your views here. Find it and open it, and replace the content with this: members/views.py : from django.shortcuts import render from django.http import HttpResponse def index(request): return HttpResponse("Hello world!")

Why Django is not working in PyCharm?

You have to go to the Pycharm Setting > Project: > Project Structure ; Then mark your project directory as "Sources" (just click on the django project folder and this click on your "Sources at the top"). Finally, restart Pycharm. Save this answer.

Does Django work with PyCharm?

PyCharm supports the latest Django versions. The corresponding Python versions depend on Django.


1 Answers

If you right click the mysite.com/mysite folder and select Mark Directory As -> Source Root you should be able to do from polls import views

like image 189
Ngenator Avatar answered Oct 23 '22 02:10

Ngenator