Integrate Django and Vue Projects

Installing django using pip (make sure nodejs is installed)

Now we install Vue Installing the app (for example frontend) inside the django project directory (where manage.py exists) and run: Start Vue developement Server Install required packages for dango and Vue For Vue, in frontend directory run: Now, we need to change some settings:
  1. in the frontend folder, create a file named "vue.config.js"
Paste the following minimal configuration settings: module.exports = { publicPath: "http://0.0.0.0:8080", outputDir: "./dist/", chainWebpack: config => { config.optimization.splitChunks(false) config.plugin('BundleTracker').use(BundleTracker, [ { filename: './webpack-stats.json' } ]) config.resolve.alias.set('__STATIC__', 'static') config.devServer .public('http://0.0.0.0:8080') .host('0.0.0.0') .port(8080) .hotOnly(true) .watchOptions({poll: 1000}) .https(false) .headers({'Access-Control-Allow-Origin': ['\*']}) } ``` For django: 1- Install django-webpackloader 2 Apped to the intalled app list in the django settings 3- Copy and paste the default minimal configuration from the webpack github page

Tags: django, web developement, Vue

amir's profile picture

amir

Django collectstatic does not collect the static folders within each app

The static folders within the apps should have similar structure: myapp/static/myapp/css/...

Tags: django

amir's profile picture

amir

Read the last 10 lines of a service log

sudo journalctl -u example.service -n 10

Tags: linux

amir's profile picture

amir

Make nginx available website, enable

sudo ln -s /etc/nginx/sites-available/example /etc/nginx/sites-enabled/ sudo systemctl restart nginx

Tags: nginx, web developement

amir's profile picture

amir

Register SSL for when using Nginx

Step 1: Install Certbot sudo apt update\ sudo apt install certbot python3-certbot-nginx Step 2: Obtain and Install SSL Certificate sudo certbot --nginx -d example.com -d www.example.com Step 3: Verify Auto-Renewal Let's Encrypt certificates are valid for 90 days. Certbot should automatically set up a task to renew the certificates before they expire. To test the renewal process, you can run:\ sudo certbot renew --dry-run And/or check if a systemd timer exists: systemctl list-timers | grep certbot

Tags: nginx, web developement

amir's profile picture

amir