I'm trying to install django-admin-tools in my existing Django installation. So far so good except for the fact that the backend looks fuzzy and afters some inspection it seems that utils.js is missing:
If I look into my static directory (after running python manage.py collectstatic) the file simply isn't there (it is in the installed Python package so I don't know if it's supposed to be there anyway but it might be a clue)
I think the problem might be related with my configuration, here some snippets of it:
MEDIA_URL = '/'
STATIC_ROOT = os.path.join('static')
STATIC_URL = '/static/'
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
INSTALLED_APPS = (
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'blog',
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
'django.core.context_processors.static',
],
},
},
]
Django is 1.8.1
I'm wondering if anyone has some suggestions to fix this.
I've managed to fix this so for possible future readers:
The documentation (http://django-admin-tools.readthedocs.org/en/latest/configuration.html) states that django-admin-tools is modular. I thought that configuring installed apps with the above configuration was correct, it wasn't.
Although all the installed components seemed to work. Collectstatic probably couldn't find all the required files (files that belong to the base 'admin-tools' app).
The solution was to add 'admin-tools' to installed_apps so it looks like:
INSTALLED_APPS = (
'admin_tools',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
(...)
)
Related
I have done all the necessary settings in settings.py, and i have set the urls too i the urls.py file. Each time i am trying to access /accconts/login, it will say the url did not match any pattern, and it redirects me to /accounts/profile.
This are the code
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'core'
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
SITE_ID = 1
urlpatterns = [
path('accounts/', include('allauth.urls'))
]
Thanks for the reply. I was able to solve the problem. The way allauth works you must not be logged in while accessing /accounts/login.
What i did was to go to /accounts/logout/ and then logout before the /accounts/login will go
By default django-allauth divert logged in users from the login page.
You can use a couple of settings to fix the issue :
SET the ACCOUNT_AUTHENTICATED_LOGIN_REDIRECTS to FALSE
or
SET LOGIN_REDIRECT_URL to 'the desired path' for logged in users in the settings.py file.
https://django-allauth.readthedocs.io/en/latest/configuration.html
I have installed and configured django-admin-tools-stats as mentioned on https://django-admin-tools-stats.readthedocs.io/en/latest/index.html
However I can not generate any graph, or no widget for graphs is visible on my admin interface.
My settings.py
INSTALLED_APPS = (
#Admin Dashboard
'admin_tools',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
#For the admin interface statistics
'admin_tools_stats',
'django_nvd3',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.admin',
'rest_framework',
#Rest-auth
'rest_framework.authtoken',
'rest_auth',
#Rest-auth registration
'allauth',
'allauth.account',
'rest_auth.registration',
#Following is added to allow cross domain requests i.e. for serving requests those are coming from frontend app
'corsheaders',
#Admin reg stats
'admin_user_stats',
'chart_tools',
#'djangobower',
'flights',
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
#'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
],
'loaders': (
'admin_tools.template_loaders.Loader',
#'django.template.loaders.filesystem.load_template_source',
#'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.app_directories.Loader',
#'django.template.loaders.filesystem.Loader',
),
},
},
]
#To use custom admin dashboard, edit dashboard.py file to make any changes
ADMIN_TOOLS_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard'
ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'dashboard.CustomAppIndexDashboard'
What could be the reason?
Have you added django-admin-tools to your urls.py file like below -
urlpatterns = patterns('',
url(r'^admin_tools/', include('admin_tools.urls')),
#...other url patterns...
)
And make sure to migrate it using -
python manage.py migrate
Being a Django newbie, facing problem in using Django-allauth with my project. I installed the Django-allauth package in the virtualenv of my project successfully and also have made the relevant changes in the settings.py file to configure the same with my project.
I also checked the "requirements.txt" file and it has a line as "django-allauth==0.23.0". But as soon I tried to run the 'python manage.py migrate' command, I got an ImportError saying: No module named allauth.
Below is my code for settings.py:
Settings.py
...
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'myapp_v1',
)
SITE_ID = 1
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder'
)
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'myapp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.request',
],
},
},
]
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
...
Please let me know if I am missing something over here.
Since our discussion in comments identifies the problem, I'll post my answer.
I'd suggest a few ways that you can use.
Uninstall one of the python versions as you do not actually need two python running. Alternatively, remove one of the python paths from your environment variables so that both CLI and your project use same versions.
Use Pycharm, an IDE which will let you use specific python version through its interface and will allow you to install packages for the version you have selected.
or
Follow this thread on stackoverflow. Which is a similar question as you asked in your last comment.
Could any one help me to figure out why ?
I just followed the structure of tutorial , and installed the package called django-polls to my project called mysite successfully. But it returned "TemplateDoesNotExist at /polls/" after running the server.
Following is What I have done:
1.pip install /django-polls/dist/django-polls-0.1.tar.gz
2.modifed the settings.py in mysite project
3.modifed the urls.py in mysite project
4.python manage.py runserver
settings.py in mysite project:
...
TEMPLATE_DEBUG = True
...
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls',
)
...
ROOT_URLCONF = 'mysite.urls'
...
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader', # <--
)
I'm a Django beginner and I encounter an issue with django context_processors.
I want use a queryset in all my template for generate a menu.
But I get this error when I try to reach this page http://mysite/catalog which calls my cardabelle/catalog/views.py :
ImportError at /catalog/
No module named 'cardabelle.catalog'
Here "cardaballe" is my project name and "catalog" my application name.
Here is some interesting part (i guess) from my cardabelle/cardabelle/settings.py :
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar',
'catalog',
'autoslug',
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'template')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'cardabelle.catalog.context_processors.categories',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'cardabelle.wsgi.application'
and here is my custom context in cardabelle/catalog/views.py :
def categories(request):
return Category.objects.value()
Somebody knows why django doesn't find my new custom context ?
Thanks in advance for your help !
I guess you have the file context_processors.py in the directory catalog, which is on the same level as the directory cardabelle?
/catalog
__init__.py
context_processors.py
...
/cardabelle
__init__.py
settings.py
...
If yes, the context_processor setting should read
TEMPLATES = [
{
# ...
'OPTIONS': {
'context_processors': [
# ...
'catalog.context_processors.categories',
# ...
],
},
},
]
Also the context_processor should return a dict. Your current code reads Category.objects.value(). This is probably a typo while pasting it to SO? Just in case, make sure it reads Category.objects.values(), which returns a list of dicts.
def categories(request):
return {'menu_categories': Category.objects.values()}
It will then be available as {{ menu_categories }} in your templates.