Python Framework – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Thu, 05 Jan 2023 17:21:54 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How to Install and Use Flask on Debian 11/10 https://tecadmin.net/how-to-install-flask-on-debian/ https://tecadmin.net/how-to-install-flask-on-debian/#respond Thu, 05 Jan 2023 16:56:31 +0000 https://tecadmin.net/?p=33627 Flask is a microweb framework written in Python that is widely used for building web applications. It is a lightweight framework that does not require particular tools or libraries to be installed. Flask provides developers with the ability to add functionality to their applications through the use of libraries and modules. In this tutorial, we [...]

The post How to Install and Use Flask on Debian 11/10 appeared first on TecAdmin.

]]>
Flask is a microweb framework written in Python that is widely used for building web applications. It is a lightweight framework that does not require particular tools or libraries to be installed. Flask provides developers with the ability to add functionality to their applications through the use of libraries and modules.

In this tutorial, we will show you how to install Flask on Debian 11. Debian 11, also known as “Bullseye,” is the latest stable release of the Debian operating system. It is a free and open-source operating system that is widely used on servers and other systems.

Prerequisites

Before you start, make sure that you have Python and pip installed on your system. You can check if you have Python installed by running the following command:

python3 --version 

If you do not have Python installed, you can install it by running the following command:

sudo apt update 
sudo apt install python3 python3-pip python3-venv 

To check if you have pip installed, run the following command:

python3 --version 
pip3 --version 

Step 1: Installing Flask

Once you have Python and pip installed, you can install Flask system-wide by running the following command: `pip3 install flask`

But I recommended creating a virtual environment for your Flask application.

  1. Create a directory for your Flask application:
    mkdir flask-app && cd flask-app 
    
  2. Create the Python virtual environment.
    python3 -m venv venv 
    
  3. Activate the virtual environment:
    source venv/bin/activate 
    
  4. Install the Python Flask module within the virtual environment.
    pip3 install flask 
    

This will install the latest version of Flask and all the required dependencies under the virtual environment.

Step 2: Creating a Flask Application

Now that Flask is installed, you can create your first Flask application. Switch to the newly created application directory:

cd flask-app 

Next, create a file called `app.py` and add the following code to it:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run()

This code creates a simple Flask app that listens for incoming HTTP requests on the root path (/) and returns the message “Hello, World!”.

Step 3: Run Your Flask Application

To run the application, execute the following command:

flask run 

This will start the Flask development server and you will see the following output:

Output:
* Serving Flask app "app" * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Now, open your web browser and go to “http://127.0.0.1:5000/” to view your Flask app. You should see the message “Hello, World!” displayed on the page.

Conclusion

In this tutorial, you learned how to install and use Flask on Debian 11. You also learned how to create a simple Flask app and run it using the Flask development server. Flask is a powerful and easy-to-use web framework that makes it easy to build web applications with Python.

The post How to Install and Use Flask on Debian 11/10 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-flask-on-debian/feed/ 0
How to Install and Use Flask on Ubuntu 22.04 https://tecadmin.net/how-to-install-flask-on-ubuntu/ https://tecadmin.net/how-to-install-flask-on-ubuntu/#comments Sun, 01 Jan 2023 17:21:10 +0000 https://tecadmin.net/?p=33469 Python Flask is a lightweight Python web framework that makes it easy to build web applications quickly. It’s a microframework that doesn’t include an ORM (Object Relational Mapper) or such features and is instead extensible through Flask plug-ins. Flask is easy to get started with and doesn’t require any particular directory structure. A Flask application [...]

The post How to Install and Use Flask on Ubuntu 22.04 appeared first on TecAdmin.

]]>
Python Flask is a lightweight Python web framework that makes it easy to build web applications quickly. It’s a microframework that doesn’t include an ORM (Object Relational Mapper) or such features and is instead extensible through Flask plug-ins.

Flask is easy to get started with and doesn’t require any particular directory structure. A Flask application is a Python script that imports the Flask module creates an instance of the Flask class, and then start the development server using a line of code.

In this article, we’ll show you how to install Flask on Ubuntu 22.04. Also, create a simple Hello World application using the Flask Python module.

Step 1: Installing Python

Before you start, make sure you have Python and pip installed on your system. If you don’t have them already, you can install them by running the following commands:

