Im about to deploy my django-app to heroku. I will then use whitenoise to handle the static files. The tutorial im following tells me i have to add this to my wsgi.py file:
So the problem is that pycharm tells me: "Cannot find reference 'DjangoWhiteNoise' in 'django.py'"
However i have installed whitenoise! and it is located in the "External libraries". I even went down into the whitenoise.django file, and there is nothing named DjangoWhiteNoise there...
Thanks in advance. Havent found anythin about this concrete problem anywhere.
The tutorial you are following is for an older, outdated version of WhiteNoise.
There are up-to-date instructions here:
http://whitenoise.evans.io/en/stable/django.html
Related
In my project, I just added new security methods, separating the .env from the project into another folder and adopting the use of new processes. To do this, I followed the python-dotenv lib documentation, which I use in my app.
But even following the suggestion I can not find all the parameters, since I end up having the following error:
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty
My settings:
from dotenv import load_dotenv
env_path = Path('/home/user/configs') / '.env'
load_dotenv(dotenv_path=str(env_path))
How can I resolve this problem from the specific path?
Note: I use in my project, python 3.4.5 and django 1.9.4, but I do not believe that the problem is caused by the old versions adopted in the project.
Another important detail is that the .env file is correct, because when I use it in the same folder where I find the file settings.py it works without problems!
I'm also using this approach and from past few months I'm following a very good developer and he also writes about a python dependency "python-decouple" and you will going to get it in detail at this link
I think this will definitely going to solve your problem.
Python-decouple github repo : here
You can add the folder containing .env to the path. Here's how I did it:
load_dotenv(os.path.join(BASE_DIR, "project", ".env"))
Answered it here.
I am currently working on the cadasta - an open source organisation's - Django project.
They require you to run their platform in a virtual machine (virtualbox) using vagrant.
As I enter their repository, and run their server using ./runserver, I am all of a sudden getting a CompileError which says:
File to import not found or unreadable: bootstrap-sass/assets/stylesheets/bootstrap/variables. Parent style sheet: /vagrant/cadasta/core/static/css/_variables.scss.
on line 74 of core/static/css/_variables.scss
#import "bootstrap-sass/assets/stylesheets/bootstrap/variables";
Following this link: https://github.com/jrief/djangocms-cascade/issues/130,
I found that libsass is already installed, and so I tried installing bootstrap-sass inside the VM, but it did no good. Everything was working fine until I renamed the cadasta-platform directory (i.e their github repo that I cloned, and so the main project is included inside this folder only.) and refreshed. I even tried running the server again, but couldn't get through this error. I suppose renaming the directory shouldn't be the cause?
I have no clue on how to proceed. Please help.
EDIT: After renaming the project folder to the same name solved this error. If anyone would ever like to answer this question, please explain why renaming the project directory produces an error like this? As I believe, I think renaming should not be an issue?
I keep getting an exception stating
DOMAIN dictionary missing or wrong.
My folder structure looks like this
.
└──myapp
├── app.py
├── app.wsgi
└── settings.py
So Eve is stating that Dictionary cannot be found, even though it's defined in the settings file. I'm running this app in a virtualenv and I have my apache virtual host pointed to the wsgi file.
Hit this too, and after a bit of rooting around this is the conclusion I've reached.
Eve has, to me, an unintuitive method of finding the settings file. You can see it in the code. It does the following:
Gets the name of the settings file from the environment variable 'EVE_SETTINGS' if set, otherwise from the string passed as the settings= key-word argument to the Eve() constructor, default 'settings.py'.
Looks in the directory of sys.argv[0] to see if the file is there. It seems odd to me that this is useful enough to be the first option.
Walks every directory in sys.path to try and find a settings file. Which means if any module you have installed in your environment has a file named settings.py anywhere in it, Eve will try to use that.
If Eve doesn't find one, then it doesn't use one.
So, my problem was that I was running Eve from a virtualenv that also had django installed. Django has (at least one) sample 'settings.py' file in it. So Eve was trying to use that. And it was crashing. Thanks Eve.
Also note that it doesn't look in the current directory for a settings file at all (unless it's in your PYTHONPATH). This seems a bit nuts to me.
I have raised an issue on Eve's github page.
I am using Django Contact Form within my application which requires the following addition to my urls.py file:
url(r'^contact/', include('contact_form.urls'), name='contactform'),
What I don't understand is the include() function:
include('contact_form.urls')
Looking in the Django Docs, I thought that using include() refers to another URLconf module but
having looked over the file system I can't find anything with this name which leads me to believe that my understanding of include() is not correct?
So can you tell me what or where this "contact_form.urls" is?
In case of need I am using Django 1.6. on Xubuntu 14.04.
Thanks in advance.
It's in the python path.
Presumably, you installed django contact form, which would put contact_form in your python path.
If you can't find it in your entire filesystem you're not looking hard enough!
python -c "import contact_form; print(contact_form.__file__)" would be another way to find where this physically exists.
The problem
Foundation 5 was released last week, that's great, but the new version requires to use bower for using F5 with SASS and the official documentation seems to be a bit incomplete and immature.
I'm trying to create a project using the steps proposed by the docs:
[sudo] npm install -g bower
and then
gem install foundation
No problems here. The problem is when creating a Compass project:
foundation new MY_PROJECT
cd MY_PROJECT
compass compile
After Compass compilation, I get the following error:
directory stylesheets/
error scss/app.scss (Line 1: File to import not found or unreadable: settings.
Load paths:
/home/cartucho/MY_PROJECT/scss
/var/lib/gems/1.9.1/gems/compass-0.12.2/frameworks/blueprint/stylesheets
/var/lib/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets
/home/cartucho/MY_PROJECT/bower_components/foundation/scss
Compass::SpriteImporter)
create stylesheets/app.css
Compass config file (config.rb):
# Require any additional compass plugins here.
add_import_path "bower_components/foundation/scss"
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "scss"
images_dir = "images"
javascripts_dir = "javascripts"
The SASS file (app.sass):
#import "settings";
#import "foundation";
...
The problem seems to be in config.rb:
add_import_path "bower_components/foundation/scss"
because Compass fail trying to import the files settings and foundation but I don't know how to fix it. Any help will be highly appreciated.
Thanks.
You need to change the line foundation new MY_PROJECT by replacing MY_PROJECT with the folder you want to install the project on. After that, confirm that these folders exist on the directory you specified above - "bower_components/foundation/scss"
When starting a project run compass init and then compass watch (in Terminal) to watch for changes on the .sass files.
Personally, I don't go that route and use http://koala-app.com/ to convert or "compile" my Sass. It's FREE and awesome.
This is SASS were talking about. Please correct me if i'm wrong but you don't need the underscore when importing an "include" file. I create separate sass files for my variables and my mix-ins. They are prefixed with and underscore which signifies an "include" file. SASS recognizes #import "variables"; as #import "_variables.scss". So to be clear when it is an include file just the name of the sass file is need not the _ or the scss extension.
I have never put an underscore before any include file that I have named _filename.scss.
There is probably another issue going on. Possibly with the install and the paths for bower. For those who did add the underscore in the past and it worked...well you just bypass what could become a deeper issue down the road. You need to check your install.
In your app.sass file change the following line
#import "settings";
To
#import "_settings";
Explaination
When you run compass watch you got the error
error scss/app.scss (Line 1: File to import not found or unreadable: settings.
This just means it can't find the settings file being imported. By adding the underscore to the settings file you have specified the correct file path. If you receive any other errors like this, make sure the file path is correct.
I think I had the same error; finally I found in the _settings.scss
You need to underscore before the importing the functions
Before:
// Uncomment to use rem-calc() in your settings
#import "foundation/functions";
After:
// Uncomment to use rem-calc() in your settings
#import "foundation/_functions";
Also you would need to import the settings same way.
In my example I made style.scss and import all the SCSS inside :
#import "foundation/_settings", "_normalize", "_foundation";
I encountered this same issue, but for me the solution was to change the import of settings in app.scss from:
#import "settings";
To:
#import "foundation/_settings";
Once you've done that, run compass watch again.
You can install Grunt into your project which uses compass's watch function and then some other clever stuff to compile your sass and livereload it in the browser! Here's a great tutorial on how to get it up and running! (it's as simple as creating two new files in the root of your project and then running a few commands from your command line! I seriously advise it!)
http://moduscreate.com/get-up-and-running-with-grunt-js/
I had the same problem.
For Ubuntu 14.04 users make sure nodejs and Bower are working properly.
You can follow these instructions here http://www.codediesel.com/javascript/installing-bower-on-ubuntu-14-04-lts/comment-page-1/#comment-63283