I use Django-Registration-Redux in my Django project.
In settings.py, the code:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rango',
#'django.contrib.sites',
'registration',
In urls.py, the code:
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings
from registration.backends.simple.views import RegistrationView
# Create a new class that redirects the user to the index page, if successful at logging
class MyRegistrationView(RegistrationView):
def get_success_url(self,request, user):
return '/rango/'
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^rango/', include('rango.urls')),
#Add in this url pattern to override the default pattern in accounts.
url(r'^accounts/register/$', MyRegistrationView.as_view(), name='registration_register'),
(r'^accounts/', include('registration.backends.simple.urls')),)
if not settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
if settings.DEBUG:
urlpatterns += patterns(
'django.views.static',
(r'^media/(?P<path>.*)',
'serve',
{'document_root': settings.MEDIA_ROOT}),)
Then pyCharm show that my urls.py has errors: Unresolve reference 'registration'
I have run 'python manage.py migrate'. But the error still exists. Why does this happend? How can I fix it? And it's really strange that although pyCharm show error, my code run well.
PS: I write this code as the same as the django tutorial http://www.tangowithdjango.com/book17/chapters/login_redux.html