I am building an app, witch django social, and i need to do some stuff when user register, but i can not find out whether this is his first log in or not, how can i do that without alter user db, and without last_login == date_joined (because i think it's pretty dirty way, tell me if not) Also sorry for my bad english in some places.
If it's the first user login, last_login field will be NULL. You can override the LoginView and form_valid, for example:
class LoginView(auth_views.LoginView):
"""Renders the client login page."""
def form_valid(self, form):
"""Security check complete. Log the user in."""
auth_login(self.request, form.get_user())
if self.request.user.is_authenticated and not self.request.user.date_joined:
# do your stuff
return HttpResponseRedirect(self.get_success_url())
Also, make sure to add this view to the login url in your urls.py