2👍
I use the approach documented here. With this arrangement, you have common, production, dev, and test settings. Works for me.
0👍
- [Answered ]-Django ~ WSGIRequest with a form added via get_context_data method
- [Answered ]-Complex query in template of django
- [Answered ]-Is there a way to access a model field from its corresponding model form field?
- [Answered ]-Docker: How to rely on a local db rather than a db docker container?
- [Answered ]-Django: how to correctly delete database record to prevent primary key reuse?
0👍
Steps to get your Django App from development to Production
-
open your project folder then find
settings.py
find the following line,SECURITY WARNING: don’t run with debug turned on in production!
DEBUG = False
Change the debug to false.
-
Change your db credentials with the actual production server db credentials
in yoursettings.py
DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.mysql’,
‘NAME’: ‘seocrawler’,
‘USER’: ”,
‘PASSWORD’: ”,
‘HOST’: ‘localhost’,
‘PORT’: ”
}
} -
once done upload your project folder to the folder in server
-
open putty enter your server credentials, then a terminal or cmd will pop
up. -
check python is installed on your server by executing below command in terminal
python -V
-
then check whether django is installed by running
django-admin --version
,
make sure that the django version you used to develop the project matches the one on server if not the install the specific version. -
now using the
cd
command to go to the project folder which containsmanage.py
file. -
now run
python manage.py showmigrations
this will list if any db migration is pending for your project. -
now run
python manage.py makemigrations
this will migrate the db tables to production server database. -
now run
python manage.py runserver 0.0.0.0:8000
then go to your domain likewww.example.com:8000
in browser, to test whether your site is working. -
once your site is up and working we want python manage.py runserver command to run even after the terminal is closed (means python manage.py runserver command in as background task/process).
-
to do that run
nohup python manage.py runserver &
this will run command in background and will never die the process even when putty terminal is closed. -
All done! now your server is up and your site too.
-
Enjoy!
- [Answered ]-Django Queryset most accurate search result
- [Answered ]-Django objects.count() in default method parameter returns 0
- [Answered ]-Django settings module and relative paths
- [Answered ]-How to write the django-piston handler to create and return ApiKey?
- [Answered ]-Django codemirror get code from editor