App based on Python Django web Framework
- Blog
- create virtual env (windows):
python -m venv env
- activate env:
.\env\Scripts\activate
- install requirement:
pip install -r requirements.txt
- create super user:
python manage.py createsuperuser
- do migrations:
python manage.py migrate
- run app:
python manage.py runserver
- enter db shell: ```python manage.py dbshell``
- if command doesn't work, make sure sqlie3 exe in path var: https://www.sqlite.org/download.html
- commands
- to see tables:
.tables
- see schema:
.schema tablename
- to see tables:
- Setup basic Django project
- add basic blog
- add CRUD features
- add favorite star icon to turn on/off
- add tasks model
- add search feature
- add pagination
- add ckeditor for rich text editing
pip install django-ckeditor
- requires migration after changes and add to settings.py under INSTALLED_APPS
- add RichTextField to forms
- try crispy forms
- add tests - https://docs.djangoproject.com/en/3.1/internals/contributing/writing-code/unit-tests/
- containerized app with docker/docker-compose
- use github actions
.github\workflows\python-app.yml
- added build status icon
- made changes to work with both locally and in github actions
- blog tests:
python manage.py test blog
- pytest
- build :
docker build --tag python-django .
- run:
docker run --name djangoapp --publish 8000:8000 python-django
- apply migration by logging into container:
docker exec -it djangoapp /bin/bash
- build image:
docker-compose build
- run:
docker-compose up
- apply migrations; app = service name specified in yml file:
- apply migrations:
docker-compose exec app python manage.py makemigrations
- migrate:
docker-compose exec app python manage.py migrate
- apply migrations:
- to make updates in dev and see changes:
docker-compose up --build
- create superuser:
docker-compose exec app python manage.py createsuperuser
- edit compose file to add image; add
psycopg2-binary
to requirements.txt - updated db in:
src\web_project\settings.py
- run
docker-compose up
- in linux, if you get permission denied, run
sudo chown -R $USER:$USER .
- in linux, if you get permission denied, run
- apply migrations
- apply migrations:
docker-compose exec app python manage.py makemigrations
- migrate:
docker-compose exec app python manage.py migrate
- apply migrations: