basic stuff
This commit is contained in:
56
cookbook/forms.py
Normal file
56
cookbook/forms.py
Normal file
@ -0,0 +1,56 @@
|
||||
from django import forms
|
||||
from .models import *
|
||||
|
||||
|
||||
class RecipeForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Recipe
|
||||
fields = ('name', 'category', 'keywords')
|
||||
|
||||
labels = {
|
||||
'name': 'Name',
|
||||
'category': 'Kategorie',
|
||||
'keywords': 'Tags',
|
||||
}
|
||||
|
||||
help_texts = {
|
||||
'keywords': 'Strg+Click für Mehrfachauswahl',
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RecipeForm, self).__init__(*args, **kwargs)
|
||||
self.fields['name'].widget.attrs.update({'class': 'form-control'})
|
||||
self.fields['category'].widget.attrs.update({'class': 'form-control'})
|
||||
self.fields['keywords'].widget.attrs.update({'class': 'form-control'})
|
||||
|
||||
|
||||
class CategoryForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Category
|
||||
fields = ('name', 'description')
|
||||
|
||||
labels = {
|
||||
'name': 'Name',
|
||||
'description': 'Beschreibung',
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CategoryForm, self).__init__(*args, **kwargs)
|
||||
self.fields['name'].widget.attrs.update({'class': 'form-control'})
|
||||
self.fields['description'].widget.attrs.update({'class': 'form-control'})
|
||||
|
||||
|
||||
class KeywordForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Keyword
|
||||
fields = ('name', 'description')
|
||||
|
||||
labels = {
|
||||
'name': 'Name',
|
||||
'description': 'Beschreibung',
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(KeywordForm, self).__init__(*args, **kwargs)
|
||||
self.fields['name'].widget.attrs.update({'class': 'form-control'})
|
||||
self.fields['description'].widget.attrs.update({'class': 'form-control'})
|
Reference in New Issue
Block a user