
Вот моя модель
Код: Выделить всё
class InfluencerModel(models.Model):
full_name = models.CharField(max_length=255, null=False, blank=False)
email = models.EmailField(max_length=255, null=False, blank=False)
contact_number = models.CharField(max_length=10, null=False, blank=False)
instagram_id = models.CharField(max_length=50, null=False, blank=False)
message = models.TextField(null=True, blank=True)
visited_on = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.email
def get_absolute_url(self):
return reverse("influencers")Views.py
Код: Выделить всё
class InfluencersPageView(CreateView):
model = InfluencerModel
template_name = 'home/influencers.html'
fields = ['full_name', 'email', 'contact_number', 'instagram_id', 'message']
def get_context_data(self, *args, **kwargs):
context = super(InfluencersPageView, self).get_context_data(*args, **kwargs)
return contextВот шаблон
< div class="snippet">
Код: Выделить всё
{% csrf_token %}
{{ form.full_name.errors }}
{{form.full_name|as_crispy_field}}
{{ form.email.errors }}
{{form.email|as_crispy_field}}
{{ form.contact_number.errors }}
{{form.contact_number|as_crispy_field}}
{{ form.instagram_id.errors }}
{{form.instagram_id|as_crispy_field}}
{{ form.message.errors }}
{{form.message|as_crispy_field}}
Send Message
Подробнее здесь: https://stackoverflow.com/questions/781 ... eview-form
Мобильная версия