Answers for "how to use custom form to upload to a model form in django"

1

passing user instance django form submission

if form.is_valid():
    post = form.save(commit=False)
    post.author = request.user
    post.published_date = timezone.now()
    post.save()
Posted by: Guest on December-20-2020
5

django model form

class YourForm(ModelForm):
	class Meta:
    	model = YourModel
    	fields = ['pub_date', 'headline', 'content', 'reporter']
Posted by: Guest on October-07-2020

Code answers related to "how to use custom form to upload to a model form in django"

Python Answers by Framework

Browse Popular Code Answers by Language