• SupportTutorial
  • How to deploy your python project using python manager (django)

Our test project: https://github.com/liangliangyy/DjangoBlog

panel: aaPanel

1. Go to the directory where you will store the code

`cd /www/python/flask`

2. Run the git clone command on your terminal to get the project

git clone https://github.com/liangliangyy/DjangoBlog.git

3. Install the python version your project needs

4.Start adding python projects

Parameter Description:

  • Name: Give your project a name
  • Path: Select the root directory of the project
  • Version: Choose the python version your project needs
  • Framework: The project project framework, my project here is Flask, so choose django
  • Startup Mode: Choose gunicorn here, You can switch other options according to your needs.
  • Startuo file/dir: In general, diango selects the project directory to start, and flask selects the py file to start.
  • Install module now: When adding a project, install the required modules according to the documentation of the project root directory requirements.txt.

When we finish project creation, we can’t open the project normally.We need to initialize the project

5. According to the project requirements, we first create the databases and modify the project database configuration.

create a database:

6.modify the project database configuration

The default database configuration is to get the database account and other information from the environment variables, we refer to the installation tutorial to remove the os.environ.get method

Go into the project’s virtual environment and execute the following command

Go into the project’s virtual environment:
source /www/python/DjangoBlog/django_blog_venv/bin/activate

Now execute the following command :

cd /www/python/DjangoBlog/ #your project dir
./manage.py makemigrations
./manage.py migrate

Create the SuperAdmin:
./manage.py createsuperuser
Create test data:
./manage.py create_testdata
Collect static files:

./manage.py collectstatic --noinput
./manage.py compress --force

Now we can access our blog using http://192.168.1.199:8099

4 months later
3 months later
3 months later

satya876

You may need to set a separate location to access the static directory,

location /static{

    root /root/workpace/webapp;

}
    4 months later

    Hi!! I managed to install everything and be able to upload my project to my panel. I did the migration of the tables to the database everything perfect. I run the server and everything is fine ... but when I close the console the page falls. How do I get the python manage.py runserver running?

    satya876 If you have the static route declared in the setting, you just have to run this command in console and put yes. Greetings

    python manage.py collectstatic

    3 months later
    8 months later

    adilhami please check if DEBUG is true? When I configure debug as false, this happen with me too.

    a month later
    3 months later
    2 months later

    @aaPanel_Jose
    source /www/python/DjangoBlog/django_blog_venv/bin/activate
    not available now in bin dont contain activate file
    Second issues
    django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
    Did you install mysqlclient?

    a month later

    Please, update your tutorial.

    There is problem with activating venv because there is no "activate" binary/executable in path - project_path/project_name_md5_venv/bin/
    for me -

    /www/wwwroot/DjangoBlog/098f6bcd4621d373cade4e832627b4f6_venv/bin# pwd
    /www/wwwroot/DjangoBlog/098f6bcd4621d373cade4e832627b4f6_venv/bin
    /www/wwwroot/DjangoBlog/098f6bcd4621d373cade4e832627b4f6_venv/bin# ls -las
    total 70508
    4 drwxr-xr-x 3 root root 4096 Apr 26 10:55 .
    4 drwxr-xr-x 6 www www 4096 Apr 26 10:28 ..
    4 -rwxr-xr-x 1 root root 134 Apr 26 10:26 2to3
    4 -rwxr-xr-x 1 root root 134 Apr 26 10:26 2to3-3.10
    4 drwxr-xr-x 2 root root 4096 Apr 26 10:29 pycache
    148 -rwxr-xr-x 1 root root 150619 Apr 26 10:29 bottle.py
    4 -rwxr-xr-x 1 root root 272 Apr 26 10:28 coverage
    4 -rwxr-xr-x 1 root root 272 Apr 26 10:28 coverage-3.10
    4 -rwxr-xr-x 1 root root 272 Apr 26 10:28 coverage3
    4 -rwxr-xr-x 1 root root 320 Apr 26 10:28 django-admin
    4 -rwxr-xr-x 1 root root 274 Apr 26 10:29 gunicorn
    4 -rwxr-xr-x 1 root root 132 Apr 26 10:26 idle3
    4 -rwxr-xr-x 1 root root 132 Apr 26 10:26 idle3.10
    4 -rwxr-xr-x 1 root root 271 Apr 26 10:29 markdown_py
    4 -rwxr-xr-x 1 root root 301 Apr 26 10:29 normalizer
    4 -rwxr-xr-x 1 root root 278 Apr 26 10:28 pip
    4 -rwxr-xr-x 1 root root 278 Apr 26 10:28 pip3
    4 -rwxr-xr-x 1 root root 278 Apr 26 10:28 pip3.10
    4 -rwxr-xr-x 1 root root 117 Apr 26 10:26 pydoc3
    4 -rwxr-xr-x 1 root root 117 Apr 26 10:26 pydoc3.10
    4 -rwxr-xr-x 1 root root 272 Apr 26 10:29 pygmentize
    0 lrwxrwxrwx 1 root root 7 Apr 26 10:55 python -> python3
    23416 -rwxr-xr-x 1 root root 23976536 Apr 26 10:25 python3
    4 -rwxr-xr-x 1 root root 3122 Apr 26 10:26 python3-config
    23420 -rwxr-xr-x 1 root root 23976536 Apr 26 10:25 python3.10
    4 -rwxr-xr-x 1 root root 3122 Apr 26 10:26 python3.10-config
    23420 -rwxr-xr-x 1 root root 23976536 Apr 26 10:55 python3.bak
    4 -rwxr-xr-x 1 root root 276 Apr 26 10:29 raven
    4 -rwxr-xr-x 1 root root 273 Apr 26 10:28 sqlformat
    4 -rwxr-xr-x 1 root root 265 Apr 26 10:28 wheel

    I tried and found activate script in -
    ./098f6bcd4621d373cade4e832627b4f6_venv/lib/python3.10/venv/scripts/common/activate

    but it looks like template cuz activating it result with -
    VENV_PROMPTroot@cv-9060:/www/wwwroot/DjangoBlog#

    and even if venv path is exported to PATH var there is problem right after first command "./manage.py makemigrations" -
    EOFError: marshal data too short

    I tried with 3.9.7 and 3.10 python, no luck.

    All in all your panel is good for casual users, but these inconsistencies are really holding aapanel back for users who do not use only PHP/static sites.

    How can I restart my Django app without using aaPanel web admin?

    For example, in Cpanel I just need to run touch django-app/tmp/restart

    3 months later

    Mal function.

    The command "source......./activate" doesnt anything

    Please help

    I dont noy how to deploy a django project in aapanel

    Thanks

      Connect with us: 📨 Telegram 💬 Discord Email: support@aapanel.com