Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django import forms
- from advertisement.models import Advertisement, Category
- class AdvertisementForm(forms.ModelForm):
- class Meta:
- model = Advertisement
- fields = [
- 'title',
- 'address',
- 'complement',
- 'number',
- 'zip_code',
- 'value',
- 'description',
- 'category',
- 'image',
- ]
- widgets = {
- 'title': forms.TextInput(
- attrs={'class': 'form-control', 'placeholder': 'Title', 'required': ''}),
- 'address': forms.TextInput(
- attrs={'class': 'form-control', 'placeholder': 'Address', 'required': ''}),
- 'complement': forms.TextInput(
- attrs={'class': 'form-control', 'placeholder': 'Complement', 'required': ''}),
- 'number': forms.TextInput(
- attrs={'class': 'form-control', 'placeholder': 'Number', 'required': ''}),
- 'zip_code': forms.TextInput(
- attrs={'class': 'form-control', 'placeholder': 'Zip-Code', 'required': ''}),
- 'value': forms.TextInput(
- attrs={'class': 'form-control', 'placeholder': 'Value 00,00', 'required': ''}),
- 'description': forms.TextInput(
- attrs={'class': 'form-control', 'placeholder': 'Description', 'required': ''}),
- 'category': forms.Select(
- choices=[('0', '----------')]+ [(ctg.id, ctg.name) for ctg in Category.objects.all()],
- attrs={'class': 'form-control', 'placeholder': 'Description', 'required': ''}),
- 'image': forms.FileInput(
- attrs={'class': 'form-control-file', 'placeholder': 'Image', 'required': ''}),
- }
Add Comment
Please, Sign In to add comment