How can I have/setup two projects/App

Hi, I am a novice with Django

I have created a nice project (Dajngo App) that I have to improve but I need to start a new one. I also got a new macbook and I to reconfigure my first project and be ready to create the new one.

I am used to have a folder /Dev/ which contain the framework/language

/Dev/Python
/Dev/ReactNative
/Dev/Arduino
/Dev/Django

Then, I would like to have

/Dev/Django/project1
/Dev/Django/project2

I read my notes about how I installed Django on my previous Mac and I think I have to do a bit different to host to project (two different Dajngo web application)

My idea would be the following. Could you validate?

cd /Documents/Dev/Django
python3 -m venv .env # Create an environement named .env source .env/bin/activate # Activate your environment
(.env) pip3 install mysqlclient
(.env) pip3 install django==4.1.4 (.env) python3 -m django --version
(.env) pip3 install -r requirements.txt # Install packages listed in the requirements file (.env) pip3 freeze > requirements.txt

the requirement.txt contain

asgiref==3.6.0
sqlparse==0.4.3
django==4.1.4
djangorestframework==3.14.0
djangorestframework-gis==1
django-filter==22.1.0
djangorestframework-simplejwt==5.2.2

I am confuse from this point

My two different Django web app and named ‘map’ and ‘ged’.

If I continue reading my note, I did the following. I created a project console and an app map

(.env) django-admin startproject console
(.env) cd console
(.env) ./manage.py startapp map

How should I do for my two Django/web app?

Form /Documents/Dev/Django, should I run

(.env) django-admin startproject map
(.env) cd map
(.env) ./manage.py startapp map

and

(.env) django-admin startproject ged
(.env) cd ged
(.env) ./manage.py startapp ged

or should I run from /Documents/Dev/Django/

(.env) django-admin startproject applications
(.env) cd applications
(.env) ./manage.py startapp map
(.env) ./manage.py startapp ged

I am confuse about the best pratice, because the two web app are two different projects. Both have no common points.

I have an additional quetsion?

Which local server/Database for Django, are you using on a Macbook Pro?

  • MAMP?
  • XMAP?
  • Something else?

Many thanks for your help and clarification, and happy Christmas and new year!!!

That’s fine.

You can do:

cd /Dev/Django
django-admin startproject project1
cd project1
./manage.py startapp map
cd /Dev/Django
django-admin startproject project2
cd project2
./manage.py startapp ged

Or, if you want the project to be inside the project1 and project2 directories, you can create the projects inside those directories.

As long as the two project directories are independant, it pretty much doesn’t matter where they reside.

I

I don’t use a Macbook Pro, but I do some development work on a Macbook Air. When I do, I use nginx (homebrew), gunicorn, and PostgreSQL.

To provide another example, I sometimes just use the default SQLite, for a quick/simple Django project.

Or if I need PostgreSQL then I use Docker to run it in a container.

These days I run the Django site itself using its built in dev server (manage.py runserver) which is good enough for me.

There are lots of options!

Hi thanks for your replies.

I do not understand the difference between project and application in “Django” as for me is the same. I create a new Application for a need, it’s a new projcect.

So, with Django you may have 2-3 common application for the same project? or a project can be client which need several Application?

Any way, I will do

cd /Dev/Django
django-admin startproject project1
cd project1
./manage.py startapp map
cd /Dev/Django
django-admin startproject project2
cd project2
./manage.py startapp ged

which is fine as long as a good practice :slight_smile:

May I develop the DB topics?

I do not have a lot experience with Docker, but I am very interrested. I have a Synology NAS to host InvoceNinja (Which a web app to manage invoice and offer…). I first installed with Docker but it never work (May be because of a few Docker experience… :slight_smile: ). I finally installed on a Ubuntu VM on my NAS.

I recently tried to insall my GED (which is build with Django) on my NAS (with 6G of RAM) with Docker, but it never work because my VM use to much RAM (4G).

I was used to develop web app with PHP or with different CMS, and I use MAMP.
I make a big mistake. When my previous laptop crash and I need to reinstalled from crash, I missed to backup my DB for my first Django App. It’s not a big issue as it was an exercise and I can start from the begining. That DB was with MySQL/phpmysql and manage by MAMP.

May I be, I could install Docker on my new MacBook (I have really enough memory :slight_smile: ), and to have two containers, one for my first Django App and the second for my GED Dejango App? Or a conatiner for both Django App with PostgreSQL?

And continue working as I ma used to with MAMP and MySQL?

I am curious is to know how you would do and there is better than MAMP, and which will be compliant with Django and Nodes.js (I also develop iOS/Android app)

Happy Crhistams

It’s an issue of the terminology that Django uses. An “App” is a Django-specific term, referencing a functional component. A “Project” is (generally) a website that might be composed of multiple “Apps”.

See Applications | Django documentation | Django for more details on this.

