daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # forms.py :: part 1
  2.  
  3. from django import forms
  4. from django.forms import modelformset_factory
  5.  
  6. from .models import Book, Author
  7.  
  8. class BookModelForm(forms.ModelForm):
  9.     class Meta:
  10.         model = Book
  11.         fields = ('name', )
  12.         labels = {
  13.             'name': 'Book Name'
  14.         }
  15.         widgets = {
  16.             'name': forms.TextInput(attrs={
  17.                 'class': 'form-control',
  18.                 'placeholder': 'Enter Book Name here'
  19.                 }
  20.             )
  21.         }
  22. AuthorFormset = modelformset_factory(
  23.     Author,
  24.     fields=('name', ),
  25.     extra=1,
  26.     widgets={
  27.         'name': forms.TextInput(
  28.             attrs={
  29.                 'class': 'form-control',
  30.                 'placeholder': 'Enter Author Name here'
  31.             }
  32.         )
  33.     }
  34. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top