Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. views.py
  2.  
  3. <...>
  4.     def form_valid(self, form):
  5.         form.instance.ip = self.request.META["REMOTE_ADDR"]
  6.         form.nickname = self.request.user.username
  7.         form.instance.approved = False
  8.         form.save()  # add post to the database
  9.         return super(PostSubmissionView, self).form_valid(form)
  10. <...>
  11.  
  12. models.py
  13. <...>
  14. nickname = models.CharField(_("Nickname*"), max_length=20, db_index=True,
  15.                                 validators=[RegexValidator(r'^[A-z0-9-_]+$',
  16.                                                            _("Nickname must consist of letters and numbers only."))])
  17.  
  18. <...>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement