以下は書籍から引っ張ってきた例です。問題に影響がありそうなファイルのみ書いております。
そのまま実装しています。現在開発中で、HPのお問い合わせから送信されたものをPycharmに送信するまでを目指しています。
HTML,CSSともに間違いはなく、ローカルホストからHPを開くことが可能です。さらにお問い合わせ画面にも移ります。そこで文字を打ち、送信を押すのですが、送信画面に変化はなくPycharmに反映されることはありません。これはいったい何が問題だと考えられますか?
settings.py
python
1from japweb.settings_common import * 2 3# SECURITY WARNING: keep the secret key used in production secret! 4DEBUG = True 5 6ALLOWED_HOSTS = [] 7 8LOGGING = { 9 'version': 1, 10 'disable_existing_loggers': False, 11 12 'loggers': { 13 'django': { 14 'handlers': ['console'], 15 'level': 'INFO', 16 }, 17 'diary': { 18 'handlers': ['console'], 19 'level': 'DEBUG', 20 }, 21 }, 22 23 'handlers': { 24 'console': { 25 'level': 'DEBUG', 26 'class': 'logging.StreamHandler', 27 'formatter': 'dev' 28 }, 29 }, 30 31 'formatters': { 32 'dev': { 33 'format': '\t'.join([ 34 '%(asctime)s', 35 '[%(levelname)s]', 36 '%(pathname)s(Line:%(lineno)d)', 37 '%(message)s' 38 ]) 39 }, 40 } 41} 42 43EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' 44
追記(Base.html)
HTML
1{% load static %} 2<html lang="ja"> 3<head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> 6 <meta name="descripition" content=""> 7 <meta name="author" content=""> 8 9 <title>{% block title %}{% endblock%}</title> 10 11 <!--Bootstrap core CSS--> 12 <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet"> 13 14 <!--Custom fonts for this template--> 15 <link href="https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900" rel="stylesheet"> 16 <link href="https://fonts.googleapis.com/css?family=Lato:100,100i,300,300i,400,400i,700,700i,900,900i" rel="stylesheet"> 17 18 <!--Custom styles for this template--> 19 <link href="{% static 'css/one-page-wonder.min.css' %}" rel="stylesheet"> 20 21 <!--My style--> 22 <link rel="stylesheet" type="text/css" href="{% static 'css/mystyle.css' %}"> 23 {% block head %}{% endblock %} 24</head> 25 26<body> 27 28<div id="wrapper"> 29 <!-- Navigation --> 30 <nav class="navbar navbar-expand-lg navbar-dark navbar-custom fixed-top"> 31 <div class="container"> 32 <a class="navbar-brand" href="{% url 'diary:index' %}">Squeeze Japanese</a> 33 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> 34 <span class="navbar-toggler-icon"></span> 35 </button> 36 <div class="collapse navbar-collapse" id="navbarResponsive"> 37 <ul class="navbar-nav mr-auto"> 38 <li class="nav-item {% block active_inquiry %}{% endblock%}"> 39 <a class="nav-link" href="{% url 'diary:inquiry' %}">INQUIRY</a> 40 </li> 41 </ul> 42 <ul class="navbar-nav ml-auto"> 43 <li class="nav-item"> 44 <a class="nav-link" href="#">Sign Up</a> 45 </li> 46 <li class="nav-item"> 47 <a class="nav-link" href="#">Log In</a> 48 </li> 49 </ul> 50 </div> 51 </div> 52 </nav> 53 54 {% block header %}{% endblock %} 55 56 {% block contents%}{% endblock%} 57 58 <!-- Footer --> 59 <footer class="py-5 bg-black"> 60 <div class="container"> 61 <p class="m-0 text-center text-white small">Copyright © Private Dairy 2020</p> 62 </div> 63 <!-- /.container --> 64 </footer> 65 66 <!-- Bootstrap core JavaScript --> 67 <script src="{% static 'vendor/jquery/jquery.min.js' %}"></script> 68 <script src="{% static 'vendor/bootstrap/js/bootstrap.bundle.min.js' %}"></script> 69</div> 70</body> 71</html>
追記(Inquiry.html)
HTML
1<!DOCTYPE html> 2<html lang="ja"> 3<head> 4 {% extends 'base.html'%} 5 <meta charset="UTF-8"> 6 {% block title %}Inquiry:Private Diary{% endblock %} 7 {% block active_inquiry %} active {% endblock %} 8 9 {% block contents %} 10</head> 11<body> 12<div class="container"> 13 <div class="row"> 14 <div class="my-div-style"> 15 <form method="post"> 16 {% csrf_token %} 17 {{ form.non_field_errors }} 18 {% for field in form %} 19 <div class="form-group row"> 20 <label for = "{{ field.id_for_label }}" class ="col-sm-4 col-form-label"> 21 <strong>{{ field.label_tag }}</strong> 22 </label> 23 <div class="col-sm-8"> 24 {{ field }} 25 {{ field.errors }} 26 </div> 27 </div> 28 {% endfor %} 29 30 <div class="offset-sm-4 col-sm-8"> 31 <buttun class="btn btn-primary" type="submit">submit</buttun> 32 </div> 33 </form> 34 </div> 35 </div> 36</div> 37{% endblock %} 38</body> 39</html>
追記(urls.py)
python
1from django.urls import path 2from. import views 3 4app_name = 'diary' 5urlpatterns = [ 6 path("", views.IndexView.as_view(), name="index"), 7 path('inquiry/', views.InquiryView.as_view(), name='inquiry'), 8]
追記(エラー分)
Error
1 2 32020-03-22 21:31:45,167 [WARNING] C:\Users\django\utils\log.py(Line:228) Not Found: /favicon.ico 42020-03-22 21:31:45,167 [WARNING] C:\Users\django\core\servers\basehttp.py(Line:157) GET/favicon.ico HTTP/1.1" 404 2304 5 6Traceback (most recent call last): 7handlers.py", line 138, in run 8self.finish_response() 9handlers.py", line 180, in finish_response 10self.write(data) 11handlers.py", line 274, in write 12self.send_headers() 13handlers.py", line 332, in send_headers 14self.send_preamble() 15handlers.py", line 255, in send_preamble 16('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1') 17handlers.py", line 453, in _write 18result = self.stdout.write(data) 19socketserver.py", line 799, in write 20self._sock.sendall(b) 21ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine 222020-03-22 21:31:45,167 [ERROR] C:\Users\django\core\servers\basehttp.py(Line:157) "GET /favicon.ico HTTP/1.1" 500 59 23---------------------------------------- 24Exception happened during processing of request from ('127.0.0.1', 52275) 25Traceback (most recent call last): 26handlers.py", line 138, in run 27self.finish_response() 28handlers.py", line 180, in finish_response 29self.write(data) 30handlers.py", line 274, in write 31self.send_headers() 32handlers.py", line 332, in send_headers 33self.send_preamble() 34handlers.py", line 255, in send_preamble 35('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1') 36handlers.py", line 453, in _write 37result = self.stdout.write(data) 38socketserver.py", line 799, in write 39self._sock.sendall(b) 40ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine 41 42During handling of the above exception, another exception occurred: 43 44Traceback (most recent call last): 45handlers.py", line 141, in run 46self.handle_error() 47basehttp.py", line 119, in handle_error 48super().handle_error() 49handlers.py", line 368, in handle_error 50self.finish_response() 51handlers.py", line 180, in finish_response 52self.write(data) 53handlers.py", line 274, in write 54self.send_headers() 55handlers.py", line 331, in send_headers 56if not self.origin_server or self.client_is_modern(): 57handlers.py", line 344, in client_is_modern 58return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9' 59TypeError: 'NoneType' object is not subscriptable 60 61During handling of the above exception, another exception occurred: 62 63Traceback (most recent call last): 64socketserver.py", line 650, in process_request_thread 65self.finish_request(request, client_address) 66socketserver.py", line 360, in finish_request 67self.RequestHandlerClass(request, client_address, self) 68socketserver.py", line 720, in __init__ 69self.handle() 70basehttp.py", line 174, in handle 71self.handle_one_request() 72basehttp.py", line 197, in handle_one_request 73handler.run(self.server.get_app()) 74handlers.py", line 144, in run 75self.close() 76basehttp.py", line 114, in close 77super().close() 78simple_server.py", line 35, in close 79self.status.split(' ',1)[0], self.bytes_sent 80AttributeError: 'NoneType' object has no attribute 'split'
追記(最終画像)
回答1件
あなたの回答
tips
プレビュー