For example, if you work through the Django polls tutorial, you’re creating a site that is using two apps, polls and admin. (Yes, the Django admin is “just” an app.)

I used to work on a Project (website) that was composed of multiple apps - a timesheet recording app, a work allocation app, a reporting app, and a couple others. In general terms, you might think of them as “modules”, but in Django terms, they’re apps - all running as part of the same project.

For the most part, where you create your project directories is irrelevent during development. It’s not “good practice” nor is it “bad practice”, it’s simply what you do. The project directories are completely independant of each other. There’s no need for an association or relationship between the two.

Maybe someone else will jump into the thread because you’re getting into areas outside my expertise.

  • I don’t use docker either for development nor for deployment of my personal projects. (We use docker at my former employer, but for my personal projects, I find no benefit. I know others that have the opposite opinion, and I’m happy that it works for them.)
  • I don’t deploy on a Mac. All my deployments are on Linux systems, using nginx, uwsgi, daphne, redis, postgres, and sometimes haproxy. (And, of course, Python and Django)
  • I gave up on Apache httpd more than 10 years ago now, and have never looked back - which means I personally wouldn’t consider MAMP as viable. (Again, a personal opinion that acknowledges other opinions as also being valid.)
  • I don’t use MySQL with Django. Its quirks and oddities are more than I care to deal with. I do use Sqlite as my production database in some limited situations.
  • nginx is capable of proxying connections to node.js just as well as to Django.

Hello KenWhitesell

Many thanks for your feedback. I suppose that a project can have the same name as an application

/Dev/Django/map
/Dev/Django/ged

cd /Dev/Django
django-admin startproject map
cd map
./manage.py startapp map
cd /Dev/Django
django-admin startproject ged
cd ged
./manage.py startapp ged

May be a good reason to have a second App in a project, would be if I want to work with API, which would be requested by SamrtPhone

/Dev/Django/map/map
/Dev/Django/map/api

I am going to think about MAMP. For now, I do not have another option for Mac and it has been working until I change of Laptop, I may continue using. My worries and as I am reinstalling all, is to make better for the new setup :slight_smile:

Thanks

This is possible, but potentially confusing and not recommended.

Why? Because when you create a project, Django creates a directory inside the project directory by the same name as the project.

When following the tutorial, when you create the mysite project, you end up with a directory named mysite and a directory named mysite inside that first mysite directory. This inner mysite directory contains some project-level files such as the settings and root urls.py.

If you then create an app named mysite it would be using that same directory both for the project level files and the app-specific files.

Again, potentially confusing. I don’t recommend doing this. (You can rename that project directory to be something else - there are other comments here in the forum about that. But you really don’t want to use the same directory for both purposes.

Of course, that make sense.

I believe, I am going to do as the following:I have create a web app to show the position of weather station and charts Console
With the goal to learn with Django, I recreate that web app.
My project name was ‘console’ and my app name was ‘map’
As now I also create a IOS App (later a Android) name IoT Chart with a admin part to manage the chart, on my new laptop, I will dor the following

/Documents/Dev/Djengo/

brew install mysql-client
python3 -m venv .env        # Create an environement named .env
source .env/bin/activate    # Activate your environment
(.env) pip3 install mysqlclient
(.env) pip3 install django==4.1.4 #( I will change to the latest)
(.env) pip3 install -r requirements.txt
(.env) pip3 freeze > requirements.txt

Then I create my first project

(.env) django-admin startproject iot-chart
(.env) cd iot-chart
(.env) ./manage.py startapp map # Main application
(.env) ./manage.py startapp admin # Later, I will add the option to manage the chart, as I did for the SmartPhones

Then I will go to /Documents/Django/iot-chart/iot-chart/settings.py to setup the database settings, as map and admin need the same database

The challenge now is for my second project/App, because I would likte to install paperless-ngx which is build with Django. I found this help Self Host with IPv6rs - IPv6 Provider - How to Install Paperless-ngx on macOS

My idea would be from /Documents/Django/

(.env) django-admin startproject edm # or ged
(.env) cd emd
(.env) ./manage.py startapp paperlesss # Main application

However, I am not sure that the tuto is reliable at 100% as the requirement.txt is not available and it also create the .env into the colned folder ‘paperless’

cd paperless
python3 -m venv venv

It does not look properly. Additonally, I planed the buy a Barbone Asus PC with Ubutnu 100% dedicated for paperless-ngx.

So as long as my way to create my first project, I am happy. If later, I will create a new Django App according to

cd /Documents/Dev/Django
source .env/bin/activate    # Activate your environment
(.env) django-admin startproject new_project
(.env) cd new_project
(.env) ./manage.py startapp new_app

and If I need new requirement for my new project/app, I will add new line my ‘requirements.txt’

As long as I properly create my first project and I plan future projects, and I am very happy

Happy new year and merry Christmas