When serving my django-cms application on apache with mod_wsgi I can't get the text-plugin to work.
The difference is that when serving on apache the textedito tries to get an url that does not exist.
On Apache:
/admin/js/iframe/default/wymiframe.html
With manage.py runserver
/static/cms/wymeditor/iframe/default/wymiframe.html
the wymiframe.html file is present in my static folder and is accessible but not via the wrong URL that I get when running the app through apache.
What do I do to get the text-plugin requesting the right URL?
What have you set STATIC_URL to in your settings file? That in part is what controls paths when links are created.
https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/#serving-the-admin-files
My problem was that I served static content on a subdomain and I had problems with Access Control.
My solution was to set
Header set Access-Control-Allow-Origin *
in my apache config file
Related
I have a Django application running with a gunicorn ASGI server and an NGINX reverse proxy for serving static content. All are packaged within a docker container.
Now I want to serve this container behind a reverse proxy with a path prefix, e.g. "mydomain.com/djangoapp/". The problem is, that Django doesn't know it's hosted under a subpath, and for example, the Django admin application then always redirects to the root path "/" instead of "/djangoapp/".
I already read that there are several settings that handle this problem.
I tried setting the "FORCE_SCRIPT_NAME" in the Django settings directly to "/djangoapp". It worked for the admin login page, but after clicking the login button it redirected to the wrong root "/".
I tried setting the "SCRIPT_NAME" environment variable of the gunicorn server to "/djangoapp". It did not apply at all.
I'm running now out of ideas on what else to try. Does anybody else have a solution for this problem?
FORCE_SCRIPT_NAME should work. For the post-login redirect you need to properly set LOGIN_REDIRECT_URL
Here is my set-up: Django 1.7; Python 3.4, mod_wsgi, virtualenv, apache2. Django and other pakages are installed after activating the virtualenv.
Need .htaccess file for redirects. I am new to deployment world, so please bear with me.
Here is what I have done so far:
In the virtualhost, I call the wsgi.py file after specifying the path to site-package path for Django. This works fine, however I have 2 questions:
1) I saw a lot of sites which were calling the file.wsgi file from the virtualhost config, and in the .wsgi file they were calling the exec to activate the env and call django app. The Django guide however has a different approach (https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/) and this is the one I implemented. Do I need a file.wsgi if I want to have htaccess deal with the request and then forward it to Django urls.py?
2) If the set-up that I have is ok for deployment, where do i place the .htaccess file and ensure that apache sends the request to htaccess which in turn sends it to Django app?
Thanks
So I've seen alot about Apache not serving Django admin static files, but for some reason, Apache is not serving any static files. It understands and finds the templates, but no images, css, or javascript is loaded.
EDIT 2: Updated the two files to show new settings
EDIT: I added the STATIC_ROOT and I was able to collectstatic files, but it still doesn't serve them after server restart.
I've tried ./manage.py collectstatic and get this error:
ImproperlyConfigured("You're using the staticfiles app "
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without
having set the STATIC_ROOT setting to a filesystem path.
My settings.py file is here:
https://github.com/rchurch4/stackquestions/blob/master/settings.py
My nxt4.com.conf file is here:
https://github.com/rchurch4/stackquestions/blob/master/nxt4.com.conf
If someone could please let me know exactly how to configure this so that Apache will serve django's static files, that would be great. I'm running Ubuntu on AWS with a mysql db. The filepath to the site on the server is: /home/ubuntu/nxt4.com/nxt4/
Thanks in advance
The error message seems quite clear: you have not set the STATIC_ROOT setting, so collectstatic does not know where to put the collected files. From the looks of your httpd.conf, it seems like it should be set to "/home/ubuntu/nxt4.com/static/"
My django admin page didn't display properly. Like a pure html display. Can someone help here?
I don't have the permission to upload screenshot. But you can imagine, it doesn't look the same as tutorial shows.
thanks
You probably don't have static files serving set up. If you have DEBUG turned on, you'll get this automatically with Django's development server (./manage.py runserver). If running in production, you need to set this up manually. See the docs for more info.
Basically your static files are not set up properly, some of the reasons can be :-
If you running on a server like apache, you need to have static url in settings.py and same alias in httpd.conf file of apache.
If you are running on django in built server, please try to set Debug=True, which will force django to serve those static files.
If you have debug=False in settings.py file, https://docs.djangoproject.com/en/dev/howto/static-files/
Because u really need a static files from django, sometimes you have to set the alias of django admin static files separately, which can be set in urls.py that is pointing to django package
found the issue.
I forgot to turn on
'django.contrib.staticfiles'
in setting.py file
I am using Django and Apache.
I am serving the static files with Apache. It works well, the problem is, when a user go to the url http://urlOfMySite.com/static, he can see the whole directory and navigate in it.
I'm using : Alias /static /var/www/MySite/app/app/static in Apache VirtualHost to serve static files.
Is there any way to hide it from user? (make the static files accessible, but not the full directory browsable).
Thanks
Your problem is about the apache server itself, you need to disable indexing for that folder with "Options -Indexes" inside the "directory" clause to specify which folder you want to apply this command. More info:https://wiki.apache.org/httpd/DirectoryListings#Directory_Listings
Btw, this is odd, by default, when I deploy using Apache, I don't need this =/.