You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I just want to thank you very much for all your hard work into djangocentral. I am new at pythin/django (well everything really, lol) and found your tutorial somehow and it's been like SOOO helpful getting up and started quickly, but everything was going like super smooth until this point, and seems I am dealing with a common issue. (Have found many people complaining of the same issue while doing a simple google search - yet after combing through and trying many ideas and solutions I still can't seem to figure out what is going wrong or how to fix it) And I'd really like to finish your tutorials. I had actually planned on going through the list of tutorial links you have posted here one by one, they are so great!!
I found this odd page at django detailing the issue briefly but not really listing a fix. I figured I'd reach out and if django isn't posting a fix for this on their website, I figured maybe if you knew you could post one on yours at least (and grab all that traffic 🤑 anyway loll!!)...and it would help me out in the process!! 😁 btw, I just followed you on Kofi and plan on buying you a coffee as soon as I get my next check (around the 3rd...).
Ok, well, thanks for your help in advance..🙏
Here's the link to the issue and the odd answer given from django:
We are done with the Models and Views now we need to make templates to render the result to our users. To use Django templates we need to configure the template setting first.
Create directory templates in the base directory. Now open the project's settings.py file and just below BASE_DIR add the route to the template directory as follows.
Now save and close the file we are done with the configurations.
I followed all these instructions and keep getting:
NameError: name 'os' is not defined error.
When I add an import for os at the top of the settings file, I get: django.core.exceptions.ImproperlyConfigured: The TEMPLATE_DIRS setting must be a list or a tuple. error, so I keep going round and round forever cause every time I fix one thing it seems to cause another to the point that I figured it's better I just ask...this is driving me crazy lol...idk if I did something wrong somewhere, I'm just too new to know if it's cause of something I did or it actually is an error somewhere in the tutorial, like maybe something was forgotten or even changed since seems there have been a lot of breaking changes to django in the recent past. I just hate to put this as an issue if I'm just making some noob mistake, so I hope you forgive me cause I'm so at a loss!!
Ok well this has been long enough.Thank you in advance...
The text was updated successfully, but these errors were encountered:
So, turns out the tutorial on djangocentral shows it written as, TEMPLATE_DIRS instead of TEMPLATES_DIR,which is what it's actually supposed to be(!!) but once I fixed that it unfortunately still didn't work, BUT..., once I made these other simple changes to my settings.py file it finally worked!!
It's a really good thing the source code was available, I totally forgot that was accessible to me since I had started the tutorial completely from scratch - with NO Cheating LOL!! So, once I took a look it was very clear.
It may be worth mentioning here, that whatever files django creates during the startapp command, it includes all the text I had to replace below. For that reason I felt that you might still want to update djangocentral's website with the most current information, which is why I decided, as simple a fix as this ended up being (which was only possible because the source code was correct and available afterall!!) to continue and post the fix here, instead of just deleting it all...so maybe I can be of some help afterall! ;) WOOT WOOT!
So anyways - Here's the fix!!
Remove: from pathlib import Path,
Replace it with: import os
Remove:
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Replace it with:
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Hello, I just want to thank you very much for all your hard work into djangocentral. I am new at pythin/django (well everything really, lol) and found your tutorial somehow and it's been like SOOO helpful getting up and started quickly, but everything was going like super smooth until this point, and seems I am dealing with a common issue. (Have found many people complaining of the same issue while doing a simple google search - yet after combing through and trying many ideas and solutions I still can't seem to figure out what is going wrong or how to fix it) And I'd really like to finish your tutorials. I had actually planned on going through the list of tutorial links you have posted here one by one, they are so great!!
I found this odd page at django detailing the issue briefly but not really listing a fix. I figured I'd reach out and if django isn't posting a fix for this on their website, I figured maybe if you knew you could post one on yours at least (and grab all that traffic 🤑 anyway loll!!)...and it would help me out in the process!! 😁 btw, I just followed you on Kofi and plan on buying you a coffee as soon as I get my next check (around the 3rd...).
Ok, well, thanks for your help in advance..🙏
Here's the link to the issue and the odd answer given from django:
https://code.djangoproject.com/ticket/20400
I am using python 3.9 with django 4.0.6
👉 I am on your tutorial page:
https://djangocentral.com/building-a-blog-application-with-django/
👉 And Stuck here:
Creating Templates For The Views
We are done with the Models and Views now we need to make templates to render the result to our users. To use Django templates we need to configure the template setting first.
Create directory templates in the base directory. Now open the project's settings.py file and just below BASE_DIR add the route to the template directory as follows.
TEMPLATES_DIRS = os.path.join(BASE_DIR,'templates')
Now add the newly created TEMPLATE_DIRS in the DIRS.
Now save and close the file we are done with the configurations.
I followed all these instructions and keep getting:
NameError: name 'os' is not defined
error.When I add an import for
os
at the top of the settings file, I get:django.core.exceptions.ImproperlyConfigured: The TEMPLATE_DIRS setting must be a list or a tuple.
error, so I keep going round and round forever cause every time I fix one thing it seems to cause another to the point that I figured it's better I just ask...this is driving me crazy lol...idk if I did something wrong somewhere, I'm just too new to know if it's cause of something I did or it actually is an error somewhere in the tutorial, like maybe something was forgotten or even changed since seems there have been a lot of breaking changes to django in the recent past. I just hate to put this as an issue if I'm just making some noob mistake, so I hope you forgive me cause I'm so at a loss!!Ok well this has been long enough.Thank you in advance...
The text was updated successfully, but these errors were encountered: