I'm trying to install OSQA, a Django application on Linux Red Hat (Python 2.7 and Djando 1.6). I synchronized the databases and I restarted Apache without get any error.
export DJANGO_SETTINGS_MODULE=settings
python2.7 manage.py syncdb --settings=settings
python2.7 manage.py migrate --settings=settings --fake
$APACHE/restart
After I opened the site from the browser I get HTTP status "200" Error, and in the logs I get this error:
ImproperlyConfigured: Error importing module forum.middleware.extended_user: "cannot import name get_svn_revision"
(See complete Logs)
Any help is greatly appreciated. Thank you!
I was also having this issue with OSQA, and restarting Apache solved it for me. I'm not sure why this happened though; sorry!
Related
I am trying to port a django web application from some server to cloudera "applications" (data science workbench) and I was trying to make it work. I managed to do so with flask and fastapi applications, just the django framework is missing. My problem, when trying the base setup (https://docs.djangoproject.com/en/3.2/intro/tutorial01/), locally works like a charm but when I try to start up the server from an instance in cloudera, the server does not start and, more curiosuly, I get a weird output related to some package of the image I am spinning. (you can see I am bypassing the traditional runserver command on django because in the cloudera applications side I cannot run shells directly and also due to the fact that I would to tie it up with some environmental variable)
below the manage.py
import os
import sys
if __name__ == '__main__':
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.management import execute_from_command_line
port_to_pass = 8000
args = ['name', 'runserver', '127.0.0.1:%d' % port_to_pass]
execute_from_command_line(args)
weird "print" (the instance I am spinning has got the exact same package versions installed locally):
when I should be getting:
any idea what might the problem be?
You need an extra entry.py script:
!pip install django
!python manage.py runserver 8000
I am wondering if anybody has experience with integrating a python manage.py migrate command into a MS Azure release pipeline. The app is being deployed using CI/CD pipeline through DevOps. In the release pipeline portion, the app is being deployed to three different stages (dev, test and prod). I have not been successful in being able to integrate the migrate command into the deployment process. I have tried achieving this by using a post deployment inline script:
/antenv/bin/python /home/site/wwwroot/manage.py collectstatic
/antenv/bin/python /home/site/wwwroot/manage.py migrate
If I run the above commands in the sandbox environment via SSH they are carried out successfully.
However, including them in the release pipeline as a post deployment script raises the following error:
2020-03-22T19:00:32.8641689Z Standard error from script:
2020-03-22T19:00:32.8727872Z ##[error]/home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: 1: /home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: /antenv/bin/python: not found
/home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: 2: /home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: /antenv/bin/python: not found
2020-03-22T19:01:34.3372528Z ##[error]Error: Unable to run the script on Kudu Service. Error: Error: Executed script returned '127' as return code. Error: /home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: 1: /home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: /antenv/bin/python: not found
/home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: 2: /home/site/VSTS_PostDeployment_1321584903618191/kuduPostDeploymentScript.sh: /antenv/bin/python: not found
I also attempted running the above in-line script as:
manage.py collectstatic
manage.py migrate
But to no avail.
Based on the Oryx documentation, it seems as though manage.py collectstatic is being run, but not manage.py migrate
Any ideas or suggestions would be very much appreciated! Thanks in advance.
Since we want to be able to use the release pipeline infrastructure on Azure DevOps, we cannot use startUpCommand: python3.6 manage.py migrate because there is no YAML file associated with the release in devops (at least as of yet). Instead, what finally worked was:
Creating a script file in the project repository. I named the file Procfile.sh. In this file I added the following two lines of code:
python manage.py migrate
python manage.py collectstatic --no-input
Add a new variable in the webapp configuration that points to that file:
{
"name": "POST_BUILD_SCRIPT_PATH",
"slotSetting": false,
"value": "Procfile.sh"
}
If you are running the collectstatic command in your script, you will want to disable the Oryx engine from running it as well:
{
"name": "DISABLE_COLLECTSTATIC",
"slotSetting": false,
"value": "true"
},
See Oryx documentation for more details.
When using Django, you typically want to migrate the data models using manage.py migrate after deploying the app code. You can add startUpCommand with post-deployment script for this purpose:
startUpCommand: python3.6 manage.py migrate
For details ,please refer to this official document.
It appeared that I successfully deployed the application using this code
import sys, os
sys.path.append(os.getcwd())
os.environ['DJANGO_SETTINGS_MODULE'] = "UR.settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
However Django did not run properly because it could not get to the latest version of Django and ran an old version with Python 2.3. I installed the latest Django and Python 2.7 and I added those two lines and now I am getting an internal server error..
INTERP = '/home/username/opt/python-2.7.7/bin/python'
if sys.executable != INTERP:
os.execl(INTERP, INTERP, *sys.argv)
I am sure this is the right path to my Python 2.7 ... any help will be really appreciated
I finally solved it ,
I was deploying on dreamhost and their servers had django1.2 and python2.6, whenever i tried to make python2.7 and let it be the default passenger gets to python 2.6 and successfully executes python2.7 but for some reason it ran into django1.2 instead of the latest django i installed.
I installed python2.7 in /usr/ (using a sudoer account ofcourse) then i installed the new django into site packages and now I no longer need the lines that execute python2.7 as it is the default now along with django 1.7
I have also edited the passenger-wsgi file and this code worked very fine for me....
import sys, os
sys.path.append(os.path.join(os.getcwd(), 'projectname')) #I needed this
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
The only setback now is that the server is to slow in it's response but other than that everything went fine
And i found a great trick to get into the logs of django
ssh into your server
Execute python manage.py runserver
Open another ssh session at the same time
In the new ssh execute lynx localhost:8000
Then you will be able to see logs and debug information from django in the second ssh .
I created a django app on openshift successfully. But, I'm not able to run syncdb using the following deploy hook.
#!/bin/bash
source $OPENSHIFT_HOMEDIR/python/virtenv/bin/activate
cd $OPENSHIFT_REPO_DIR/wsgi/$OPENSHIFT_APP_NAME
python manage.py syncdb --noinput
What could be wrong? Please help!
I think its simply because you forget to add the right for file execution with chmod +x filename
Today I changed IDE from Gedit to Geany.
I want to debug my django project, but don't know how.
My settings in debug tab:
Target: /path/to/manage.py
Command line arguments: runserver --noreload
Env variables:
DJANGO_SETTINGS_MODULE = settings
PYTHONPATH = print sys.path
When I try to run server, I got an error: Error loading file
Google doesn't help...
Thanks in advance :)