我不知道为什么它不保存从false到true的更改。 请帮忙。 is_approved和is_superuser是用户u的属性。
谢谢
编辑: 用户模型代码
class User(AbstractUser):
TRAINEE = 1
MENTOR = 2
MODERATOR = 3
SUBMENTOR = 4
USER_TYPES = (
(TRAINEE, 'Trainee'),
(MENTOR, 'Industry Expert'),
(MODERATOR, 'Moderator'),
(SUBMENTOR,'SubMentor')
)
user_type = models.PositiveSmallIntegerField(choices=USER_TYPES, null=True, blank=True)
is_approved = models.BooleanField(default=False)
has_paid_subscription = models.BooleanField(default=False)
date_of_birth = models.DateField(null=True, blank=True)
bio = models.CharField(max_length=2000, validators=[MinLengthValidator(100)], blank=True, null=True)
profile_picture = models.ImageField(upload_to=profile_media_path, default='default_profile_pic.jpg', blank=True, null=True)
profile_tags = models.ManyToManyField(Tag, blank=True, related_name='profiles')
signup_completed = models.BooleanField(default=False)
referral_code = models.CharField(max_length=100,null=True,blank=True)
def __str__(self):
return self.username
def save(self, *args, **kwargs):
super(User, self).save(*args, **kwargs)
if self.bio:
self.profile_tags.clear()
lda_model = lda.LDA([self.bio])
tags = lda_model.generate_tags()
for tag in tags:
name = str(tag).capitalize()
try:
tag_object = Tag.objects.get(tag_name=name)
except Tag.DoesNotExist:
tag_object = Tag(tag_name=name)
tag_object.save()
self.profile_tags.add(tag_object)
tag_object.save()
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs):
if created:
Token.objects.create(user=instance)
答案 0 :(得分:0)
声明您要编辑的模型。
std::vector<int>
从查询集中访问用户时发生了一些奇怪的事情,这阻止了用户保存。不清楚为什么的细节,但是您可以按照上述模式解决它。