`models.py`:

```
class BlogPost(models.Model):
    title = models.CharField(max_length=200)
    post_body = models.TextField()
    user = models.ForeignKey(User)
    pub_date = models.DateTimeField('published')

    def get_absolute_url(self):
        return u'/entries/%d' % self.id

```

`forms.py`:

```
class NewPostForm(forms.ModelForm):
    class Meta:
        model = BlogPost
        fields = ('title', 'post_body')

```

So, I was trying to make a view for users to post a new post into blog. BlogPost model has 4 fields - `title`, `post_body`, `user`, and `pub_date`. User should be able to fill the `title` and `post_body`, while the other two should be filled automatically. First thing I tried was this:

```
class NewPostView(generic.edit.CreateView):
    model = BlogPost
    form_class = NewPostForm

    def get_initial(self):
        return {'pub_date': timezone.now(),
                'user': self.request.user}

```

But the only thing it does is providing the default values for html form. After additional research this is the code that ended up working:

```
class NewPostView(generic.edit.CreateView):
    model = BlogPost
    form_class = NewPostForm

    def form_valid(self, form):
        obj = form.save(commit=False)
        obj.user = self.request.user
        obj.pub_date = timezone.now()
        obj.save()
        return HttpResponseRedirect(obj.get_absolute_url())

```

So, while overriding form\_valid method worked, I don't feel like it's how it should be done maybe? Is there a better place to put this actions into? What is the conventional way of doing this?