2👍
you should also take a look at the tutorial included in django docs for the parts that may not be covered in the one you found.
you may need to modify settings.py
and add the blog
app to INSTALLED_APPS
to solve the ImportError
. This is covered in the activating models section of the tutorial.
EDIT: here is what seems to be needed to solve the ImportError
you had.
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog', # <------ your app here.
...
}
3👍
I had the very same problem while working through this tutorial from tutsplus. Like user61629 said, you need to change the url pattern to ‘blog.views.home’ instead of ‘FirstBlog.blog.views.home’ and it works perfectly.
- [Django]-Site name appearing in django URLs
- [Django]-How to tell Django model that only one or other field must be not empty?
- [Django]-Django models ForeignKey return IDs
- [Django]-Unrequired field error w/ Django REST Framework
1👍
Forgetting comas after each INSTALLED_APPS could also cause a similar error. For example:
INSTALLED_APPS = (
'django.contrib.auth' <----------- No Comma!
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
(May help a beginner like me out there)
- [Django]-Django on Aptana Studio 3.0
- [Django]-How can I centralize URLs in Django templates?
- [Django]-How to include "None" in lte/gte comparisons?
- [Django]-Django invite friends from social account
- [Django]-Django Cache: Use Memcached and fallback to FileSystem
0👍
Sounds like a simple import error. Could be due to either you having not installed the app ‘blog’ check your settings.py it is installed?
The other issue could be simply an incorrect import path for example
from blog.models import Blog
Either way it sounds like you should continue reading the docs. I found these video very helpful
http://hackedexistence.com/project-django.html
Also on another note from your code above don’t include full paths like this…
TEMPLATE_DIRS = (
"F:/firstblog/blog/templates",
It can give you a lot of issues later on.
0👍
It is also a good practice not to use absolute paths like F:/firstblog/blog/templates
in your project as if you deploy on the server or other people also develop this project they have to change these paths.
Try using unipath
for this or just os
module to set paths.
- [Django]-TemplateDoesNotExist in project folder django 1.8
- [Django]-How to create a custom 404 page for my Django/Apache?
- [Django]-Authenticating Android with firebase Authentication and send token to verify to backend Django
0👍
This error might because you rename your Django project after creation. So you have to undo and go back to the name you use to create the Django project or trace the error and update it with the new Django name.
- [Django]-Django Import Issue
- [Django]-InlineModelAdmin not showing up on admin page
- [Django]-How to troubleshoot – ImportError: Could not import settings 'mysite.settings' when deploying django?
- [Django]-Use values() in Django query to get Model instead of ID
0👍
I was faced with the same error because I created app outside of the project. Check whether your app is in its right directory or not.