Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- views.py
- <...>
- def form_valid(self, form):
- form.instance.ip = self.request.META["REMOTE_ADDR"]
- form.nickname = self.request.user.username
- form.instance.approved = False
- form.save() # add post to the database
- return super(PostSubmissionView, self).form_valid(form)
- <...>
- models.py
- <...>
- nickname = models.CharField(_("Nickname*"), max_length=20, db_index=True,
- validators=[RegexValidator(r'^[A-z0-9-_]+$',
- _("Nickname must consist of letters and numbers only."))])
- <...>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement