daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Jul 16th, 2018 121 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. # in userprofile/models.py
  2. class Profile(models.Model):
  3.     user = models.ForeignKey(User, unique=True)
  4.     location = models.CharField(max_length=100, blank=True)
  5.  
  6. # in settings.py
  7. AUTH_PROFILE_MODULE = 'userprofile.Profile'
  8.    
  9. # in backend/default/__init__.py
  10. def register(self, request, **kwargs):
  11.     username, email, password = kwargs['email'], kwargs['email'], kwargs['password1']
  12.     if Site._meta.installed:
  13.         site = Site.objects.get_current()
  14.     else:
  15.         site = RequestSite(request)
  16.     new_user = RegistrationProfile.objects.create_inactive_user(username, email, password, site)
  17.     signals.user_registered.send(sender=self.__class__,
  18.                                  user=new_user,
  19.                                  request=request)
  20.  
  21.     # how to add 'location = USA' to profile via signals here?
  22.  
  23.     return new_user
  24.    
  25. LOCATION = 'USA'
  26.    
  27. # in backend/default/__init__.py
  28. def register(self, request, **kwargs):
  29.  
  30.     username, email, password = kwargs['email'], kwargs['email'], kwargs['password1']
  31.     if Site._meta.installed:
  32.         site = Site.objects.get_current()
  33.     else:
  34.         site = RequestSite(request)
  35.     import settings
  36.     if settings.LOCATION:
  37.         location = settings.LOCATION
  38.     new_user = RegistrationProfile.objects.create_inactive_user(username, location, email, password, site)
  39.     signals.user_registered.send(sender=self.__class__,
  40.                                  user=new_user,
  41.                                  request=request)
  42.  
  43.  
  44.     return new_user
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top