Coder Social home page Coder Social logo

djangotutorial's People

Contributors

spianodev avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

vivirbi

djangotutorial's Issues

Quick Checklist for Django/Python Application Build

Setup

  • Make a directory for the project
  • Install python3 and virtual environment with brew install python pipenv
  • Run pipenv install django and pipenv install psycopg2-binary to create django application with PostgreSQL
  • Run pipenv run django-admin startproject <project name> . to initialize the project
  • Start the virtual environment with pipenv shell
  • Create the application inside the project with django-admin startapp <application name>
  • Open PostgreSQL with psql -d postgres
  • Create the database, user, password, and privileges for the application
  • Update settings.py to reflect the current database
  • python3 manage.py runserver to check everything has been installed correctly!

Models & Admin

  • Make Models in models.py with Primary Key and Foreign Key Relationships
  • Run python3 manage.py makemigrations to connect the Models to the database
  • Run python3 manage.py migrate to copy the data over
  • Create a superuser for the admin panel python3 manage.py createsuperuser
  • Register the Models in admin.py
  • Visit localhost to populate local database

CRUD in Django views

  • Import Models in views.py
  • Create python methods for list, detail, create, update, and delete
  • Add urls.py to the Application directory
  • Create urlpatterns paths for all python methods
  • Add forms.py to the Application directory and create ModelForms
  • Add templates to the Application directory
  • Create html pages for base along with list, detail, and form for each Model
  • Add the includes path to urls.py in the Project directory
  • Update all html pages to display data from the database
  • Connect Stylesheet and add CSS to Django views

Deploy

  • Install dependencies pipenv install django-cors-headers gunicorn whitenoise dj-database-url django-heroku python-decouple
  • Create requirements.txt from virtual environment by running pip freeze > requirements.txt
  • Create Procfile in the Root directory and add web: gunicorn <project name>.wsgi to it
  • Add cors and adjust the secret_key in settings.py
  • Run heroku create honeydo-app to create the Heroku copy of your application
  • Run heroku addons:create heroku-postgresql:hobby-dev to connect the database
  • Upload to Heroku git push heroku master
  • Migrate the database to Heroku heroku run python manage.py migrate
  • Open the application! heroku open

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.