modelform

(Django CBV) Need object be attached to a user with CBV

(Django CBV) Need object be attached to a user with CBV Question: I implemented this functionality with using FBV, but when I’m trying to use CBV, Objects were created with empty user field. views.py class BlockCreate(CreateView): model = TrainingBlock template_name = ‘training_room/create_block.html’ form_class = BlockForm success_url = reverse_lazy(‘gym’) def set_user(self, form): form.instance.user = self.request.user return …

Total answers: 1

When I include a hidden field in my modelform, the modelform is not submitted

When I include a hidden field in my modelform, the modelform is not submitted Question: I am trying to build up a posting webpage. This is how it works: you click a button, the posting form will appear, you fill in the form, you click the submit button, and the process is complete. And when …

Total answers: 1

How to use a DatePicker in a ModelForm in django?

How to use a DatePicker in a ModelForm in django? Question: I am using django 3.0 and I am trying to display a datepicker widget in my ModelForm, but I can’t figure out how (all I can get is text field). I have tried looking for some solutions, but couldn’t find any. This is how …

Total answers: 5

Django ModelForm has no model class specified

Django ModelForm has no model class specified Question: I am trying to use ModelForm: from django.db import models from django.forms import ModelForm class Car(models.Model): carnumber = models.CharField(max_length=5) def __unicode__(self): return self.carnumber class PickForm(ModelForm): class Meta: Model = Car` I have checked this and I cannot find my error. When I call the view in a …

Total answers: 9