DataError('значение слишком длинное для типа character varing(40) на Heroku, но не на разработке

Мой проект отлично работает под разработкой, но на Heroku возникла эта ошибка. Ошибка возникает, когда пользователь пытается зарегистрироваться. Я использую регистрацию redux

Я только что сделал несколько обновлений, включая Python39 и Django 3. Так что, возможно, многое изменилось. Но если локальное окружение работает нормально, почему у Heroku возникают проблемы?

Мое мнение

class Register(RegistrationView): form_class = UserRegistrationForm

def register(self, form_class):

    new_user = super(Register, self).register(form_class)
    profile = Profile()
    profile.user = new_user
    profile.company = form_class.cleaned_data['company']
    profile.title = form_class.cleaned_data['title']
    profile.phone_number = form_class.cleaned_data['phone_number']
    profile.address = form_class.cleaned_data['address']
    profile.city = form_class.cleaned_data['city']
    profile.province = form_class.cleaned_data['province']
    profile.country = form_class.cleaned_data['country']
    profile.postal = form_class.cleaned_data['postal']
    profile.save()
    template = get_template('registration/registration.txt')

    context = {'name':new_user.first_name,'last':new_user.last_name,'company':profile.company,
                       'phone':profile.phone_number}

    content = template.render(context)

    return redirect('registration_complete')

Моя модель

class Profile(models.Model):
    user = models.OneToOneField(User, max_length=250,on_delete=models.CASCADE)
    city=models.CharField(max_length=250, blank=True)
    province=models.CharField(max_length=250, blank=True)
    country=models.CharField(max_length=250,blank=True)
    postal=models.CharField(max_length=7, blank=True)
    address = models.CharField(max_length=250, blank=True)
    company = models.CharField(max_length=250, blank=True)
    title = models.CharField(max_length=250, blank=True)
    phone_regex = RegexValidator(regex=r'^\+?1?\d{9,15}$',
                                 message="Phone number must be entered in the format: '+6041234567'. Up to 15 digits allowed.")
    phone_number = models.CharField(validators=[phone_regex], max_length=15, blank=True)  


    def __str__(self):
        return 'Profile for user {}'.format(self.user.username)

Я учусь здесь, поэтому, пожалуйста, дайте мне любые советы, которые вы можете найти полезными. Спасибо.

Вернуться на верх