Elros Flashcards

1
Q

How to migrate?

A

Never makemigrations without app_name.
Only python manage.py makemigrations app_name
You should also use python manage.py migrate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

5 Checks before commit

A
  1. CRUD works
  2. Add doc strings
  3. Remove unnecessary comments (search ‘#’)
  4. Remove prints (search ‘print’)
  5. Fix imports
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

New ticket git flow

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Виртуальная модель для отображения одного элемента требует …

A

ID либо с Навигатора, либо добавления вручную

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

git naming convention

A

enrollment-fix
1. lower-case (minuscule)
2. dashes as space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Сделать форму рид онли

Добавить win и contract из params
Задать условие
Задать для формы ридонли

A

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()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Передать в params ключ-значение

В get_edit_window_params передать ключ-значение

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

ForeignKey field name

A

self.field_name_id
Always add _id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Debug

A

Ломай/отключай части кода и смотри, что меняется.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Если нет таблицы в DataBase View

A
  1. Проверить миграции приложения
  2. Обновить вид в таблице(CTRL+F5)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Find app name for making migrations

A

Check apps.py within the app folder

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Get entries from navigator

A

{navigator}/api/contract-pf?number=110

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Build django container (from scratch downloading all components)

A

docker-compose -f docker-compose.yml up -d --build django

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Recreate container without rebuilding it from scratch

A

docker-compose up -d --force-recreate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Install Python 3.10 on Ubuntu 23.04

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Rebuild running containers

A

docker-compose up -d --force-recreate

17
Q

Check pending migrations without applying them

A

python manage.py makemigrations --dry-run

18
Q

Output the migration file for dry run

A

python manage.py makemigrations payer --dry-run --verbosity 3

19
Q

How to see environmental variables in a docker container?

A
env
printenv
docker exec <container_id> env
20
Q

Что делать если миграции не выполняются?

A

Удалить файлы миграций и записи в БД django_migrations в поле app

21
Q

Create named migrations

A

python manage.py makemigrations --name changed_my_model your_app_label

22
Q

SQL: Удалить колонку

A

ALTER TABLE public.education_program_educationprogrammodule DROP COLUMN in_occupancy;