sudo apt update 
sudo apt install python3 python3-pip python3-venv 

Step 2: Install Flask on Ubuntu

Once Python and pip are installed, you’re ready to install Flask. To do this, you’ll need to open a terminal and enter the following command: `pip3 install Flask`

But we recommend creating Python virtual environment to isolate your application. To do this create and/or switch to your flask application directory:

mkdir flask-app && cd flask-app 

Now, create and activate the virtual environment:

python3 -m venv venv
source venv/bin/activate

The above commands will create a directory with the name “venv” for storing virtual environment files. The second command will activate it. The system command prompt will be modified with the virtual environment name.

Once the virtual environment is activated, you can install Flask and other required Python modules.

pip3 install Flask 

This will install the latest version of Flask and all its dependencies. Once the installation is complete, you can verify that Flask is installed correctly by running the following command:

python3 -m flask --version 

If everything is working correctly, you should see the version number of Flask printed on the terminal.

Step 3: Create a Sample Flask Application

Once Flask is installed, you can start building your web application. To do this, create a new Python script and import the Flask module. Then, create a new Flask app using the following code:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run()

This code creates a simple Flask app that listens for requests at the root URL and returns the message “Hello, World!”. You can run this script by entering the following command:

python3 app.py 

This will start the Flask development server and listen for requests on port 5000. To access your application, open

Step 4: Finishing Your Work

You can create the `requirements.txt` file which is helpful for deploying applications on other systems. This file contains the Python modules required for your application.

pip freeze > requirements.txt

Once you finish your work with this project, You can simply deactivate the virtual environment by running the following command:

deactivate

Conclusion

In conclusion, installing Flask on Ubuntu 22.04 is a straightforward process that involves installing Python and pip, and then using pip to install Flask. Once Flask is installed, you can start building your web application by creating a new Python script and importing the Flask module. Then, create a new Flask app and start the development server using a line of code.

Flask is a lightweight and flexible web framework that is easy to get started with and doesn’t require any particular directory structure. It’s a good choice for small projects and prototyping, and it can be extended with a variety of third-party libraries to add additional functionality. With Flask installed, you’re now ready to start building your web applications on Ubuntu 22.04.

The post How to Install and Use Flask on Ubuntu 22.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-flask-on-ubuntu/feed/ 2
How to Dockerize a Flask Application https://tecadmin.net/how-to-create-and-run-a-flask-application-using-docker/ https://tecadmin.net/how-to-create-and-run-a-flask-application-using-docker/#respond Tue, 05 Jul 2022 05:27:29 +0000 https://tecadmin.net/?p=30363 In this tutorial, you will learn how to create a basic Flask app with Docker. You will set up your app with a Dockerfile, and manage the images with an automated build process. In this process, you’ll also learn how to use multiple Python virtual environments and keep your source code organized. If you’re new [...]

The post How to Dockerize a Flask Application appeared first on TecAdmin.

]]>
In this tutorial, you will learn how to create a basic Flask app with Docker. You will set up your app with a Dockerfile, and manage the images with an automated build process.

In this process, you’ll also learn how to use multiple Python virtual environments and keep your source code organized. If you’re new to Python or Flask, you may want to check out our beginner guide to Python as well as our beginner guide to Flask first. They cover the basics of these frameworks so that you can follow along better in this tutorial. Let’s get started!

What is Flask?

Flask is a lightweight Python framework for building web applications. It is simple, flexible, and pragmatic. It can be easily extended with the use of extensions and plug-ins. Flask can be used to create small websites or large-scale, complex applications.

Flask is used by companies like Pinterest, Twitter, Walmart, and Cisco. One of the common uses of Flask is for REST APIs that are used to interact with other systems. Applications written in Flask can also easily be deployed to a server or a cloud.

Create a Basic Flask Application

Before you can create a Docker image with your application, you have to have a basic app that you can run locally or on a server.

