Am Freitag, 19. Mai 2017 10:46:02 UTC+2 schrieb James Schneider:
>
>
>
> On Thu, May 18, 2017 at 8:14 AM, guettli <[email protected] 
> <javascript:>> wrote:
>
>>
>>
>>
>> Am Mittwoch, 17. Mai 2017 23:14:04 UTC+2 schrieb James Schneider:
>>>
>>>
>>>
>>> On May 17, 2017 6:31 AM, "guettli" <[email protected]> 
>>> wrote:
>>>
>>> Hi Russell Keith-Magee,
>>>
>>> which version do you use? With <table> or without table?
>>>
>>>    <table>{{ form }}</table> vs {{ form }}
>>>
>>>
>>> Both of these are incorrect.
>>>
>>> You need to wrap {{ form }} in a <form> HTML tag. If you want it in a 
>>> table, use {{ form.as_table }}.
>>>
>>>
>>> https://docs.djangoproject.com/en/1.11/topics/forms/#form-rendering-options
>>>
>>> There is no "correct" way, it depends on your template design as to 
>>> which one is more appropriate.
>>>
>>
>>
>> Hi James,
>>
>> yes, you are right. Both ways need a surrounding <form> tag. Maybe I 
>> condensed my question too much.
>>
>> I don't understand the "as_table" part you wrote. AFAIK {{ form.as_table 
>> }} and {{ form }} return the same result.
>>
>
>
> Hmm, it appears you're right. I mistakenly though that {{ form }} would 
> result in something similar to {{ form.as_p }}. I haven't rendered a {{ 
> form }} without crispy-forms in quite a while.
>
>
> https://docs.djangoproject.com/en/1.11/ref/forms/api/#outputting-forms-as-html
>
> Also tested myself quickly on a current project and verified the same.
>
> In that case, both of those formats are valid and effectively equivalent. 
> My original assertion about there being no "correct" format still stands, 
> since that is based on your template design. Adding the <table> tags will 
> place the form inside of a true HTML table. That may or may not be what you 
> want. You may want to be more semantic if using a table and use <table>{{ 
> form.as_table }}</table> just to make it clear that the variable is being 
> rendered as a table, rather than relying on a default output format. That's 
> personal preference, though, but it is slightly safer if the default format 
> for {{ form }} ever changed, which I doubt will be the case any time soon.
>
> Apologies for not checking myself before sending out the response. 
>
>

No need to apology :-)

Up to now I don't use crispy forms. I think a lot of people use it. Maybe I 
should try it.

Regards,
  Thomas

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/6b5594f4-541a-4f3c-9754-9354a6f05a4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to