Django poj.c B8) Eng) Signup !! Eventually !! - 14th day
Code B Django 8th article, 14th day of the project (Sunday)
1.
Development progress now.
I completed the core structure of the Signup page.
I need the Django User Model cause of security issues - for example, password encryption or password validation.
But it was not easy to make code satisfying me with the User Model which Django already made.
Anyway, I did it eventually.
2.
The first time, I just used 'form' following textbooks code and it looks like this.
{{ form.username.label }}
{{ form.username }}
It was ok if I didn't want to use CSS styling.
'form' makes input text boxes automatically. And I couldn't change any other attributes. There are ugly text boxes.
3.
I want to put {{ form.fields }} inside of input tags because If I could set {{ form }} in the HTML tags, it is easy to assign class attributes to tags for styling.
And I think that many people use something like this for the 'POST' form method with Model.
But I had to spend lots of time and energy because that was hard to find what I expected.
So many blogs and textbooks say that write just {{ form.as_p }} or assign style attribute in Form class using widgets like this.
widgets = {
'field':TextInput(attrs={
'style' : 'max-width: 300px; '
}),
Not to mention the first way, but I don't want the second one because it messes up MTV design pattern.
Eventually, thankfully I found what I want in some blog. It shows how to access Django Forms in Html form.
<p>
<label for="{{ form.username.id_for_label }}">아이디</label>
<input type="text"
name="{{ form.username.html_name }}"
id="{{ form.username.id_for_label }}"
class="text_input_css"
autocomplete="off"
>
</p>
I've gotten the idea from this blog. Thank you.
django 04. 장고 개인 프로젝트 6 - 회원가입, 로그인 폼 꾸미기
https://wayhome25.github.io/django/2017/03/01/django-99-my-first-project-6/
4.
I have lots of stories besides this,
It seems to need an eternity of time if I write in English continuously.
So I end up this post here.
And I am going to write the next story in Korean as simply as possible.
Thank you for reading my story!