In this section, you will create a basic app with Flask and then run it in a Docker container. You can use your preferred editor to create the app, or you can use the following command in your terminal to create a new app:

  1. Let’s begin with creating a new directory:
    mkdir flask-app && flask-app 
    
  2. Next, create the Python virtual environment and then activate the environment.
    python3 -m venv venv 
    source venv/bin/activate 
    
  3. Now install the Flask python module under the virtual environment.
    pip install Flask 
    
  4. The below command will create the requirements.txt file with the installed packages under the current environment. This file is useful for installing module at deployments.
    pip freeze > requirements.txt 
    
  5. Now, create a sample Flask application.. You can write your code in a .py file and run it with the python command.
    vim app.py 
    

    Add the below snippt.

    # Import flask module
    from flask import Flask
    
    app = Flask(__name__)
    
    @app.route('/')
    def index():
        return 'Hello to Flask!'
    
    # main driver function
    if __name__ == "__main__":
        app.run()

  6. Your sample Flask application is ready. You can run this script with Python now.
    flask run --host 0.0.0.0 --port 5000 
    
    Running Flask App via CLI
    Running flask application at command line

Now that you have a basic app, you can run it in a Docker container by creating a file called Dockerfile in the same directory as your app.py file.

Create a Dockerfile for Your Flask Application

A Dockerfile is a file that contains instructions on how to build your image. It describes the entire process of building your image from the installation of your Python app to the creation of your container.

  1. Let’s create a file named Dockerfile under the project directory. This is the file docker reads instructions to build image.
    vim Dockerfile 
    

    Add the following code:

    FROM python:3-alpine
    
    # Create app directory
    WORKDIR /app
    
    # Install app dependencies
    COPY requirements.txt ./
    
    RUN pip install -r requirements.txt
    
    # Bundle app source
    COPY . .
    
    EXPOSE 5000
    CMD [ "flask", "run","--host","0.0.0.0","--port","5000"]
    

    Save the file and close it.

  2. Next, create the Docker image by running the below-mentioned command. Here “flask-app” is the image name.
    docker build -t flask-app . 
    
  3. This image will be created in local image registry. Then you can create a Docker container with the following command.
    sudo docker run -it -p 5000:5000 -d flask-app  
    
  4. Now, verify that container is running on your system.
    docker containers ls  
    

    Dockrise Flask Application

  5. Finally, open a browser and connect to localhost on port 5000 (or use your own defined port). You should see the flask application.

    Dockrise Flask Application

You can use a Dockerfile to automate the building and updating of your image. This is helpful if you’re working with a team and people are adding code to the same application.

Conclusion

In this tutorial, you learned how to create a basic Flask app and build a Docker image with it. You also learned how to create a private registry and automate the building and updating of your image. This is a great way to create reproducible builds and container images that are easy to share and deploy. This can be helpful if you need to set up servers or if you want to run your app on different machines.

The post How to Dockerize a Flask Application appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-create-and-run-a-flask-application-using-docker/feed/ 0
How to Install Django Framework in Ubuntu 20.04 https://tecadmin.net/how-to-install-django-on-ubuntu-20-04/ https://tecadmin.net/how-to-install-django-on-ubuntu-20-04/#comments Wed, 12 Aug 2020 10:38:49 +0000 https://tecadmin.net/?p=22275 Django is a Python Web framework that encourages the rapid development of applications. The Django framework is designed for developers to take applications from initial to completion as quickly as possible. It provides higher security for the application and avoids developers from making common security mistakes. This tutorial will help you to install the Django [...]

The post How to Install Django Framework in Ubuntu 20.04 appeared first on TecAdmin.

]]>
Django is a Python Web framework that encourages the rapid development of applications. The Django framework is designed for developers to take applications from initial to completion as quickly as possible. It provides higher security for the application and avoids developers from making common security mistakes.

This tutorial will help you to install the Django web framework in Ubuntu 20.04 Linux system. It will also help you to create a sample Django application. Let’s go through the tutorial:

Step 1 – Installing Python

Most of the latest operating systems come with default Python 3 installed. But if your system doesn’t have Python installed, Execute the below commands to install it. Also, install pip on your system.

sudo apt update -y 
sudo apt install python3 python3-pip -y 

The installed Python version is:

python3 -V 

Python 3.8.2

And pip version is:

pip3 -V 

pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

Step 2 – Installing Django Python Module

You can install Django either from source code available in Github repository or install it using PIP . In this tutorial, I use pip for the Django installation on Ubuntu 20.04 system. Run the below command from Linux terminal:

pip3 install Django 

You will get a django-admin command for creating new projects. Check the current installed version:

django-admin --version 

