hackathon-mexico-city

Project Objective

We will build a dynamic, responsive web-based app using Github, Cookie Cutter, Python, Django, Bootstrap, ColorlibHQ and Heroku. The app will be dynamic, because the html pages will be generated by Python modules that we will create. The app will be Responsive by leverage a popular CSS library named Bootstrap.

Moreover, we will create high-quality Python code quickly by leveraging a coding framework named Dango, and, we'll also leverage a prebuilt Bootstrap UI named Gentelella.

Project objective

Technology Stack

Generic Web App

Stack

  • browser: html, css, js, media

    • html: content / structure
    • css: appearance
    • js: browser automation
    • media: images, video, music, etc.
  • server side: data storage, program automation

    • linux: file system, ssh, http
    • mysql
    • nginx
    • python

Django MVC (Model-View-Template aka "Model-View-Controller")

Django MVC

Django helps us to quickly and elegantly resolve several difficult web development problems:

  • How to map URL routes to Python program code
  • How to convert Python code into HTML web pages
  • How to manage program parameters
  • How to make HTML web pages data-driven and dynamic

setup local development environment

VS Code Github account Heroku account

Option I: Python Anywhere

Technology Source
Python Anywhere https://www.pythonanywhere.com/

Option II: Local

Technology Source
Homebrew https://brew.sh/
Git N/A
Python https://evansdianga.com/install-pip-osx/
Pip https://bootstrap.pypa.io/get-pip.py
VirtualEnv pip3 install virtualenv
Django pip install Django==2.2.7

Option III: AWS

same as above, but on Ubuntu 16.04 LTS

setup project

#1. Create virtual environment
python3 -m venv venv
source venv/bin/activate

#2. Postgres installation (optional):
postgres -V

# if you see a version response then try to login to psql
psql postgres

# otherwise you need to install Postgres
https://www.codementor.io/engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb
brew install postgresql
brew postgresql-upgrade-database
brew services start postgresql

#Postgres log: /usr/local/var/log/postgres.log

# Create a Postgres user for your project
psql postgres
# to list existing users
\du

CREATE ROLE hackathon WITH LOGIN PASSWORD 'hackathon'

#3. create new project w cookie cutter
pip install "cookiecutter>=1.4.0"
cookiecutter https://github.com/pydanny/cookiecutter-django

#4. install Django
cd hackathon
pip install Django
pip install -r requirements/local.txt
pre-commit install
createdb hackathon
createdb hackathon -U postgres --password <password>
 * if this is the first time a database is created on your machine you might need an initial PostgreSQL set up to allow local connections & set a password for the postgres user. The postgres documentation explains the syntax of the config file that you need to change.

# make necesary edits to hackathon/config/settings/local.py
#DATABASES = {
#    'default': {
#        'ENGINE': 'django.db.backends.postgresql',
#        'NAME': 'hackathon',
#        'USER': 'hackathon',
#        'PASSWORD': 'hackathon',
#        'HOST': '127.0.0.1',
#        'PORT': '5432',
#    }
#}

./manage.py makemigrations
  • GO TO WORK!!

Deploy to Heroku