Issue
I'm trying to use include in my app following the tutorial here - https://www.w3schools.com/django/django_views.php
it seems that when I run the server using this configuration-
urlpatterns = [path('members/', include('mimi.urls')), path('admin/', admin.site.urls),]
I get ModuleNotFoundError: No module named 'mimi'.
I've attached a screenshot of my Pycharm project folder as it is now.
I don't understand what I'm doing wrong. It seems to fail to recognize anything outside the web_questions folder, but I can't find a way to give it the absolute path. I'm running the server using this command line -
py web_questions/manage.py runserver
Solution
So like people have said here before ,the app directory should be under the project directory! The way to do it easily, and without transferring manually the folders, is to run this line of code-
django-admin startproject <project_name>
cd .\<project_name>
python .\manage.py startapp <app_name>
The second line is what made all the difference for me, and I didn't see it in the tutorial. This way everything is created in the correct hierarchy.
Answered By - KarinP
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.