3.1

Step 3 – Create Django Application

First, navigate to the directory you need to create a new application. Then use django-admin startproject command followed by the application name to create a new Django application. Open a terminal on your system and type:

mkdir -p /var/www && cd /var/www 
django-admin startproject django_app 

After that migrate the pending changes.

cd django_app 
python3 manage.py migrate 

Django Migrate Data

Step 4 – Create Django Super Admin Account

Also, create a superuser account for the administration of the Django application. Run the following command from your Django application directory.

python3 manage.py createsuperuser 

Create superuser in django

Step 5 – Running Django Application

The Django application is ready to serve. By default, Django doesn’t allow external hosts to access the web interface. To allow external hosts, edit settings.py file and add IP under ALLOWED_HOSTS.

vi django_app/settings.py 

Add IP:

ALLOWED_HOSTS = ['192.168.1.239']

Here 192.168.1.239 is the IP address of the system where Django is installed.

Finally, run the Django application server with below command. Here 0.0.0.0:8000 defined that Django will listen on all interfaces on port 8000. You can change this port with any of your choices.

python3 manage.py runserver 0.0.0.0:8000 

Running Django Application

Django application server is running now. Open your favorite web browser and access to Django system ip on port 8000. This will show you the default Django web page.

http://192.168.1.239:8000

Django web interface

You can also access Django administrator page on /admin subdirectory url. Use your superuser login credentials created in the previous step to get access.

http://192.168.1.239:8000/admin

Django admin login

You will get the Django admin dashboard like below. You can add more users and groups for your application on dashboard.

Django admin dashboard on ubuntu 20.04

Conclusion

You have successfully created Django application on your system. Let’s start building your Django application.

The post How to Install Django Framework in Ubuntu 20.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-django-on-ubuntu-20-04/feed/ 2
How To Install Django on CentOS/RHEL 8 https://tecadmin.net/install-django-centos-8/ https://tecadmin.net/install-django-centos-8/#comments Fri, 14 Feb 2020 16:32:17 +0000 https://tecadmin.net/?p=19226 Django is a high-level Python Web framework for the rapid development of applications. It is developed by the Django Software Foundation in the year 2005. At the time of editing this tutorial, Django 3.0.3 is available for application development. This tutorial helps you to install and create a sample application with Django on CentOS 8 [...]

The post How To Install Django on CentOS/RHEL 8 appeared first on TecAdmin.

]]>
Django is a high-level Python Web framework for the rapid development of applications. It is developed by the Django Software Foundation in the year 2005. At the time of editing this tutorial, Django 3.0.3 is available for application development. This tutorial helps you to install and create a sample application with Django on CentOS 8 and RHEL 8 Linux systems.

Step 1 – Install Python

CentOS 8 minimal installation systems do not have default Python installed. You can install Python 3 on your CentOS 8 via default repository. Just execute the following commands to install Python and PIP on your system.

sudo dnf install python3 python3-pip

Then check the Python and pip version:

python3 -V

Python 3.6.8
pip3 -V

pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

Step 2 – Install Django on CentOS 8

Django source code is available in the Github repository. But this tutorial uses pip3 for the Django installation on CentOS 8 and RHEL 8 Linux. Simply run the following command from the system terminal:

pip3 install Django

You will get a django-admin command for creating new projects. Check the current installed verson:

django-admin --version

3.0.3

Step 3 – Create Django Application

You have Django installed on your system. Let’s create a new Django application. The django-admin command provides you the option to create a new Django application via command line. First, navigate to the directory you need to create a new application.

Then use the django-admin startproject command followed by the application name to create a new Django application on a Debian Linux.

cd /var/www
django-admin startproject django_app

After that migrate the pending changes.

cd django_app
python3 manage.py migrate

Step 4 – Create Admin User

Now, create a superuser account for the administration of the Django application. Run the following command from your Django application directory.

python3 manage.py createsuperuser

Step 5 – Run Django Application

A new Django application is ready to use. By default, Django doesn’t allow external hosts to access the web interface. To allow external hosts, edit settings.py file and add IP under ALLOWED_HOSTS.

vi django_app/settings.py

Add IP:

ALLOWED_HOSTS = ['192.168.1.239']

Here 192.168.1.239 is the IP address of the system where Django is installed.

