Django ORM, Forms and custom select input look -
some thing confused me. have simple model (employee) 1 fk user django model. in templates, used custom field output customization of field in form:
<select ...> {% employee in form.accept_employee.field.choices %} <option value="{{ employee.0 }}">{{ employee.1 }}</option> {% endfor %} </select>
this used create ticket model fk employee, user should select 1 list. django-debug-toolbar see 2 identical sql request "select * employees" template instead of 1 when use this
{{ form.accept_employee }}
in template. can explain why happend?
p.s. view code:
class ticketcreate(setheadlinemixin, createview): headline = u'...' template_name = u'service/ticket_create_form.html' model = ticket def form_valid(self, form): self.object = form.save() message = u'<a href="{0}" target="_blank"><strong>...</strong></a>'.format(reverse('ticket_print', args=[self.object.id])) messages.add_message(self.request, messages.info, message) return httpresponseredirect(reverse('ticket_list'))
Comments
Post a Comment