Django cannot find the static files on the google server, the
python manage.py collectstatic
command has already been used with the settings.py configured.
To solve this problem I followed several tutorials that showed us how to deploy static files, including the documentation itself. However, none got results. It is worth mentioning that this same code and configuration worked in the homolog version of the system.
Related
I have created a new Heroku site and I am developing it on my Linux box, using Django. The standard "getting started" site Heroku created for me is called "gettingstarted". How can I change that / configure Heroku to forget about it?
I was reading through the Django tutorial, which explains how to create a new site (django-admin startproject my_site). I did this successfully for a demo project. Then I tried to do it under the Heroku directory, because I wanted a better name for my site than "gettingstarted". I noticed that every time I start the Heroku server under my project, it says ...using settings 'gettingstarted.settings'. I found that this is configured in manage.py and I change it.
This is the directory layout I have
/some/path/heroku_random_name/gettingstarted/settings.py
/some/path/heroku_random_name/my_site/settings.py
/some/path/heroku_random_name/my_app
This is what I have in
/some/path/heroku_random_name/manage.py
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_site.settings')
so I would expect that the site that matters is my_site.
I got it to the point where I can run the site successfully on my local machine, and I can tell that it using the settings from my_site. But when I deploy the project to Heroku, it does not recognize my_app until I register it in gettingstarted/settings.py. In other words, when running in Heroku, it is still using gettingstarted as the site to run.
I am new to all this, so I left gettingstarted in the project, because I am afraid to break things. But how can I configure Heroku to execute settings from my_site and not from gettingstarted?
Found it: it's configured in Procfile.
It's confusing because it's configured in one place for running locally and in a different place for running hosted at Heroku.
The website displays to localhost without css, js, or images.
I setup Windows IIS according to this blog including the final section about static files. The methods outlined are similar to answers from this question, this question, this blog, and this youtube video on how to serve static files from django with IIS.
UPDATE: The problem may be coming from my virtual environment. This project was developed with Anaconda. When I followed the listed tutorials I simply used the paths to my conda venv and didn't think anything of it since the localhost loaded without errors. At the time python was only present on my machine in the anaconda environment, so if manage.py was able to execute and database data was accessed and displayed(without css/js) then I presumed this was not an issue. I am currently trying to interpret this blog on how to setup Anaconda for IIS 8.5 to see if I need to make additional changes to IIS 10. I have not had any luck using web.config files and have had to accomplish the same goals through IIS manager. Jalpa Panchal's comment lead me to investigate the environment.
Any ideas on what additional changes need to be made for IIS 10 to interpret an Anaconda(conda 4.8.3) developed django application?
ORIGINAL POST:
Django settings:
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, 'static') # tested in shell, it is where I expect at the same level as manage.py
The directory "static" was created with manage.py collectstatic in the expected STATIC_ROOT location with all of the static files contained
IIS Manager:
The static directory was then added as a virtual directory:
Then I removed the django handler I created from the static directory's handler mappings:
I unlocked the handlers at the root:
The django application did display properly, with static files, when I tried using Wampserver w/ Apache and mod_wsgi. Unfortunately, it appears windows IIS will be the better solution for other unrelated reasons. Not too mention Wampserver is a development server, not a production server.
I defined a path for the environment variable WSGI_LOG, the logs generated have no errors. Just states wfastcgi.py was initialized and will restart when there are changes to the files in my project
What else can I be missing that would prevent my static files from being processed?
I have a regular django site, with djangorestframework (v2.3.14) serving restful api under "/api". On local box everything works fine (mac / mavericks), on remote box (Ubuntu 12) the API browser comes up but all the bootstrap stuff is missing (the page looks like it's out of 1992 prototype instead of pretty bootstrap theme i see locally).
All the pip dependencies have been upgraded and are identical. Locally running site through PyCharm, remotely it is running on WSGI.
What can I check to see what the issue is and resolve it??
I suppose that under PyCharm on your local machine you are running the development server, which serves static files directly from your apps and projects internal locations.
After every deployment into production (your WSGI server) you need to collect all static files to a single place, your STATIC_ROOT. This is a job for the django management command collectstatic, see Django docs here.
The command may look like this:
# Executing collectstatic (organize static files)
python /path/to/your/project/manage.py collectstatic --noinput
For further details you may also read Django cannot find static files. Need a second pair of eyes, I'm going crazy.
If this question doesn't help, you can quicly fix it making a link under your proyect's static folder
ln -s /your_env_folder/lib/pythonX.X/site-packages/rest_framework/static/rest_framework rest_framework
I am following the tutorial for deploying a django project on AWS elastic beanstalk here:
http://docs.amazonwebservices.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html
My app works when I test locally but when I deploy, I'm getting a 404 error. Looking at the event logs, I see this message:
Error running user's commands : An error occurred running '. /opt/python/ondeck/env && PYTHONPATH=/opt/python/ondeck/app: django-admin.py syncdb --noinput' (rc: 127) /bin/sh: django-admin.py: command not found
That leads me to believe that the tutorial is missing a part about installing django files on the server or at least configuring my project to recognize django-admin.py. I have django installed on my local machine so it works there.
I know python support is brand new for elastic beanstalk but has anyone deployed django to it?
I believe you don't need to put container_commands in .config because there is no database or table at this moment.
Did you made the step?: Freeze the requirements.txt file.
(djangodev)# pip freeze > requirements.txt
Note
Make sure your requirements.txt file contains the following:
Django==1.4.1
MySQL-python==1.2.3
I had the same problem because I skipped it. Once I did it, add, commit and push. It works!
I followed the same tutorial recently and had a similar result.
At step 6, upon seeing the default django 'congrats' page render locally, I deployed to EB as instructed and got a 404 instead of the default 'congrats' page.
I decided to use the code up to that point as a foundation for following the 'getting started with django tutorial' which led me to a successful rendering of a 'home' view. This is a much more useful place to be anyway. I do agree that there is something wrong with the AWS tutorial and posted to the AWS forums here.
If you can, you should try to access the log file; it might give you a better idea of what's going on. Here's a link that might help:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.loggingS3.title.html
this is app-engine-patch http://code.google.com/p/app-engine-patch/
i download it ,and unzip , but can't running on my google-app-engine launcher
why ?
updated
but the patch has app.yaml, and i can't find aep-sample
updated2
when i python manage.py runserver
so can app-engine-patch running on gae launcher ?
App Engine Patch isn't an App Engine app, it's a library to use with your app. If it doesn't have an app.yaml file, it won't be able to be run.
It looks like there's an aep-sample app included in the .zip file, try running that.
(response to edit)
The app.yaml file you found references aep-sample as the app's name, but the app listed in the launcher says "patch", so something's wrong there.
Have you read the Getting Started page on the project's site? Reading the documentation is generally a helpful first step.