DetailView, CreateView) from .models import Account, Transaction class AccountList(ListView): model = Account class AccountDetail(DetailView): model = Account class AccountCreate(CreateView): model = Account class TransactionCreate(CreateView): model = Transaction success_url = reverse_lazy('bank_account_list')
import Account class AccountForm(ModelForm): class Meta: model = Account def clean(self): cleaned_data = super(AccountForm, self).clean() name = cleaned_data.get("name") slug = cleaned_data.get("slug") if not slug and name: cleaned_data['slug'] = slugify(name) return cleaned_data
import Account class AccountForm(ModelForm): class Meta: model = Account exclude = ('slug',) def clean(self): cleaned_data = super(AccountForm, self).clean() name = cleaned_data.get("name") slug = cleaned_data.get("slug") if not slug and name: cleaned_data['slug'] = slugify(name) return cleaned_data