Add form for signatures
This commit is contained in:
parent
b8899cb44b
commit
7b90c17094
3 changed files with 39 additions and 2 deletions
11
petition/forms.py
Normal file
11
petition/forms.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from django.forms import ModelForm
|
||||||
|
from .models import Signature
|
||||||
|
|
||||||
|
|
||||||
|
class SignatureForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Signature
|
||||||
|
fields = [
|
||||||
|
'name',
|
||||||
|
'mail',
|
||||||
|
]
|
23
petition/migrations/0002_auto_20180205_2106.py
Normal file
23
petition/migrations/0002_auto_20180205_2106.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 2.0.2 on 2018-02-05 21:06
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('petition', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='signature',
|
||||||
|
name='mail',
|
||||||
|
field=models.EmailField(max_length=254, unique=True, verbose_name='Adresse mail'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='signature',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=255, unique=True, verbose_name='Nom complet'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -2,8 +2,11 @@ from django.db import models
|
||||||
|
|
||||||
|
|
||||||
class Signature(models.Model):
|
class Signature(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField('Nom complet',
|
||||||
mail = models.EmailField()
|
max_length=255,
|
||||||
|
unique=True)
|
||||||
|
mail = models.EmailField('Adresse mail',
|
||||||
|
unique=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{} <{}>".format(self.name, self.mail)
|
return "{} <{}>".format(self.name, self.mail)
|
||||||
|
|
Loading…
Reference in a new issue