Giter Club home page Giter Club logo

django-appinsight-opencensus's Introduction

Sample Django Web App

SQLite database

Database is configured to be stored in system temp directory:

  • use TMP environment variable if not empty
  • otherwise use TEMP environment variables if not empty
  • otherwise use /tmp directory as default.

Development Setup

Step 1. Configure development environment

Create .dev directory. The directory is used for developer artifacts. A rule in the .gitignore instructs git to ignore the .dev directory.

Create a file .dev/setenv.sh which initializes the environment variables, used by the app. A rule in the .gitignore instructs git to ignore the .dev directory.

export DJANGO_SECRET_KEY='DjangoSecretKey'
export APPINSIGHTS_INSTRUMENTATION_KEY='<instrumentation-key>'

Update the environment, using the .dev/setnenv.sh:

$ source .dev/setenv.sh

Step 2. Create Python Virtual Environment

$ py -3.8 -m venv .venv38
$ source .venv38/Scripts/activate

Step 3. Install Python Dependencies

$ pip install -r requirements.txt

Step 4. Initialize Django Database

$ python manage.py makemigrations
$ python manage.py migrate

Step 5. Run Django web server

$ python manage.py runserver

Highlights

Endpoints:

  • /dt - shows current date time Purpose: See in App Insights
  • /exc - throws unhandled exception Purpose: See how it is logged in App Insights

Custom Azure App Service Startup Command

python manage.py makemigrations; python manage.py migrate; GUNICORN_CMD_ARGS="--timeout 600 --access-logfile '-' --error-logfile '-' --bind=0.0.0.0:8000" gunicorn mysite.wsgi

Create superuser from shell

echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', '[email protected]', 'password')" | python manage.py shell


As of Django 3.0 you can use default createsuperuser --noinput command and set all required fields (including password) as environment variables DJANGO_SUPERUSER_PASSWORD, DJANGO_SUPERUSER_USERNAME, DJANGO_SUPERUSER_EMAIL for example. --noinput flag is required.

DJANGO_SUPERUSER_PASSWORD=password; python manage.py createsuperuser --noinput --username admin --email [email protected]; 

Reference

django-appinsight-opencensus's People

Contributors

ivangeorgiev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.