I want the admin only to create a object from a model. Is it possible?

#EmailAddress.objects.create(user=instance, email=instance.email)



>From models.py

class EmailAddress(models.Model):
 user = models.OneToOneField(User, unique=True, related_name ='address')
 email = models.EmailField()
 verified = models.BooleanField(verbose_name=_('verified'), default=True)
 primary = models.BooleanField(verbose_name=_('primary'), default=True)

 class Meta:
 db_table = 'account_emailaddress'





@receiver(post_save, sender=User)
def create_profile(sender, instance, created, **kwargs):
 if created:
    UserProfile.objects.create(user=instance)
    #EmailAddress.objects.create(user=instance, email=instance.email)


Any help is highly appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/30e452a0-d6cd-48c5-932a-96b13ca68601%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to