Django: keep top shape?

Are there any documents about this? I could not dig.

I have a custom one ModelFormfor creating articles. Whenever I use this form, I pass in an instance articleto automatically set the author:

    article = Article(author=req.user)
    form = ArticleForm(req.POST, instance=article)

How do I access this variable instance/ articlefrom the inside form.save()?
Is there anything else I need to know when writing this method? Or just need to be returned articleand is that pretty much?

+3
source share
1 answer

I think the answer I'm looking for is:

article = super(ArticleForm, self).save(commit=False)
+7
source

Source: https://habr.com/ru/post/1724986/


All Articles