How to run multiple Django apps in production at the same Apache server

I have a practical problem - I'm building a web site, but I have one app already running in production for the site. So I need to take care that I don't lose the data in my app and make sure that 2 apps work together.

Configuration
-Debian 11
-Apache2 2.4
  

Working the process out locally

  
It's good to try out things locally first and only after that works, apply the changes to a production environment. So, in order to do that I copied my soon-to-be-implemented app from my dev location to my website's project folder.  
     

cp shopping/shopping/list/ /home/kallet /kalletolonencom/ktcom/

  
After that was done, it was time to add the app to settings and run the migrations.     

micro settings.py

     

#settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'mainsite',
    'markdownx',
    'list', #added my app
]

  
After trying out the url for my app I had an error message that guided me towards urls.py.      

 Using the URLconf defined in ktcom.urls, Django tried these URL patterns, in this order: 

     
I modified urls.py.   

from django.conf.urls import include, url #added this

#SHOPPINGLIST
    url('', include('list.urls')), #and this

  
After that I ended up with a great error message that pointed me to list/urls.py, to where I just copied my old urls from that project's urls.py.   

ModuleNotFoundError: No module named 'list.urls'

  
The only error left was the one that complained about the admin namespace, since my project already had an admin path.     

?: (urls.W005) URL namespace 'admin' isn't unique. You may not be able to reverse all URLs in this namespace

  
So naturally I removed that from my list-app and tested the functionality.   

Locally proved concept - many django apps in service
Running multiple apps locally

     

Production install & changing the DBMS to a better one

  
You can read my article on this process here and apply it to your project.   
While doing the production DBMS update I ran into some challenges and the error message that led me to a working solution was:     

Could not load contenttypes.ContentType(pk=7): duplicate key value violates unique constraint

  
The thing to notice is that you should exclude some things from your data dump, I found a nice answer on this source on the parameters.   
./manage.py dumpdata --exclude auth.permission --exclude contenttypes > db.json

  

All articles


Comments

No published comments yet.


Add a Comment

Your comment is held for review before it appears publicly.

Your email is never published or shared.

Up to 2,000 characters.

Tick the box, then click Submit right away (Google expires the check after about two minutes).