Google App Engine import error, for django.urls - django

I'm trying to learn Django, so I completed their multi-part tutorial (Python 2.7) and ran it locally. I got it working fine on my PC.
I need the following import, in a views.py file:
from django.urls import reverse
When I upload it to GAE, it gives me the following error:
Exception Type: ImportError
Exception Value: No module named urls
Is this module unavailable for the GAE, or am I doing something wrong?
(By the way, I need this import so I can use the "reverse" method, after a user submission is received in the polls app, like: HttpResponseRedirect(reverse('polls:results', args=(question.id,))) )

reverse() was moved from django.core.urlresolvers to django.urls in Django 1.10. The error suggests that you are using an older version of Django.
You need to import reverse() from the old location:
from django.core.urlresolvers import reverse

Related

I just setup python django and Im unable to import

I just finished installing Python and Django. I followed everything in a tutorial video and I wrote the most simple code:
from django.shortcuts import render
from django.http import HttpResponse
def hello(request):
return HttpResponse("<h1>Hello world!</h1>")
I imported it to the URL and it works as expected but the problem is I get this error:Unable to import I don't know why it is saying this because it works well. what is wrong with the program?
And I have the same import problem on other files too.

ImportError : cannot import name AppCache

I have installed Django 1.8.3 Then i created my project. I need to import the AppCache but not able to import it. In Django shell i wrote
from django.db.models.loading import AppCache
Error is:
ImportError: cannot import name AppCache
Please help me out.
AppCache is not a part of django.db.models.loading from django 1.7 onwards.For more information you can read this link

django on jython(cannot import name BaseDatabaseWrapper)

I have a problem buliding django on jython
I have already installed django-jython , jython , django
in settings.py dababase engine I write : doj.db.backends.sqlite
raiseImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured:
'doj.db.backends.sqlite' isn't an
available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'base', u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: cannot import name BaseDatabaseWrapper
it seems that in doj.db there is no these classes which I can find in django.db
and I find in site-packages\django_jython-1.7.0b2-py2.7.egg\doj\db\backends\sqlite\base.py
there are :
from doj.db.backends import JDBCBaseDatabaseWrapper as BaseDatabaseWrapper
from doj.db.backends import JDBCBaseDatabaseFeatures as BaseDatabaseFeatures
from doj.db.backends import JDBCBaseDatabaseOperations as BaseDatabaseOperations
from doj.db.backends import JDBCCursorWrapper as CursorWrapper
from doj.db.backends import JDBCConnection
maybe the problem lies here
thanks for your help
I got the same problem. It's Django compatibility issue indeed. django-jython 1.7 works with Django 1.7.x (see https://pythonhosted.org/django-jython/release-notes.html#b2)

ViewDoesNotExist at / Could not import django.views.generic.simple.redirect_to. Parent module django.views.generic.simple does not exist

I am new to django framework. Please help me through this.
when i run python manage.py runserver, i am facing an error,
ViewDoesNotExist at /
Could not import django.views.generic.simple.redirect_to. Parent module django.views.generic.simple does not exist.
my project name is scrapboard, my app name is core.
I realise this question is two years old, but I also hit this while upgrading an old project. The url structure
url(r'^$', 'django.views.generic.simple.redirect_to', {'url': 'whatever' }),
Was removed and replaced with;
from django.views.generic import RedirectView
url(r'^$', RedirectView.as_view(url='/whatever'),permanent=True)
The error is clear. That module does not exist. That is because it was deprecated and removed two versions ago. You should follow the correct documentation for the version of Django you are using.

Dojango with django 1.5

I'm a django noob. I just added dojango 0.5.5 in project apps. I use Django 1.5 and when i try to vie the test page dojango offers at mysite/dojango/test/ i got this error:
__init__() got an unexpected keyword argument 'namedtuple_as_object'
the error is in the dojango base template file where there is:
'isDebug':{{ DOJANGO.DEBUG|json }},
Has someone encountered this issue? How do you resolve it?
I found a similar issue. Try to find
from django.utils import simplejson as json
and replace it with
try:
import json
except ImportError:
from django.utils import simplejson as json