'django custom sign up form with dropdown field, allauth

so, I am using django allauth with custom signup form and page. I am trying to make usermanager to pickup vendor name and vendor code on signup page from vendorinfo class. So if I select vendor name on dropdown box on sign up page, it should automatically select vendor code that matches with vendor name field. How can I accomplish this? This is all auth so I didn't even need to create view for signup page. it just picks up signup.html from my template to generate form.

forms.py

class MyCustomSignupForm(SignupForm):
    name = forms.CharField(max_length=30, label='Name')
    vendor_name = dropdown
    vendor_code = dropdown that matches with vendor name

model.py

class VendroInfo(models.Model):

    vendor_code = models.IntegerField('Vendor Code', primary_key=True)
    vendor_name = models.CharField('Vendor Name', max_length=50)


class UserManager(BaseUserManager):

    def _create_user(self, name, vendor_name, vendor_code, password):
        if not email:
            raise ValueError('Users must have an email address')
        now = timezone.now()
        email = self.normalize_email(email)
        user = self.model(
            name = name,
            vendor_name=vendor_name,
            vendor_code=vendor_code 
        )
        user.set_password(password)
        user.save(using=self._db)
        return user

    def create_user(self, name, vendor_name, vendor_code, password):
        return self._create_user(self, name, vendor_name, vendor_code, password)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source