Elros Flashcards
How to migrate?
Never makemigrations without app_name.
Only python manage.py makemigrations app_name
You should also use python manage.py migrate
5 Checks before commit
- CRUD works
- Add doc strings
- Remove unnecessary comments (search ‘#’)
- Remove prints (search ‘print’)
- Fix imports
New ticket git flow
git switch dev
git pull
git checkout -b EXTEDU-44_fix_EducationProgram
git status # Check all changed files (Commit Side Tab provides diff-view)
git add .
git commit -m ‘EXTEDU-44 Payer CRUD on Navigator’
git switch dev
git pull
# PyCharm - Git: Merge LOCAL (!) EXTEDU-44 into dev
git push
Виртуальная модель для отображения одного элемента требует …
ID либо с Навигатора, либо добавления вручную
git naming convention
enrollment-fix
1. lower-case (minuscule)
2. dashes as space
Сделать форму рид онли
Добавить win и contract из params
Задать условие
Задать для формы ридонли
ui.py / set_params
self.win = win contract = params['object'] if not params['create_new'] and not contract.is_active: self.win.form.make_read_only()
Передать в params ключ-значение
В get_edit_window_params передать ключ-значение
actions /
def get_edit_window_params(self, params, request, context): params = super().get_edit_window_params(params, request, context) params['current_unit_id'] = get_current_unit_id(request) return params
ui /
def set_params(self, win, params): current_unit_id = params['current_unit_id'] current_unit = Unit.objects.get(id=current_unit_id) self.field\_\_unit_id.value = current_unit.id self.field\_\_unit_id.default_text = current_unit.full_name self.field\_\_unit_id.hidden = True
ForeignKey field name
self.field_name_id
Always add _id
Debug
Ломай/отключай части кода и смотри, что меняется.
Если нет таблицы в DataBase View
- Проверить миграции приложения
- Обновить вид в таблице(CTRL+F5)
Find app name for making migrations
Check apps.py within the app folder
Get entries from navigator
{navigator}/api/contract-pf?number=110
Build django container (from scratch downloading all components)
docker-compose -f docker-compose.yml up -d --build django
Recreate container without rebuilding it from scratch
docker-compose up -d --force-recreate
Install Python 3.10 on Ubuntu 23.04
Install pyenv following the readme https://github.com/pyenv/pyenv
Edit bashrc and install python 3.10.5
In Pycharm select Python from home/.pyenv/versions