{"id":1010,"date":"2019-05-05T12:53:01","date_gmt":"2019-05-05T03:53:01","guid":{"rendered":"https:\/\/www.nblog09.com\/w\/?p=1010"},"modified":"2021-11-07T15:17:30","modified_gmt":"2021-11-07T06:17:30","slug":"django-error","status":"publish","type":"post","link":"https:\/\/www.nblog09.com\/w\/2019\/05\/05\/django-error\/","title":{"rendered":"Django\u3067\"Either provide a url or define a get_absolute_url method on the Model.\"\u3068\u51fa\u305f\u3068\u304d"},"content":{"rendered":"<p>Django\u306eCreateView, UpdateView\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u3068<span class=\"pink_span\">\"ImproperlyConfigured Either provide a url or define a get_absolute_url method on the Model.\"<\/span><\/p>\n<p>\u3068\u8868\u793a\u3055\u308c\u308b\u6642\u304c\u3042\u308b\u3002<br \/>\n\u3053\u306e\u5834\u5408\u306e\u89e3\u6c7a\u6cd5\u306b\u3064\u3044\u3066\u3001\u4ee5\u4e0b\u306b\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-1012 aligncenter\" src=\"https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2019\/05\/error-1024x808.png\" alt=\"\" width=\"509\" height=\"401\" srcset=\"https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2019\/05\/error-1024x808.png 1024w, https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2019\/05\/error-300x237.png 300w, https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2019\/05\/error-768x606.png 768w, https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2019\/05\/error.png 1066w\" sizes=\"auto, (max-width: 509px) 100vw, 509px\" \/><\/p>\n<p>\u3053\u308c\u306f\u3001Create, Update\u3057\u305f\u5f8c\u306b\u3001\u9077\u79fb\u5148\u304c\u306a\u3044\u3053\u3068\u306b\u3088\u308b\u30a8\u30e9\u30fc\u3067\u3042\u308b<\/p>\n<p>&nbsp;<\/p>\n<p>\u753b\u9762\u4e0a\u306b\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u306e\u307f\u3067\u5b9f\u969b\u306bDB\u3092\u78ba\u8a8d\u3059\u308b\u3068<strong>Create, Update\u3055\u308c\u3066\u3044\u308b\u3002<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u30a8\u30e9\u30fc\u3092\u306a\u304f\u3059\u306b\u306f\u3001<span class=\"pink_span\">models.py\u306bget_absolute_url(self)\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3001django.urls.reverse\u3092\u4f7f\u3044\u3001Create, Update\u5f8c\u306e\u9077\u79fb\u5148\u3092\u6307\u5b9a\u3059\u308c\u3070\u3088\u3044\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<div class=\"programming-gray\">\n<ul>\n<li>models.py<\/li>\n<\/ul>\n<div class=\"programming-inside\">\nfrom django.db import models<br \/>\nfrom django.urls import reverse<\/p>\n<p>class School(models.Model):<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;name = models.CharField(max_length=256)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;principal = models.CharField(max_length=256)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;location = models.CharField(max_length=256)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;def __str__(self):<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return self.name<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"codehighlight\">def get_absolute_url(self):<\/span><br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<strong># get_absolute_url\u3067\u9077\u79fb\u5148\u3092\u6307\u5b9a<\/strong><br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return <span class=\"codehighlight\">reverse(\"basic_app:detail\", kwargs={'pk': self.pk})<\/span>\n<\/div>\n<\/div>\n<p>\u3053\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3059\u308b\u3068\u3001Create, Update\u5f8c\u306bbasic_app:detail\/pk=self.pk\u306b\u9077\u79fb\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u30a8\u30e9\u30fc\u304c\u306a\u304f\u306a\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Django\u306eCreateView, UpdateView\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u3068\"ImproperlyConfigured Either provide a url or define a get_absolute_url m [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_uag_custom_page_level_css":"","_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[121],"tags":[122,14],"class_list":{"0":"post-1010","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-django","7":"tag-django","8":"tag-python","9":"entry","10":"has-post-thumbnail"},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"home-middle":false,"home-top":false,"sidebar-thumbnail":false},"uagb_author_info":{"display_name":"9nmatsumoto","author_link":"https:\/\/www.nblog09.com\/w\/author\/9nmatsumoto\/"},"uagb_comment_info":1,"uagb_excerpt":"Django\u306eCreateView, UpdateView\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u3068\"ImproperlyConfigu&hellip;","_links":{"self":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts\/1010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/comments?post=1010"}],"version-history":[{"count":7,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts\/1010\/revisions"}],"predecessor-version":[{"id":3598,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts\/1010\/revisions\/3598"}],"wp:attachment":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/media?parent=1010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/categories?post=1010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/tags?post=1010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}