How to host django in the company's server?

Recently I developed a simple django project to be used by my colleagues. The goal was to have the project only available within the network so no one outside the company could access it. The company has a server, with a certain IP that will host the project.

What steps do I have to take, either in django or on the company server, to make the project available to everyone in the company? Do I have to install python in the server? I tried to put the servers IPs in allowed_hosts but it doesn’t work.

Thanks for helping, Edward

Start with https://docs.djangoproject.com/en/4.1/howto/deployment/

You’ll have a number of decisions to make, and few of them are going to have obvious answers if you’ve never deployed a web application before. Be prepared to take the time needed to understand what needs to be done.

It has been said here and elsewhere that doing a production-quality deployment is one of the most difficult things you will ever do with Django.

2 Likes

Hey Ken, thanks for answering.

I will look at the docs and I hope it answers all my questions

Ken Whitesell via Django Forum <notifications@djangoproject.discoursemail.com> escreveu no dia sexta, 11/11/2022 à(s) 18:34:

I was able to make it work.
If i wanna to do changes in the django project, what are the best practices ?

There are no one set of “best practices”, just some general principles that would apply regardless of the framework or type of application.

All decisions regarding a specific approach need to be evaluated in the context of “risk”. You need to answer:

  • What’s the worst that can go wrong at any given point?
  • What is it going to take to recover from the worse-case scenario?
  • What is the effect on the business of an outage lasting for the “Time To Recover”?

I’ve got a handful of projects running the full range from “connect VSCode to the production server and make changes directly” to “every change requires multiple approvals at every step before deployment”. So it all depends on your business requirements - which may be affected both by business needs and policy.

1 Like

Ok, man.
Thanks for letting me know .

Ken Whitesell via Django Forum <notifications@djangoproject.discoursemail.com> escreveu no dia sexta, 18/11/2022 à(s) 12:54:

The solution I have is what I recently went through to be able to host my Django application on Windows Server 2022 Standard Version.

  1. Install Python on the server

  2. Download Cygwin and install on windows server

  1. Proceed to the Cygwin Setup - Select Packages window.

  2. Select Full in View.

  3. Enter gcc in Search.

  4. Find gcc-core row in Package column and change Skip to the required version.

  5. Enter g++ in Search.

  6. Find gcc-g++ row in Package column and change Skip to the required version.

  7. Proceed to the next step and install the packages.

  8. Then download uwsgi. Note: uwsgi is written for Linux, it does not run on Windows, hence you need to download Cygwin for Windows. It acts as a traslator for uwsgi on windows platform.

Step 1: Download the stable release and extract the tar file

Step 2: Open uwsgiconfig.py and import platform then replace os.uname()[index] with platform.uname()[index] because Windows does not understand os.uname()[index], it is Linux code.

Change

uwsgi_os = os.uname()[0]
uwsgi_os_k = re.split('[-+_]', os.uname()[2])[0]
uwsgi_os_v = os.uname()[3]
uwsgi_cpu = os.uname()[4]

To

import platform

uwsgi_os = platform.uname()[0]
uwsgi_os_k = re.split('[-+_]',  platform.uname()[2])[0]
uwsgi_os_v = platform.uname()[3]
uwsgi_cpu = platform.uname()[4]
  1. Open terminal of cygwin on the windows and cd to the folder where you extrated the uwsgi tar file.

Then run python setup.py install in the Cygwin terminal.
You can follow this youtube video How To Compile And Install uWSGI On Windows to complete the installation.

1 Like

Well Explained!
Thankss!!