Reputation: 1
I'm attempting to use Django to create a website builder. I have created a development webserver with "python manage.py runserver" and it worked initially. I created a Products app and added code in the views module and the url module under this app, whilst also mapping it to the parent url module using "path('products/', include('products.urls'))" but when I go back to the link produced by the server, it no longer works. I don't know what the problem is and how to fix it, as I didn't do anything different from the first time I tried this, and it worked briefly, before it stopped. I had to start a new project when this happened but I don't have time to keep starting over.
This worked a few days ago but the next day the runserver command wasn't working. I had to delete the project and start again and now I am running into the same problem and I don't know what to do
Upvotes: 0
Views: 98
Reputation: 11
Are there any errors in the terminal or traceback information ? Did you check the port availability? Usually the port 8000 is the default check if it's available because there might be another app running causing conflicts.
For the app when using the include function, I usually include an empty string '' whenever I want to map the URLs directly to the included app. For example in your urls.py file:
path('', include('products.urls')),
Other things to check Make sure you registered the app in the settings.py: INSTALLED_APPS. Make sure the "include" is imported in the main urls.py file. Hope any of this helps! Wish you all the best!
Upvotes: 1