Created
May 6, 2014 20:46
-
-
Save gileno/514a470c2469d7e64821 to your computer and use it in GitHub Desktop.
Django Many to Many CheckboxSelectMultiple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.forms.widgets import CheckboxSelectMultiple | |
from django import forms | |
from .models import Curriculo | |
class CurriculoForm(forms.ModelForm): | |
class Meta: | |
model = Curriculo | |
widgets = { | |
"habilidades": CheckboxSelectMultiple | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Curriculo(models.Model): | |
habilidades = models.ManyToManyField(Habilidade, through='CurriculosHabilidades') | |
class Habilidade(models.Model): | |
tipo = models.IntegerField(choices=HABILIDADES_CHOICES) | |
nome = models.CharField(max_length=100,verbose_name=_('Nome')) | |
class CurriculosHabilidades(models.Model): | |
curriculo = models.ForeignKey(Curriculo) | |
habilidade = models.ForeignKey(Habilidade) | |
nivel = models.IntegerField(choices=HABILIDADES_NIVEIS_CHOICES) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment