前提
djangoでSNSアプリを作成しています。
django-allauthを使用した認証画面(ログイン、サインインなど)でタブ複製した際に、
htmlコードが表示されてしまいます。
F5でページ更新すると正常に画面が見えます。
開発環境、本番環境どちらも発生します。
django-allauthを使用した認証画面(ログイン、サインインなど)以外では発生しません。
実現したいこと
タブ複製後、F5でページ更新しなくても正常に画面が見えるようにしたいです。
発生している問題・エラーメッセージ
以下はログインページのhtmlです。
login.html
1{% extends 'base.html' %} 2 3{% block title %}ログイン | にゃっぷ{% endblock %} 4 5{% block active_login %}active{% endblock %} 6 7{% block contents %} 8<div class="container my-div-style"> 9 <div class="row"> 10 <div class="mt-2 col-sm-6 mx-auto"> 11 <div class="text-center"> 12 <strong>ログイン</strong> 13 <hr> 14 </div> 15 <div class="text-center"> 16 <form method="post" action="{% url 'account_login' %}"> 17 {% csrf_token %} 18 19 {{ form.as_p }} 20 21 {% if redirect_field_value %} 22 <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/> 23 {% endif %} 24 25 <button class="btn btn-primary" type="submit">ログイン</button> 26 <br> 27 <a class="button btn-sm" href="{% url 'account_reset_password' %}">パスワードを忘れましたか?</a> 28 </form> 29 </div> 30 </div> 31 </div> 32</div> 33{% endblock %}
以下のbase.htmlを含ませています。
{% load static %} <html lang="ja"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content=""> <title>{% block title %}{% endblock %}</title> <link rel="icon" type="image/x-icon" href="{% static 'assets/favicon.ico' %}"> <!-- Font Awesome icons (free version)--> <script src="https://use.fontawesome.com/releases/v5.15.4/js/all.js" crossorigin="anonymous"></script> <!-- Google fonts--> <link href="https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,600,800,900" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Lato:100,100i,300,300i,400,400i,700,700i,900,900i" rel="stylesheet"> <!-- leaflet --> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin=""/> <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script> <script src="https://code.jquery.com/jquery-3.5.0.min.js" integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" crossorigin="anonymous"></script> <script src="{% static 'js/ajax.js' %}"></script> <script src="{% static 'js/script.js' %}"></script> <script src="{% static 'js/jquery.waypoints.min.js' %}"></script> <script src="{% static 'js/infinite.min.js' %}"></script> {% block extrajs %}{% endblock %} <!-- Core theme CSS (includes Bootstrap)--> <link href="{% static 'css/styles.css' %}" rel="stylesheet"> <!-- My style --> <link href="{% static 'css/mystyle.css' %}" rel="stylesheet"> </head> <body> <div id="wrapper"> <!-- Navigation--> <nav class="navbar navbar-expand-lg navbar-light navbar-custom fixed-top border"> <div class="container px-5"> <img src="{% static 'assets/img/nyapu.png' %}" height="40"/> <a class="navbar-brand" href="{% url 'diary:diary' %}">にゃっぷ</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span></button> <div class="collapse navbar-collapse" id="navbarResponsive"> <ul class="navbar-nav ms-auto"> {% if user.is_authenticated %} <li class="nav-item"> <a class="nav-link" href="{% url 'diary:diary_create' %}">投稿する</a> </li> <li class="nav-item"> <a class="nav-link" href="{% url 'diary:diary' %}">ホーム</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggl" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> アカウントメニュー </a> <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> <a class="dropdown-item" href="{% url 'diary:diary_list' request.user %}">プロフィール</a> <a class="dropdown-item" href="{% url 'diary:like_diary_list' %}">いいねした日記</a> <a class="dropdown-item" href="{% url 'diary:followings' %}">フォロー</a> <a class="dropdown-item" href="{% url 'diary:followers' %}">フォロワー</a> <a class="dropdown-item" href="{% url 'accounts:userlist' %}">ユーザーリスト</a> <a class="dropdown-item" href="{% url 'account_logout' %}">ログアウト</a> <a class="dropdown-item" href="{% url 'diary:map' %}">にゃっぷ</a> </div> </li> {% else %} <li class="nav-item {% block active_signup %}{% endblock %}"> <a class="nav-link" href="{% url 'account_signup' %}">ユーザ登録</a> </li> <li class="nav-item {% block active_login %}{% endblock %}"> <a class="nav-link" href="{% url 'account_login' %}">ログイン</a> </li> {% endif %} <li class="nav-item {% block active_inquiry %}{% endblock %}"> <a class="nav-link" href="{% url 'diary:inquiry' %}">お問い合わせ</a> </li> </ul> </div> </div> </nav> {% block header %}{% endblock %} {% if massages %} <div class="container"> <div class="row"> <div class="my-div-style w-100"> <ul class="massages" style="list-style: none;"> {% for message in messages %} <li {% if message.tags %} class="{{ message.tags }}" {% endif %}> {{ message }} </li> {% endfor %} </ul> </div> </div> </div> {% endif %} {% block contents %}{% endblock %} <!-- Footer--> <footer class="py-3 bg-black fixed-bottom"> <div class="container px-5"><p class="m-0 text-center text-white small">Copyright © にゃっぷ 2022</p></div> </footer> <!-- Bootstrap core JS--> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> <!-- jQuery first, then Popper.js, then Bootstrap JS --> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script> </div> </body> </html>
以下はログインページをタブ複製したときに表示される内容です。
{"form": {"fields": {"login": {"label": "\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9", "value": null, "help_text": "", "errors": [], "widget": {"attrs": {"placeholder": "\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9", "autocomplete": "email"}}}, "password": {"label": "\u30d1\u30b9\u30ef\u30fc\u30c9", "value": null, "help_text": "", "errors": [], "widget": {"attrs": {"placeholder": "\u30d1\u30b9\u30ef\u30fc\u30c9", "autocomplete": "current-password"}}}, "remember": {"label": "\u30ed\u30b0\u30a4\u30f3\u3057\u305f\u307e\u307e\u306b\u3059\u308b", "value": null, "help_text": "", "errors": [], "widget": {"attrs": {}}}}, "field_order": ["login", "password", "remember"], "errors": []}, "html": "
~以降は上記のhtmlの内容です~
試したこと
表示内容を見ると最初がフォーム処理の内容で、そのあとにhtmlの内容がそのまま載っているので、
django-allauthのフォーム処理が関係して、htmlの情報を読み込めてないようなのですが、参考になる情報見つけられていません。
補足情報(FW/ツールのバージョンなど)
・django 3.2.14
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。