Answer the question
In order to leave comments, you need to log in
How to inherit a variable from a class?
In the SkillGroupCreateForm class, I calculate the queryset value to be passed to the child class.
class SkillGroupCreateForm(forms.ModelForm):
def __init__(self, *args, employee_pk=None, **kwargs):
super().__init__(*args, **kwargs)
self.fields['technology'].required = False
if employee_pk is not None:
queryset = Technology.objects.exclude(skill__employee_id=employee_pk).order_by('name')
class SkillCreatePLanguageForm(SkillGroupCreateForm):
def __init__(self, *args, <--??<b>queryset</b>-->> **kwargs):
super().__init__(*args, **kwargs)
self.fields['technology'].queryset = <b>queriset</b>.filter(group__name="Programming language")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question