Django perpetual 404s when visiting project directory URL - django

I have a very strange problem with Django and OLS. I am using the OpenLitespeed Django one click install droplet on Digital Ocean. In both my custom app and the example app in the droplet, if I visit a URL that matches the django project directory (in the example app, this is /demo/), then any subsequent page visits give a 404 error, no matter what URL you do. To reproduce, I've spun up a completely clean install of the droplet, then do the following steps:
Go to / -> see "Hello world!" as expected
Go to /demo/ -> also see "Hello world!" even though this should be a 404, as this URL is not specified in the urls.py or anywhere else
Go back to / -> 404! It seems to be looking for /demo/demo/ which doesn't exist
Trying any other URL also results in a 404.
The only way to get back to the normal behavior is to restart the OLS process. Everything then functions as expected unless any URL that starts with the project directory name is visited, in which case the whole thing crashes and returns 404s again.
Any help that can be provided to try and further troubleshoot this or possible fixes is greatly appreciated!
Versions:
OLS 1.6.9
Django 2.2 and 3.0
Python 3.6

Thanks for the bug reporting. It's a bug of "virtual context settings for wsgi" and should already fixed on version 1.6.11. If it's not on the repository, you can run the following command to upgrade it.
/usr/local/lsws/admin/misc/lsup.sh -v 1.6.11
Best,
Eric

Related

Deploying django project on AWS elastic beanstalk

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

How to use django "site" framework on google app engine

I'm going to answer my question. I ask this so that other people who is still searching on how to create a django "site" will have a clear answer.
The django documentation had show how to use the django site framework. But strangely, after googling for quite a while, I can't find a good instruction on how to install the site framework. We all know to install an app, we put 'django.contrib.sites' on the INSTALLED_APP list. But how to add the site? Using the admin interface will result in error that say that the site framework is installed but no site is configured (Duhh!). So, we have to assign SITE_ID on the setting.py. But what is the id? From some source, we know that the it has installed a default site by the domain example.com. But still what is the id? setting it to 0 or 1 will also result in error.
Just read the link:
http://www.allbuttonspressed.com/projects/djangoappengine
Definitely the best tutorial I have found:
Flying with Django on GAE
With this I had my site on appspot after about half an hour.
The answer is....
First, put 'django.contrib.sites' on the installed app list like usual.
Then run
python manage.py syncdb
(At you project directory that is). Then, run:
python manage.py shell
Then, use the following sequence of code:
>>>import django.contrib.sites.models as mod
>>>mod.Site.objects.all().count()
Make sure it prints out 1. If it doesn't you probably haven't run syncdb properly.
>>>msite=mod.Site.objects.all().get()
>>>msite.pk
It will print your default site id. SITE_ID (in setting.py.)to the number given. That should do it. At least on development server.
ps: Strangely, mine is 383L. Not 0 or 1. This is probably google app engine with django nonrel specific.

djapian based search freezes

When I try to run a djapian based search it freezes the applications and I dont get any response from the server. Am deploying the site using mod_wsgi. The search runs fine when i run it in the python shell or in the django dev server. The problem seems to arise only when I deploy my site to apache. Does anyone know how I can get around this issue?
I ran into the same problem when I started using Djapian. You should be able to work around this problem by adding the following to your Apache site
configuration file:
WSGIApplicationGroup %{GLOBAL}
More information on the subject is available here: http://trac.xapian.org/ticket/185 and there's a related ticket for Djapian here: http://code.google.com/p/djapian/issues/detail?id=35

Getting Django and Subversion to work together on Dreamhost

Does anyone know how to get Django and Subversion to work together on Dreamhost?
I've been following this tutorial to install Django (which uses Passenger WSGI):
http://wiki.dreamhost.com/Django
After I got Django to work, Subversion stopped working. Has anyone ran into this problem?
I had the same problem. My solution for now has been to move the Subversion link to a different subdomain.
In my case, I'm only using Django for 1 subdomain in my whole domain (dom1.myurl.com), so I just created a dom2.myurl.com subdomain, and set my SVN path to use it instead.

Deploying a "working when run locally via pycharm" django app to webfaction

I've been following the steps in the box under "Configuring Django" here to try and get the django app up onto webfaction after getting it to work locally.
I zipped my project folder and used scp myproject.zip catubc#web513.webfaction.com to get it up. I then used ssh and moved the zip to $HOME/webapps/plot_composite_metrics as the linked steps instruct and unzipped it there. Since the name of my project is "myproject" I didn't have to do steps 6-7.
From the webfaction control panel I have made an application and called it plot_composite_metrics, Django 1.9.1 (mod_wsgi 4.4.21/Python 2.7). I also made a new website called good_morning_cat and added plot_composite_metrics to it.
I have ALLOWED_HOSTS = ['catubc.webfactional.com'] in settings.py
So, as per this example why do I get a "server not found" when I navigate to http://good_morning_cat.catubc.webfactional.com/? What did I forget to do to link my working-locally via pycharm app to said domain?
I have seen this related question, sadly I believe I am using the correct python version, so that's not the issue. Additionally, I do have a paid account if that makes any difference.
You have to add all the domains in the WebFaction control panel, i e http://good_morning_cat.catubc.webfactional.com/ as well.
http://catubc.webfactional.com/ works as this is what you have specified, it's resolved anyway. There's an ImportError because you haven't installed all your dependencies.