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:
*I'm using PyCharm
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!")
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.
PyCharm supports the latest Django versions. The corresponding Python versions depend on Django.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With