formset.py 880 B

1234567891011121314151617181920212223242526272829303132
  1. from django import forms
  2. from utilities.forms import APISelectMultiple, FilterChoiceField
  3. from .models import Tenant, TenantGroup
  4. #
  5. # Tenancy filtering form extension
  6. #
  7. class TenancyFilterForm(forms.Form):
  8. tenant_group = FilterChoiceField(
  9. queryset=TenantGroup.objects.all(),
  10. to_field_name='slug',
  11. null_label='-- None --',
  12. widget=APISelectMultiple(
  13. api_url="/api/tenancy/tenant-groups/",
  14. value_field="slug",
  15. null_option=True,
  16. filter_for={
  17. 'tenant': 'group'
  18. }
  19. )
  20. )
  21. tenant = FilterChoiceField(
  22. queryset=Tenant.objects.all(),
  23. to_field_name='slug',
  24. null_label='-- None --',
  25. widget=APISelectMultiple(
  26. api_url="/api/tenancy/tenants/",
  27. value_field="slug",
  28. null_option=True,
  29. )
  30. )