I installed django_facebook (django-facebook==6.0.3). I am using Django 1.11.
I got an error:
File "path/lib/python3.5/site-packages/django_facebook/urls.py", line 4, in <module>
from django.conf.urls.defaults import patterns, url
ImportError: No module named 'django.conf.urls.defaults'
I was tring solved this problem with:
try:
from django.conf.urls import include, url
except ImportError:
from django.conf.urls.defaults import include, url
but without success.
Please for hint.
django.conf.urls.defaults was removed in Django 1.6, which was many years ago, and the django-facebook package you're using has the following message in its README (which was committed two years ago):
Django and Facebook are both rapidly changing at the moment. Meanwhile, I'm caught up in a startup and don't have much spare time. The library needs a good round of testing against the latest python, django and facebook graph API.
Unless you're willing to dive deep into the package's code, I'd recommend looking for another solution. It sounds like the author is looking for someone to help maintain it. Good luck!
Related
** New user to SOF, sorry for poor post and thank you in advance for any help**
As the title says. I have been through multiple threads of StackOverflow with similar questions and none of them have given me a working solution.
My directories
The problem doesn't start until I add line18 into urls.py
and the error:
"ModuleNotFoundError: No module named django_project.users" is displayed.
I have tried different variations of importing the module and all seem to fail.
Traceback
I was following this tutorial:
https://www.youtube.com/watch?v=q4jPR-M0TAQ&t=753s
it wasn't until 14:00 where I was getting errors the author of the video was not. I have been following his tutorial from the beginning and have not run into any errors until now. I have been trying to find a solution for about 4 days now. Any help would be greatly appreciated.
I have pushed the most recent code to github and made the repository temporarily public for anyone who wants to replicate this problem:
https://github.com/ChristopherMillones/PyTest
EDIT: settings.py -> INSTALLED_APPS
django_project is your project root directory.
The apps inside are django_project, blog and users.
If you added those to your settings.py you have to import "stuff" from it like
from users.models import MyModel
In your project itself (django_project/django_project/*) you don't have a module users, that's why the error is thrown.
Versions:
Python 3.5.1
Django 1.10
django-rosetta 0.7.13
The installation guide tells you to add the following to your project's settings.py:
from django.conf import settings
if 'rosetta' in settings.INSTALLED_APPS:
urlpatterns += patterns('',
url(r'^rosetta/', include('rosetta.urls')),
)
However, this just results in an error:
NameError: name 'patterns' is not defined
Searching for that problem reveals that one apparently has to import it:
from django.conf.urls import patterns
But still it doesn't work.
ImportError: cannot import name 'patterns'
This function was removed in django 1.10. However, one can add the rosetta urls conditionally using this approach:
from django.conf import settings
if 'rosetta' in settings.INSTALLED_APPS:
urlpatterns.append(url(r'^rosetta/', include('rosetta.urls')))
However, if you try to access rosetta at the url http://127.0.0.1:8000/rosetta/ you might be surprised to find that you still get a 404 Page not found.
So it seems that the included patterns are not working properly. But they are. The problem is that there's a hidden requirement that one must be logged in when accessing the rosetta page (maybe with a staff/super user?). So, simply go to http://127.0.0.1:8000/admin/, log in, and then go to the rosetta url again. Now it should work.
The installation does note this, sort of:
Because Rosetta requires write access to some of the files in your
Django project, access to the application is restricted to the
administrator user only (as defined in your project’s Admin interface)
How does it know you are an administrator if you are not logged in? It doesn't, and apparently instead of giving an informative error, it ignores the rosetta urls entirely.
when i try to import reverse in my models.py file with the following line: from django.core.urlresolvers import reverse i'm getting this error :ImportError: No module named 'django.core.urlresolvers.I'm learning django from youtube ,and here is the url of the video that i'm watching : https://www.youtube.com/watch?v=eouZwgKuA5k.How can i fix it?
This case, you imported reverse as follows:
from django.core.urlresolvers import reverse
Upgrade your Django version, use the following command
pip install --upgrade django
and then try again.
From Django 1.10+, the import has changed to:
from django.urls import reverse
However, the old import should still work in Django 1.10 and 1.11.
If the old import is giving you an error, that suggests that either your Django install is broken, or you have installed the master branch of Django (which will become 2.0). I would avoid using the master branch.
If possible, use the same Django version that the tutorial was written for, otherwise you might hit more problems like this. If the tutorial was written for Django < 1.8 then I would avoid it, as it is out of date.
I am using Django and Django Suit V2 -
I am trying to create a custom home page for my django site using templates.
I keep getting this error: File "/usr/local/lib/python2.7/dist-packages/suit/apps.py", line 89, in add_suit_default_template_tags from django.template.engine import Engine
ImportError: No module named Engine
I want to make sure of what I'm doing before I go in and mess with the main files.
Anyone else deal with "No module named Engine" error before? Any Suggestions?
UPDATE - ok I corrected the first issue - I made sure the python interpreter was pointing to the virtualenv (it was already activated, so I deactivated and then reactivated). Was able to do a collectstatic with no error. I have now generated a different error which I will post in a different question since it's not directly related here. :)
It sounds like you have an old version of Django installed. The import
from django.template.engine import Engine
should work in Django 1.8+.
I am trying to follow through the Python Django Tutorial from the official site.
However I find it hard to follow. I did everything as written but I got the following error"
ERROR screen caption
It sounds like something is wrong with the ENV, but I am not so sure why.
Also at the last line of error it said "include is not defined"...
You are missing the line from django.conf.urls import include, url.