Guest User

Untitled

a guest
May 26th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. from django import forms
  2. from advertisement.models import Advertisement, Category
  3.  
  4.  
  5. class AdvertisementForm(forms.ModelForm):
  6.  
  7. class Meta:
  8. model = Advertisement
  9. fields = [
  10. 'title',
  11. 'address',
  12. 'complement',
  13. 'number',
  14. 'zip_code',
  15. 'value',
  16. 'description',
  17. 'category',
  18. 'image',
  19. ]
  20. widgets = {
  21. 'title': forms.TextInput(
  22. attrs={'class': 'form-control', 'placeholder': 'Title', 'required': ''}),
  23. 'address': forms.TextInput(
  24. attrs={'class': 'form-control', 'placeholder': 'Address', 'required': ''}),
  25. 'complement': forms.TextInput(
  26. attrs={'class': 'form-control', 'placeholder': 'Complement', 'required': ''}),
  27. 'number': forms.TextInput(
  28. attrs={'class': 'form-control', 'placeholder': 'Number', 'required': ''}),
  29. 'zip_code': forms.TextInput(
  30. attrs={'class': 'form-control', 'placeholder': 'Zip-Code', 'required': ''}),
  31. 'value': forms.TextInput(
  32. attrs={'class': 'form-control', 'placeholder': 'Value 00,00', 'required': ''}),
  33. 'description': forms.TextInput(
  34. attrs={'class': 'form-control', 'placeholder': 'Description', 'required': ''}),
  35. 'category': forms.Select(
  36. choices=[('0', '----------')]+ [(ctg.id, ctg.name) for ctg in Category.objects.all()],
  37. attrs={'class': 'form-control', 'placeholder': 'Description', 'required': ''}),
  38. 'image': forms.FileInput(
  39. attrs={'class': 'form-control-file', 'placeholder': 'Image', 'required': ''}),
  40.  
  41. }
Add Comment
Please, Sign In to add comment