![]() ![]() ![]() But I don't want to do so, as I may be using this form on multiple views and thus will require changes on multiple pages in future if needed. Using ModelFormMixin (base class of BusinessCreate) without the 'fields' attribute is prohibited.Īfter moving fields to views class, it is working fine. On loading template of BusinessCreate it gives error as Messages.success(self.request, 'Business Added Successfully') Messages.success(self.request, 'form is valid') I will help you design your career game plan and identify the most important and high-value areas to focus on to get results faster. User = models.ForeignKey(User, on_delete=models.CASCADE)īusiness_type = models.ForeignKey(BusinessType, on_delete=models.CASCADE)īusiness/Forms.py class BusinessForm(ModelForm):īusiness/views.py class BusinessCreate(LoginRequiredMixin, CreateView): It took me more than 20 years to learn, experiment, coach and mentor hundreds of women to get to the formula that empowers women to step up and speak out to get the career and life they deserve. Modified = models.DateTimeField('last modified', auto_now=True) I have created a Form and using Class based view to create a record and save to database.īusiness/models.py class BusinessType(models.Model):Ĭreated = models.DateTimeField('date created', auto_now_add=True) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |