I've gone through the installation steps on the Django-CMS site, and I am unable to do the initial migration. I keep getting the following error:
if x['BACKEND'] == 'django.template.backends.django.DjangoTemplates'][0]
KeyError: 'BACKEND'
Googling this error yields nothing. I've scoured setup.py and I'm not seeing anything like this. I'm just lost and a bit worried that the install instructions may be a bit dated, as I also had to remove the list of extra apps they suggest adding to INSTALLED APPS because none of them were found. Anyway, I'm down to this error, I think. Is anyone familiar with this?
You probably miss the 'BACKEND': 'django.template.backends.django.DjangoTemplates' entry inside the TEMPLATES setting, in your settings file. Check out https://docs.djangoproject.com/en/dev/ref/settings/#templates
Make sure that all of your entries are listed in single dictionary. For instance, if you are following along with the 'Integrating a third-party application' tutorial, when they show the following...
'OPTIONS': {
'context_processors': [
# ...
'aldryn_boilerplates.context_processors.boilerplate',
],
'loaders': [
# ...
'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
],
},
},
...you need to integrate it into your existing dictionary. Your TEMPLATES array would then look like the following:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates'),],
'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.template.context_processors.request',
'django.template.context_processors.csrf',
'sekizai.context_processors.sekizai',
'cms.context_processors.cms_settings'
'aldryn_boilerplates.context_processors.boilerplate',
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
],
},
}
]
Related
How to make my PyCharm to reload Django dev server after i make changes in templates?
It reloads on save on every other changes but not for template changes.
server is starting by docker compose up
We are using Django 3.2.16
entrypoint.sh:
exec gunicorn app.wsgi:application --config gunicorn.py --reload
settings.py
[...]
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",
"app.context_processors.get_version",
"app.context_processors.get_env",
]
},
}
]
[...]
I have an Angular flavoured Nativescript project, which must be tested with "vanila" Jasmine, in a browser (so not in mobile) with ng test.
By default, with "naked" tests, it works. But the problem is, if I try to test/import anything, that has a ".tns" alternative, in some cases it loads that, and the build fails.
My problem is similar to this thread but there were no good solution described there.
So for instance:
I have two files:
app.component.tns.ts
app.component.ts
and I try to import it for testing in app.component.spec.ts:
import {AppComponent} from "#src/app/app.component";
it loads the .tns. file, and the build fails, as it cannot load the mobile-specific libraries.
ERROR in ./src/app/app.component.tns.ts
Module not found: Error: Can't resolve 'nativescript-ui-sidedrawer' in '/home/..../src/app'
resolve 'nativescript-ui-sidedrawer' in '/home/...../src/app'
Parsed request is a module
using description file: /home/...../src/package.json (relative path: ./app)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
...
# ./src/app/app.component.tns.ts 25:35-72
# ./src/app/app.module.spec.ts
# ./src sync \.spec\.ts$
# ./src/test.ts
is there any solution to "remove" the .tns. files, just as if I were running a simple ng serve?
update: My tsconfig.spec.json should exclude these files, but it does not work either ...
"exclude": [
"**/*.tns.ts",
"**/*.android.ts",
"**/*.ios.ts"
]
}
it seems the problem was with tsconfig.json. Specificly this part:
"compilerOptions": {
...
"paths": {
"#src/*": [
"src/*.android.ts",
"src/*.ios.ts",
"src/*.tns.ts",
"src/*.web.ts",
"src/*.ts"
]
},
As this was extended by the tsconfig.spec.json.
I modified the tsconfig.spec.json to this:
{
"compilerOptions": {
"target": "es5",
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"typeRoots": [
"node_modules/#types"
],
"lib": [
"es2017",
"dom",
"es6",
"es2015.iterable"
],
"baseUrl": ".",
"resolveJsonModule": true,
"esModuleInterop": true,
"paths": {
"#src/*": [
"src/*.ts"
]
},
"outDir": "../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"src/test.ts",
"src/polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
],
"exclude": [
"**/*.tns.ts",
"**/*.android.ts",
"**/*.ios.ts"
]
}
and now the tests run, and the correct components are imported.
my polymer.json
{
"entrypoint": "index.html",
"shell": "src/boo-blogger/boo-blogger.js",
"sources": [
"images/*",
"fonts/*"
],
"extraDependencies": [
"manifest.json",
"node_modules/#webcomponents/webcomponentsjs/*.js",
"node_modules/web-animations-js/web-animations-next-lite.min.js",
"node_modules/#webcomponents/webcomponentsjs/bundles/*.js"
],
"builds": [
{
"name": "es6",
"bundle": true,
"browserCapabilities": [
"es2015",
"modules"
],
"js": {
"minify": true,
"transformModulesToAmd": true
},
"html": {
"minify": true
},
"css": {
"minify": true
},
"addServiceWorker": true
}
],
"npm": true,
"lint": {
"rules": [
"polymer-3"
]
}
}
I got the problem
article-list.js:5 Uncaught (in promise) TypeError: _booBlogger.html$1 is not a function
article-list.js imported dynamic by routing. So I tried to attempt some build option differently to build. I found when I build without bundle, built code can work. I don't know why my code can not bundle by polymer build. if anyone is curious the problem and need completely source code. contact me
tools summary
system: ubuntu 16.04
polymer: 1.7.7
node: 10.1.0
In your polymer.json you need to add:
"fragments": [
"src/article-list.js"
],
I think you forgot to add article-list.js to your sources. As it is written in docs you have to include your dynamically imported modules to "sources" in polymer.json. See https://polymer-library.polymer-project.org/3.0/docs/apps/build-for-production#dynamic
I have already looked for almost all questions but still none of the answers is working for me. The error I get:
My BASE_DIRS = "/home/amank/Adevelopment/test/mechanical/templates"
This is okay but still django is looking in different irrelevant paths as shown in screen shot ...
My related settings:
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
.
.
.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'debug': DEBUG,
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Any method to give templates path manually in settings.py?
Traceback
PROBLEM SOLVED ..But still I don't get the reason behind it .I have posted the solution below..
Go to your main project directory, make sure you have
templates
directory inside it. Inside templates you should have home directory inside which there should be index.html
This answer is based on image provided in Question.
I got it working somehow but i even don't know how it worked...Basically
I removed this part fully
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'debug': DEBUG,
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
and replaced it with
TEMPLATE_DIRS = (
"/home/amank/Adevelopment/test/mechanical/templates",
)
It somehow worked . If anyone can explain why before it wasn't working on PC while same code is running it on internet www.me.iitb.ac.in ?
I am exporting a django project from a computer that runs Ubutnu to another that runs Windows 10. I've exported the environment with pip install -r requeriments.txt and everything seems to work fine, since, for example, python manage.py migrate is working properly.
The server starts fine with python manage.py runserver, however, when I open the URL http://127.0.0.1:8000/home in my browser I get the following error:
IOError at /home/ [Errno 22] Invalid argument:
u'C:\Users\myusername\Envs\myenv\myproject\:\HomePage.html'
The views are correctly setup because the project was running OK in ubuntu. The problem seems to be that the HomePage.html, which is supposed to be located in ...\\myproject\\marketingApp\\templates\\HomePage.html, is being looked for in ...\\myproject\\:\\HomePage.html and I don't know how/where to fix that.
I managed to load http://127.0.0.1:8000/home by adding my project folder path 'C:\\Users\\myuser\\Envs\\myenv\\myproject' directly into the TEMPLATES dict:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates'),
'C:\\Users\\myuser\\Envs\\myenv\\myproject'
],
'APP_DIRS': True,
'OPTIONS': {
'debug':DEBUG,
'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.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz"
],
},
},
]