These are chat archives for django/django

21st
Nov 2018
lekan
@horlahlekhon
Nov 21 2018 08:09
hello , goodday....am new to django and i have been struggling with the forms....... please , is there a way one can render the fields of the form individually..... like {{form_fields.<inpu tags here>}} ...... kindly help
AJ
@ajostergaard
Nov 21 2018 08:28
@horlahlekhon yes - for example {{ form.email }} would render the email field in the form.
But don't forget that you may also want to render errors etc.
lekan
@horlahlekhon
Nov 21 2018 08:33
yes....the reason is actually that , i would like to add css classes to those form fields , and i dont want to use external apps like widget_tweaks..... how do you suggest i do that
AJ
@ajostergaard
Nov 21 2018 08:42
Set the class when you define the field... It is part of the widget: https://docs.djangoproject.com/en/2.1/ref/forms/widgets/#django.forms.Widget.attrs
lekan
@horlahlekhon
Nov 21 2018 08:44
ok, thanks
AJ
@ajostergaard
Nov 21 2018 08:44
:)
In general, don't be afraid to use popular useful libraries - they are popular and useful. ;)
lekan
@horlahlekhon
Nov 21 2018 08:47
ok.
kpagcha
@kpagcha
Nov 21 2018 13:09
can someone help me understand why loading a given template takes so long? about 1.3 seconds (total request time 2.5 seconds but that's probably because I'm using the debug toolbar). Queries are not the problem, only 50 of them are being run and it takes 61 ms. Having nested templates is not the problem either, there is only 1 template involved (if I refactor parts of it and end up with 32 templates involved the load time goes up to 1.8 seconds)
AJ
@ajostergaard
Nov 21 2018 13:14
@kpagcha version of Django?
kpagcha
@kpagcha
Nov 21 2018 13:14
@ajostergaard 1.8
kpagcha
@kpagcha
Nov 21 2018 13:16
didn't know about that one, thank you!
AJ
@ajostergaard
Nov 21 2018 13:19
:)
kpagcha
@kpagcha
Nov 21 2018 13:20
hmm it doesn't give much information I didn't know already though. It just reports loading time, but it doesn't detail why...
AJ
@ajostergaard
Nov 21 2018 13:25
Oh well - have to go old school and start chopping it up until you find the culprit. Sorry.
Perhaps your server is resource starved or something - be sure it's your template before you dive the rabbit hole.
kpagcha
@kpagcha
Nov 21 2018 13:31
yeah well that's what I've been doing all along but it's still slow. If the cause is not queries or nested templates I'm not sure where else to look at...
AJ
@ajostergaard
Nov 21 2018 13:46
The only thing I can suggest is starting with an empty template and slowly build it up...
Sorry.