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 ?
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.
I've been trying for hours and I can't seem to do it I've downloaded extensions and asked for help around but everything is just confusing me at this point.
I want to include the SFML libs in my project and I'm trying to use the the Visual Studio Code editor for it but it just won't comply for some reason.
A picture of what it currently looks like.
http://imgur.com/qJPlJua
I've been trying this for hours yesterday also but it just doesn't want to work.
I know the topic is a couple years old now but since I was searching for a way to link the sfml lib in vs code and I first ended up here, I thought I would share this git repo I found, which works pretty well for me so far:
https://github.com/andrew-r-king/sfml-vscode-boilerplate
I'm not using SFML 2.5.1 though, so I had to bring a small change in the c_cpp_properties.json file (I am on Ubuntu 18.04 and installed sfml through package manager)
here my c_cpp_properties.json file:
{
"configurations": [
{
"name": "Linux",
"intelliSenseMode": "gcc-x64",
"includePath": [
"${workspaceFolder}/src",
"/usr/local/include/**",
"/usr/include/**"
],
"defines": [],
"cStandard": "c11",
"cppStandard": "c++17",
"forcedInclude": [
"${workspaceFolder}/src/PCH.hpp"
]
}
],
"version": 4
}
I know this question is about two years old, but after fiddling with my own tasks to solve this problem, and came up with something. This shouldn't be the best way to do it, but this should be good for anyone that finds this answer in the future.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Compile",
"type": "shell",
"group": "build",
"command": "g++",
"args": [
"${file}",
"-o",
"${fileBasenameNoExtension}.exe",
"-IC:\\SFML-2.5.1\\include",
"-LC:\\SFML-2.5.1\\lib",
"-lsfml-graphics",
"-lsfml-window",
"-lsfml-system",
],
"problemMatcher": [
"$gcc"
]
}
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
//"showReuseMessage": true
}
}
This should work the same as the above answer. Hit CTRL+SHIFT+B to bring up the Task prompt, or look up Run task in the Command Palette (CTRL+SHIFT+P). Remember to have the .dlls of each library used in the root of the project.
Hope this helps.
I searched and I have found the solution.
In the tasks.json file, define two tasks :
"tasks": [
{
"taskName": "Compilation",
"isBuildCommand": true,
"args": ["-c", "${workspaceRoot}\\main.cpp", "-IC:\\SFML-2.4.0\\include"]
},
{
"taskName": "Liaison du fichier compilé aux bibliothèques SFML",
"args": ["${workspaceRoot}\\main.o", "-o", "sfml-app.exe", "-LC:\\SFML-2.4.0\\lib", "-lsfml-graphics", "-lsfml-window", "-lsfml-system"]
}
],
and add "suppressTaskName": true,
So it's like on Linux.
You compile with CTRL + SHIFT + B. To create the .exe file : CTRL+SHIFT+P --> then "run task" then click on the "Liaison du fichier compilé aux
bibliothèques SFML" task.
the entire file is as (for me):
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "g++",
"isShellCommand": true,
"suppressTaskName": true,
"tasks": [
{
"taskName": "Compilation",
"isBuildCommand": true,
"args": ["-c", "${workspaceRoot}\\main.cpp", "-IC:\\SFML-2.4.0\\include"]
},
{
"taskName": "Liaison du fichier compilé aux bibliothèques SFML",
"args": ["${workspaceRoot}\\main.o", "-o", "sfml-app.exe", "-LC:\\SFML-2.4.0\\lib", "-lsfml-graphics", "-lsfml-window", "-lsfml-system"]
}
],
"showOutput": "always"
}
well there is nothing more to say, except all it's written on official web-site:
https://code.visualstudio.com/docs/cpp/config-linux
the only stuff I needed to do is to add additional library links for the compiler, which can be done in tasks.json part:
...
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-lsfml-graphics",
"-lsfml-system",
"-lsfml-window"
],
...
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"
],
},
},
]
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',
],
},
}
]