Django Checkbox, Text and Select Django.How

Author avatar wrote on 03/06/2022


record.full_timer = request.POST.get('full_timer', False)
if record.full_timer == 'on':
    record.full_timer = True['full_timer'])
print('record updated')

In template

Number text = request.POST['target']

In template


In View

context['languages'] = Language.objects.all()

In template

Select field choices with key values

In view

context['unit_choices'] = CompanyService._meta.get_field('unit').choices

In template

Set a field to NULL use None

    if service:
        record.service = CompanySubService.objects.get(company=1, name=service)
        record.service = None