django - Access session in user model .save() -



django - Access session in user model .save() -

is possible access current session in user model .save()?

pseudo code of want achieve:

# users.models.py def save(self, *args, **kwargs): created = true if self.pk: created = false super(abstractuser, self).save(*args, **kwargs) # post-save if created: look_for_invite_in_session_and_register_if_found(self, session)

seems wrong in architecture. shouldn't access request in models layer. work request must done in view. can this:

user, created = abstractuser.objects.get_or_create(name=name) if created: look_for_invite_in_session_and_register_if_found(user, request.session)

django session

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

php - .htaccess Multiple Rewrite Rules / Prioritizing -