I see that similar to this has been asked before but I would like to know if there was a simpler way to achieve this.
Also followed this blog post.
A sample Model is given below.
class Post (models.Model):
name = models.CharField(max_length=1000, help_text="required, name of the post")
description = models.TextField(blank=True)
created_datetime = models.DateTimeField(auto_now_add=True, editable=False)
modified_datetime = models.DateTimeField(auto_now=True, editable=False)
custom_hashed_url = models.CharField(unique=True, max_length=1000, editable=False)
def save(self, *args, **kwargs):
#How to save User here?
super(Model, self).save()
Isn't it possible to send current logged in user to the Model before calling save()?
In the view:
if request.method == 'POST':
if not errors:
f = PostForm(request.POST)
f.save()