Skip to content

Commit

Permalink
トップ画面とサインアップ画面の実装,b
Browse files Browse the repository at this point in the history
  • Loading branch information
HayashiYoshihiro committed May 4, 2024
1 parent 5d82785 commit 9c5ac1c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand Down
11 changes: 11 additions & 0 deletions templates/accounts/signup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "base.html" %} ← base.htmlを継承

{% block title %}Sign Up{% endblock %} ← titleを入れる

{% block content %}
<form method="post">
{{ form.as_p }} ← formにはSignupFormのインスタンスが入っている。as_pとすることで、各input要素がpタグで囲まれた状態で表示される。
{% csrf_token %} ← csrf_token必須。formタグ内であればどこに書いてもOK
<button type="submit">ユーザー登録</button>
</form>
{% endblock %}
20 changes: 18 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,25 @@
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Document</title>
<title>{% block title %}Twitter Clone{% endblock %}</title>
</head>
<body>
<!-- header -->
<header class="mb-3">
<nav>
<ul>
<li><a href="{% url 'welcome:welcome' %}">Twitter Clone</a></li>
<li><a href="{% url 'accounts:signup' %}">Sign up</a></li>
</ul>
</nav>
</header>
<!-- /header -->

<!-- main -->
<main>
{% block content %}
{% endblock %}
</main>
<!-- /main -->
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion welcome/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

app_name = "welcome"
urlpatterns = [
path("", views.WelcomeView.as_view()),
path("", views.WelcomeView.as_view(), name="welcome"),
]

0 comments on commit 9c5ac1c

Please sign in to comment.