Qrrie Project Steps


Instructions

  1. create a new repository
  2. clone repository to local machine
  3. open repo in vscode
  4. define requirements

    django
    pillow
    qrcode[PIL]    
    uvicorn
    dotenv
    
  5. install requirements

    1. type ctrl+shift+p
    2. type install environment and select "Python: Create Environment"
    3. select your project folder in the top bar, if asked
    4. select "quick create"
    5. wait for install to complete
  6. right click on requirements.txt in project explorer and select "open in integrated terminal"
  7. type the following:

    django-admin startproject qrrie
    cd qrrie
    python3 manage.py startapp qr
    
  8. create django secret key:

    KEY=$(python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())')
    echo "DJANGO_SECRET_KEY='$KEY'">>my_env.env
    
  9. add my_env.env to ignore list

    echo "*.env" >> .gitignore

  10. edit qrrie/qrrie/settings.py

    1. import os. At the top of the file, just below from pathlib import Path, add the following:

      import os
      
    2. comment out temp secret key and add environment-based secret key

      SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY')
      
    3. Update timezone

      #TIME_ZONE = 'UTC'
      TIME_ZONE = 'America/Los_Angeles'
      
    4. add qrrie app to INSTALLED_APPS:

      INSTALLED_APPS = [W
          'django.contrib.admin',
          'django.contrib.auth',
          'django.contrib.contenttypes',
          'django.contrib.sessions',
          'django.contrib.messages',
          'django.contrib.staticfiles',
          'qr.apps.QrConfig',
      ]
      
    5. add APPEND_SLASH

      APPEND_SLASH = True
      
  11. edit qrrie/qrrie/urls.py. Modify the code so it matches the following:

    python3 manage.py runserver 0.0.0.0:8000
    
  12. create run script

    cat << EOF | tee run
    #!/usr/bin/bash
    source my_env.env
    python3 qrrie/manage.py runserver 0.0.0.0:8000
    EOF
    chmod +x run
    
    ./run
    
  13. Create superuser. Type the following in bash:

    python manage.py createsuperuser
    

    and follow interactive instructions

Contents

About

I am an engineer and educator, having spent ten years as a professor. My goal is to help you build your knowledge of design and technology, get your hardware working, and propel your startup or small business. Get in touch!

Read More