Finally, run the Django application server with the below command. Here 0.0.0.0:8000 defined that Django will listen on all interfaces on port 8000. You can change this port with any of your choices.

python3 manage.py runserver 0.0.0.0:8000

running django on centos 8

Step 6 – Manage Firewalld

The system with an active firewall needs to open port to access Django over the network. Run the following commands to allow port 8000 for public users.

firewall-cmd --permanent --add-port=8000/tcp
firewall-cmd --reload

Step 7 – Access Django in Browser

The Django application server is running now. Open your favorite web browser and access to Django system IP on port 8000. This will show you the default Django web page.

http://192.168.1.239:8000

CentOS 8 install Django

Django also provides an administrative web interface. You can access this at /admin subdirectory URL of your Django application. Use superuser login credentials created in the previous step.

http://192.168.1.239:8000/admin

Installing django on CentOS 8

The Django admin dashboard looks like below. Here you can add more users and groups for your application.

Django Admin on CentOS 8

Conclusion

You have successfully installed Django and created a sample application on your CentOS 8 or RHEL 8 Linux system.

The post How To Install Django on CentOS/RHEL 8 appeared first on TecAdmin.

]]>
https://tecadmin.net/install-django-centos-8/feed/ 1
How To Create Django Application on Fedora 36/35 https://tecadmin.net/install-django-on-fedora/ https://tecadmin.net/install-django-on-fedora/#comments Fri, 30 Aug 2019 12:16:06 +0000 https://tecadmin.net/?p=19222 Have you been itching to get your hands on the latest versions of Django, but haven’t found an easy way to do it on Fedora? You aren’t alone! We know that there are tons of new users who are interested in technology like Django, and we want to help them get set up quickly with [...]

The post How To Create Django Application on Fedora 36/35 appeared first on TecAdmin.

]]>
Have you been itching to get your hands on the latest versions of Django, but haven’t found an easy way to do it on Fedora? You aren’t alone! We know that there are tons of new users who are interested in technology like Django, and we want to help them get set up quickly with the software they need.

This blog post will walk you through how to get started with your local testing environment for Django on Fedora.

Prerequisites: Basic knowledge of using a Linux terminal/command line and installation of software packages.
Objective: To setup the development environment for Django on Fedora

Step 1 – Installing Python

First, let’s make sure you have the latest versions of Python and Django installed. Open a terminal window, and start by updating your system:

sudo apt update && apt upgrade 

Fedora’s latest versions have already installed Python 3. The minimal installation systems may not have Python installed, Execute the below commands to install it. Also, install pip on your system.

sudo dnf install python3 python3-pip 

Once the installation is finished successfully, you can find the Python version with the python3 -V command.

Step 2 – Install Django on Fedora

Django source code is available as a Github repository. This tutorial uses pip3 for the Django installation on Fedora Linux. Simply execute the following command from the terminal:

pip3 install Django 

You will get a django-admin command, that is used to initialize new Django applications. To find the version of the django-admin command, type:

django-admin --version 

2.2.5

Step 3 – Create a New Django Application

Django has been installed on your system. Now we will create a new Django application. The django-admin command allows you to create a new Django application via the command line. First, navigate to the directory you need to create a new application.

Then use the django-admin startproject command followed by the application name to create a new Django application on Debian Linux.

cd /var/www 
django-admin startproject django_app 

This will create a django_app directory. Switch to that directory and run the migrations for the first time:

cd django_app 
python3 manage.py migrate 

Step 4 – Create Super Admin Account

Django provides a super admin panel for administering it. You need to create a super user account for the first time. Run the following command from your Django application to create an account.

python3 manage.py createsuperuser 

Setup django on Fedora

Step 5 – Run Django Application

A new Django application is ready to use. By default, Django doesn’t allow external hosts to access the web interface. To enable external hosts, edit the settings.py file and add IP under ALLOWED_HOSTS.

nano django_app/settings.py 

Add IP:

ALLOWED_HOSTS = ['192.168.1.239']

Here 192.168.1.239 is the IP address of the system where Django is installed.

Finally, run the Django application server with the below command. Here 0.0.0.0:8000 defined that Django will listen on all interfaces on port 8000. You can change this port with any of your choices.

python3 manage.py runserver 0.0.0.0:8000 

how to setup django on fedora

