Lightking95

CreateView ModelForm

Jun 2nd, 2021
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. class PublicationForm(forms.ModelForm):
  2.     journal = forms.ModelChoiceField(label=_('Журналы'),
  3.                                      queryset=Journal.objects.filter(expiry_date__gte=datetime.date.today(), ),
  4.                                      widget=forms.Select(attrs={
  5.                                          "name": "journal",
  6.                                          "id": "journal",
  7.                                          "class": "form-control",
  8.                                          "autofocus": "autofocus",
  9.                                      }))
  10.     class Meta:
  11.         model = Publication
  12.         fields = (
  13.             'title', 'title_en', 'title_ky', 'journal', 'annotation', 'annotation_en', 'annotation_ky', 'keywords',
  14.             'keywords_en', 'keywords_ky', 'file')
  15.  
Advertisement
Add Comment
Please, Sign In to add comment