class Planet(models.Model): planet = models.CharField(max_length=25) class Candidate(models.Model): name_c = models.CharField(max_length=25) planet = models.ForeignKey(Planet, on_delete=models.CASCADE) age = models.IntegerField(max_length=3) email = models.EmailField() status_padavan = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True)
наваял примерно следущее:
forms.py
class CandidateForm(forms.Form): name = forms.CharField(label='Твое имя', max_length=25) planet = forms.ModelChoiceField(queryset=Planet.objects.all()) age = forms.IntegerField(max_length=3, widget=forms.TextInput()) email = forms.EmailField(max_length=25)
class CandidateForm(ModelForm):
class Meta:
model = Candidate
fields=['name_c', 'planet', 'email', 'age']