Piki is a minimal wiki
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425
  1. from typing import Any, Mapping
  2. from django import forms
  3. from django.forms.renderers import BaseRenderer
  4. from django.forms.utils import ErrorList
  5. class EditForm(forms.Form): # Note that it is not inheriting from forms.ModelForm
  6. page_txt = forms.CharField(max_length=20000, label="Page source text", widget=forms.Textarea(attrs={"rows": "20"}))
  7. page_tags = forms.CharField(max_length=500, label="Tags (words separated by spaces)", required=False)
  8. def __init__(self, *args, **kwargs) -> None:
  9. page_data = kwargs.pop("page_data")
  10. page_tags = kwargs.pop("page_tags")
  11. super().__init__(*args, **kwargs)
  12. self.fields['page_txt'].initial = page_data
  13. self.fields['page_tags'].initial = page_tags
  14. class RenameForm(forms.Form): # Note that it is not inheriting from forms.ModelForm
  15. page_name = forms.CharField(max_length=500, label="Change the page name:", required=True)
  16. def __init__(self, *args, **kwargs) -> None:
  17. page_name = kwargs.pop("page_name")
  18. super().__init__(*args, **kwargs)
  19. self.fields['page_name'].initial = page_name