Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- django ModelForm without all fields - fill them automatically
- class MyView(CreateView):
- def post(self, request, *args, **kwargs):
- self.form_class.client_ip = request.META.get('REMOTE_ADDR')
- super(MyView, self).post(request, *args, **kwargs)
- model = MyModel
- form_class = MyForm
- class MyForm(forms.ModelForm):
- class Meta:
- model = MyModel
- exclude = ('ip',)
- def get_initial(self):
- return { 'ip': ... }
Add Comment
Please, Sign In to add comment