How can I find script’s directory? [duplicate]
You need to call os.path.realpath on __file__, so that when __file__ is a filename without the path you still get the dir path: import os print(os.path.dirname(os.path.realpath(__file__)))
You need to call os.path.realpath on __file__, so that when __file__ is a filename without the path you still get the dir path: import os print(os.path.dirname(os.path.realpath(__file__)))
If you still need to server static locally (e.g. for testing without debug) you can run devserver in insecure mode: manage.py runserver –insecure
Seems like you didn’t define DJANGO_SETTINGS_MODULE which results in undefined settings. INSTALLED_APPS at this point is the first setting that Django wants to look up, resulting in the given error. With a default project creation the created manage.py defines said environment variable and if you run python manage.py runserver the settings are defined. Also see … Read more
You missed to create the view/ or forget to import views on you url py file. Cross check once again
Remove the else def post_new(request): if request.method == “POST”: form = PostForm(request.POST or None) if form.is_valid(): ct = form.save(commit=False) ct.author = request.user ct.upload_time = request.upload_time ct.save() return redirect(‘iot:detail’, pk=ct.pk) form = PostForm() return render(request, ‘iot/post.html’, {“form”:form})