The Django application server is running now. Open your favorite web browser and access to Django system IP on port 8000. This will show you the default Django web page.

http://192.168.1.239:8000

Configure Django on Fedora

Django also provides an administrative web interface. You can access this at /admin subdirectory URL of your Django application. Use superuser login credentials created in the previous step.

http://192.168.1.239:8000/admin

Installing django on Fedora

The Django admin dashboard looks like the below. Here you can add more users and groups to your application.

Django Setup on Fedora

Conclusion

Django is one of the most popular frameworks for web development, and it’s easy to get started using it with Fedora. To get started, make sure you have the latest versions of Python and Django installed. Next, create a virtual environment for testing, and you can use the Live-reload Django app to make testing more efficient. Once you’re set-up, you can start building your next Django project. Now that you know how to get your own local testing environment set up, you can create your next Django project with ease.

The post How To Create Django Application on Fedora 36/35 appeared first on TecAdmin.

]]>
https://tecadmin.net/install-django-on-fedora/feed/ 1
How to Install Django on Debian Linux https://tecadmin.net/install-django-on-debian/ https://tecadmin.net/install-django-on-debian/#comments Wed, 03 Oct 2018 14:39:25 +0000 https://tecadmin.net/?p=17064 Django is a Python Web framework that encourages rapid development of applications. This tutorial helps you to install Django on Debian 10 Buster, Debian 9 Stretch system. After that create and run your first Django applications. Step 1 – Prerequsities The latest versions of operating systems come with default Python 3 installed. The minimal installation [...]

The post How to Install Django on Debian Linux appeared first on TecAdmin.

]]>
Django is a Python Web framework that encourages rapid development of applications. This tutorial helps you to install Django on Debian 10 Buster, Debian 9 Stretch system. After that create and run your first Django applications.

Step 1 – Prerequsities

The latest versions of operating systems come with default Python 3 installed. The minimal installation systems may not have Python installed, Execute the below commands to install it. Also, install pip on your system.

sudo apt-get install python3 python3-pip

Then check the Python and pip version:

python3 -V

Python 3.5.3
pip3 -V

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)

Step 2 – Install Django on Debian

Django source code is available as a Github repository. You can also use pip to install Django on Debian 9 systems. In this tutorial, I use pip3 for the Django installation on Ubuntu. Run the below command from Linux terminal:

pip3 install Django

You will get a django-admin command for creating new projects. Check the current installed verson:

django-admin --version

2.1.2

Step 3 – Create Django Application

The django-admin command provides you the option to create a new Django application via command line. First, navigate to the directory you need to create a new application.

Then use the django-admin startproject command followed by the application name to create a new Django application on a Debian Linux.

cd /var/www
django-admin startproject django_app

After that migrate the pending changes.

cd django_app
python3 manage.py migrate

Django on Debian

Step 4 – Create Super Admin Account

Also, create a superuser account for the administration of the Django application. Run the following command from your Django application directory.

python3 manage.py createsuperuser

Django create user on Debian

Make sure all the migrations completed successfully. Once done, go to the next step.

Step 5 – Run Django Application

Your Django application is ready to use. By default, Django doesn’t allow external hosts to access the web interface. To allow external hosts, edit settings.py file and add IP under ALLOWED_HOSTS.

vi django_app/settings.py

Add IP:

ALLOWED_HOSTS = ['192.168.1.239']

Here 192.168.1.239 is the IP address of the system where Django is installed.

Finally, run the Django application server with the below command. Here 0.0.0.0:8000 defined that Django will listen on all interfaces on port 8000. You can change this port with any of your choices.

python3 manage.py runserver 0.0.0.0:8000

Run Django on Debian

The Django application server is running now. Open your favorite web browser and access to Django system IP on port 8000. This will show you the default Django web page.

http://192.168.1.239:8000

Django Setup on Debian

Django also provides an administrative web interface. You can access this at /admin subdirectory URL of your Django application. Use superuser login credentials created in the previous step.

http://192.168.1.239:8000/admin

Debian Dejango Admin

The Django admin dashboard looks like below. Here you can add more users and groups for your application.

Django on Debian

The post How to Install Django on Debian Linux appeared first on TecAdmin.

]]>
https://tecadmin.net/install-django-on-debian/feed/ 5