class Order(models.Model):
name = models.CharField(max_length=50, blank=False, verbose_name='Jméno')
surname = models.CharField(max_length=50, blank=False, verbose_name='Příjmení')
email = models.EmailField(max_length=254, blank=True)
phone = models.CharField(max_length=50, verbose_name='Telefon', blank=True)
coursedate = models.ForeignKey(CourseDate, verbose_name='Termín')
note = models.CharField(max_length=500, blank=True, verbose_name='Poznámka')
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
def __str__(self):
return '%s, %s' % (self.surname, self.coursedate.course.name)
{{ form.non_field_errors }}
<form action="." method="POST">{% csrf_token %}
{{ form.non_field_errors }}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% for field in form.visible_fields %}
<div class="form-group">
{% if field.field.required %}
{{ field.errors }}
{{ field.label }}<span class="special_class">*</span>{{ field }}
{% else %}
{{ field.label }} {{ field }}
{% endif %}
</div>
{% endfor %}
</div>
<div class="modal-footer">
<a href="#" data-dismiss="modal">Close</a>
<button type="submit" class="btn btn-primary">Send</button>
</div>
</form>
def serve(self, request):
from crm.forms import OrderFormNew
if request.method == 'POST':
form = OrderFormNew(request.POST)
if form.is_valid():
form.date_changed = datetime.date.today()
form.save()
return render(request, 'courses/course_web.html', {
'page': self,
'form': form,
})
else:
form = OrderFormNew()
form.fields["coursedate"].queryset = CourseDate.objects.filter(course=self.course).order_by('date_start')
return render(request, 'courses/course_web.html', {
'page': self,
'form': form,
})
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fabad5ea-8535-483c-895f-ebb0d90e5c1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/46f470f5-b722-4c53-8232-3e95d7fc33a1%40googlegroups.com.
<snip>
<form action="." method="POST">{% csrf_token %}
{{ form.non_field_errors }}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% for field in form.visible_fields %}
<div class="form-group">
{% if field.field.required %}
{{ field.errors }}
{{ field.label }}<span class="special_class">*</span>{{ field }}
{% else %}
{{ field.label }} {{ field }}
{% endif %}
</div>
{% endfor %}
<snip>