jeudi 7 juin 2018

Click in a dropdown option and show an specific field in Django

I have the following situation, I have this model:

class Profile(models.Model):

    DEVELOPER = 1
    MARKETER = 2
    ACADEMIC = 3
    INFLUENCER = 4
    COMMUNITY_MEMBER = 5

    ROLE_CHOICES = (
        (DEVELOPER, 'Developer'),
        (MARKETER, 'Marketer'),
        (ACADEMIC, 'Academic'),
        (INFLUENCER, 'Influencer'),
        (COMMUNITY_MEMBER, 'Community Member'),
    )

    user = models.OneToOneField(User)
    account_type = models.ForeignKey(AccountType, default=AccountType.FREE)
    role = models.PositiveIntegerField(choices=ROLE_CHOICES, null=True, blank=True)
    github_profile = models.URLField(blank=True, null=True)
    linkedin_profile = models.URLField(blank=True, null=True)

And now what I want to do is that if the user clicks in the dropwdown the Developer option, the github_profile should appear, otherwise it should keep hide.

I know this is a conditional thing, however I'm brand new in Django and I'm not pretty sure how to achieve it.

Aucun commentaire:

Enregistrer un commentaire