{"id":2257,"date":"2020-11-25T11:41:56","date_gmt":"2020-11-25T02:41:56","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=2257"},"modified":"2021-04-08T17:58:42","modified_gmt":"2021-04-08T08:58:42","slug":"post-2257","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2020\/11\/25\/post-2257\/","title":{"rendered":"\u3010Django\u3011django.core.exceptions.FieldError: Unknown field(s) () specified for"},"content":{"rendered":"<h2>\u3010Django\u3011django.core.exceptions.FieldError: Unknown field(s) () specified for<\/h2>\n<p>\u306a\u304b\u306a\u304b\u60a9\u307f\u307e\u3057\u305f\u3002\u76f4\u8a33\u3059\u308c\u3070\u300c\u77e5\u3089\u306a\u3044\u30d5\u30a3\u30fc\u30eb\u30c9\u64cd\u4f5c\u3057\u3088\u3046\u3068\u3057\u3066\u308b\u3088\u300d\u3063\u3066\u4e8b\u306a\u306e\u3067\u3059\u3002<br \/>\n\u3067\u3082\u305d\u3053\u306fDjango\u521d\u5fc3\u8005\u3001\u602a\u3057\u3044\u6240\u3092\u898b\u3066\u3044\u3066\u3082\u6c17\u3065\u304b\u306a\u3044\u3068\u3044\u3046\u306d\u3002<br \/>\n\u3068\u8a00\u3046\u4e8b\u3067\u3001\u4eca\u5f8c\u306e\u70ba\u306e\u6574\u7406\u6574\u9813\u3067\u3059\u3002<\/p>\n<h3>\u307e\u305a\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u3089\u30a8\u30e9\u30fc\u76f4\u524d\u306e\u52d5\u304d\u3092\u78ba\u8a8d\u3059\u308b<\/h3>\n<p>\u3069\u3046\u3044\u3046\u30eb\u30fc\u30c8\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u52d5\u3044\u305f\u304b\u3092\u78ba\u8a8d\u3059\u308c\u3070\u300e\u4fee\u6b63\u5834\u6240\u300f\u304c\u89e3\u308a\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306e\u30a8\u30e9\u30fc\u767a\u751f\u76f4\u524d\u306e\u6d41\u308c\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true\">File \"\/code\/company\/views.py\", line 7, in &lt;module&gt;\r\nfrom .forms import InquiryForm\r\nFile \"\/code\/company\/forms.py\", line 45, in &lt;module&gt;\r\nclass CompanyCreateForm(forms.ModelForm):<\/pre>\n<p>\u52d5\u304d\u3092\u7ffb\u8a33\u3057\u3066\u307f\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<div class=\"borderBox\">\n<ol>\n<li>company\/views\u306e7\u884c\u76ee\u306b\u3042\u308bInquiryForm\u3092\u8abf\u3079\u308b\u305f\u3081\u3001company\/forms.py\u3092\u8aad\u307f\u306b\u884c\u304f\u3002<\/li>\n<li>forms.py\u306e45\u884c\u76ee\u306b\u3042\u308bCompanyCreateForm\u3092\u8aad\u307f\u306b\u884c\u304f\u3002<\/li>\n<li>\u3067\u3001\u8aad\u3082\u3046\u3068\u3057\u305f\u3089CompanyCreateForm\u306b\u66f8\u3044\u3066\u3042\u308b\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u7121\u3044\u3093\u3067\u3059\u3051\u3069...\u3002<\/li>\n<\/ol>\n<\/div>\n<p>\u3068\u8a00\u3046\u4e8b\u306f\u3001\u602a\u3057\u3044\u306e\u306f\u30c6\u30fc\u30d6\u30eb\u69cb\u6210\u3092\u7ba1\u7406\u3057\u3066\u308bModels\u3063\u3066\u4e8b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>\u8a18\u8f09\u3057\u3066\u3044\u305f\u8aa4\u3063\u305fmodels.py \u3068\u6b63\u3057\u3044models.py<\/h3>\n<p>\u307e\u305a\u306f\u6b63\u3057\u3044\u3082\u306e\u304b\u3089\u3002<\/p>\n<pre class=\"lang:default decode:true\">from django.db import models\r\n\r\nclass Company(models.Model):\r\n    \"\"\"\u4f01\u696d\u60c5\u5831\u30e2\u30c7\u30eb\"\"\"\r\n    name = models.CharField(verbose_name='\u4f01\u696d\u540d', max_length=200, blank=False)\r\n    postal_code = models.CharField(verbose_name='\u90f5\u4fbf\u756a\u53f7', max_length=7, blank=False)\r\n    prefecture = models.CharField(verbose_name='\u770c\u540d', max_length=10, blank=True)\r\n    municipalities = models.CharField(verbose_name='\u5e02\u753a\u6751', max_length=30, blank=True)\r\n    details = models.CharField(verbose_name='\u756a\u5730\u8a73\u7d30', max_length=50, blank=True)\r\n    buildings = models.CharField(verbose_name='\u5efa\u7269\u540d', max_length=150, blank=True)\r\n    tel_number = models.CharField(verbose_name='\u96fb\u8a71\u756a\u53f7', max_length=15, blank=False)\r\n    fax_number = models.CharField(verbose_name='FAX\u756a\u53f7', max_length=15, blank=True)\r\n    email = models.EmailField(verbose_name='\u4ee3\u8868\u30e1\u30fc\u30eb', blank=True)\r\n    website = models.URLField(verbose_name='\u30db\u30fc\u30e0\u30da\u30fc\u30b8', blank=True)\r\n    created_at = models.DateTimeField(verbose_name='\u4f5c\u6210\u65e5\u6642', auto_now_add=True)\r\n    updated_at = models.DateTimeField(verbose_name='\u66f4\u65b0\u65e5\u6642', auto_now=True)\r\n\r\n    class Meta:\r\n        verbose_name_plural = 'Company'\r\n\r\n        def __str__(self):\r\n            return self.name<\/pre>\n<p>\u3053\u3061\u3089\u3001\u9593\u9055\u3048\u3066\u3044\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">from django.db import models\r\n\r\nclass Company(models.Model):\r\n    \"\"\"\u4f01\u696d\u60c5\u5831\u30e2\u30c7\u30eb\"\"\"\r\n    name = models.CharField(verbose_name='\u4f01\u696d\u540d', max_length=200, blank=False),\r\n    postal_code = models.CharField(verbose_name='\u90f5\u4fbf\u756a\u53f7', max_length=7, blank=False),\r\n    prefecture = models.CharField(verbose_name='\u770c\u540d', max_length=10, blank=True),\r\n    municipalities = models.CharField(verbose_name='\u5e02\u753a\u6751', max_length=30, blank=True),\r\n    details = models.CharField(verbose_name='\u756a\u5730\u8a73\u7d30', max_length=50, blank=True),\r\n    buildings = models.CharField(verbose_name='\u5efa\u7269\u540d', max_length=150, blank=True),\r\n    tel_number = models.CharField(verbose_name='\u96fb\u8a71\u756a\u53f7', max_length=15,blank=False),\r\n    fax_number = models.CharField(verbose_name='FAX\u756a\u53f7', max_length=15, blank=True),\r\n    email = models.EmailField(verbose_name='\u4ee3\u8868\u30e1\u30fc\u30eb', blank=True)\r\n    website = models.URLField(verbose_name='\u30db\u30fc\u30e0\u30da\u30fc\u30b8', blank=True)\r\n    created_at = models.DateTimeField(verbose_name='\u4f5c\u6210\u65e5\u6642', auto_now_add=True)\r\n    updated_at = models.DateTimeField(verbose_name='\u66f4\u65b0\u65e5\u6642', auto_now=True)\r\n\r\n    class Meta:\r\n        verbose_name_plural = 'Company'\r\n\r\n        def __str__(self):\r\n            return self.name<\/pre>\n<p>NG\u7b87\u6240\u306f\u5404\u884c\u6700\u5f8c\u306e\u3010 , (\u30ab\u30f3\u30de)\u3011\u3002\u3053\u3044\u3064\u304c\u3042\u3063\u305f\u304b\u3089\u30c6\u30fc\u30d6\u30eb\u69cb\u6210\u304c\u304a\u304b\u3057\u304f\u306a\u3063\u3066\u305f\u3093\u3067\u3059\u306d\u3002<\/p>\n<h3>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u7528\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b<\/h3>\n<pre class=\"lang:default decode:true \">python manage.py makemigrations<\/pre>\n<p>\u305d\u3057\u3066\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u5b9f\u884c\u3002<\/p>\n<pre class=\"lang:default decode:true \">python manage.py migrate<\/pre>\n<p>\u3093\uff1f\u307e\u305f\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true\">You are trying to add a non-nullable field '' to company without a default; we can't do that (the database needs something to populate existing rows).<\/pre>\n<h3>NULL\u3092\u8a31\u53ef\u3057\u3066\u306a\u3044\u306e\u306b blank=False \u3059\u308b\u306a\u3068\u6012\u3089\u308c\u3066\u3044\u308b\uff1f<\/h3>\n<p>name = models.CharField(verbose_name='\u4f01\u696d\u540d', max_length=200, blank=False)<\/p>\n<p>\u3069\u3046\u3084\u3089\u3053\u3044\u3064\u304cNG\u306e\u69d8\u5b50\u3002Laravel\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3063\u3066\u7a7a\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u308b\u5f62\u3060\u3063\u305f\u304b\u3089\u5168\u304f\u610f\u8b58\u3057\u3066\u306a\u304b\u3063\u305f\u3051\u3069Django\u3067\u306f\u3053\u3053\u3089\u8fba\u3057\u3063\u304b\u308a\u3057\u3066\u306a\u3044\u3068\u30c0\u30e1\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">Please select a fix:\r\n 1) Provide a one-off default now (will be set on all existing rows with a null\r\nvalue for this column)\r\n 2) Quit, and let me add a default in models.py\r\nSelect an option:<\/pre>\n<p>1\u3092\u9078\u629e\u3059\u308b\u3068Python \u304c\u8d77\u52d5\u3057\u3066\u30b4\u30cb\u30e7\u30b4\u30cb\u30e7\u3067\u304d\u307e\u3059\u3002<br \/>\n2\u3092\u9078\u629e\u3059\u308b\u3068\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u304c\u7d42\u4e86\u3057\u307e\u3059\u3002<\/p>\n<h3>You are trying to add a non-nullable field '' to company without a default\u306e\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n<p>\u65b9\u6cd5\u306f2\u3064\u3067\u3059\u3002<\/p>\n<div class=\"paperBox\">\n<ol>\n<li>blank\u3092\u5916\u3059 \u203b\u30a8\u30e9\u30fc\u306e\u5143\u3068\u306a\u308b\u69cb\u6210\u3092\u7a4d\u307f\u8fbc\u307e\u306a\u3044<\/li>\n<li>default\u5024\u3092\u8a2d\u5b9a\u3059\u308b<\/li>\n<\/ol>\n<\/div>\n<p>default\u3092\u8a2d\u5b9a\u3059\u308b\u5834\u5408\u3001\u6b21\u306e\u3088\u3046\u306b\u66f8\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">(\u524d\u7565)\r\nprefecture = models.CharField(verbose_name='\u770c\u540d', max_length=10, default='\u65b0\u6f5f\u770c')\r\nmunicipalities = models.CharField(verbose_name='\u5e02\u753a\u6751', max_length=30, null=True)<\/pre>\n<p>defult='\u307b\u3052' \u3067\u30c7\u30d5\u30a9\u30eb\u30c8\u306b\u56fa\u5b9a\u5024\u304c\u5165\u308a\u3001null=True\u3068\u3059\u308b\u3068\u30c7\u30d5\u30a9\u30eb\u30c8\u306bNULL\u304c\u8a2d\u5b9a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3092\u69cb\u6210\u3057\u3066 python manage.py migrate \u3059\u308c\u3070\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<h3>\u90f5\u4fbf\u756a\u53f7\u3068\u304b\u96fb\u8a71\u756a\u53f7\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3067\u6570\u5024\u4ee5\u5916\u3092\u8a18\u8f09\u3067\u304d\u306a\u3044\u69d8\u306b\u3059\u308b<\/h3>\n<pre class=\"lang:default decode:true\">postal_code_regex = RegexValidator(regex=r'^[0-9]+$', message = (\"Postal Code must be entered in the format: '1234567'. Up to 7 digits allowed.\"))\r\npostal_code = models.CharField(validators=[postal_code_regex], max_length=7, verbose_name='\u90f5\u4fbf\u756a\u53f7', null=True)\r\n<\/pre>\n<p>\u3053\u3093\u306a\u5f62\u3067\u69cb\u6210\u3057\u3066\u3042\u3052\u308b\u3068Validation\u3092\u4e00\u7dd2\u306b\u8a18\u8f09\u3067\u304d\u308b\u305d\u3046\u3067\u3059\u3002<\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>models.py\u306e\u30ab\u30f3\u30de\u3001\u306a\u3093\u3067\u6c17\u4ed8\u304b\u306a\u304b\u3063\u305f\u306e\u304b...\u3002<br \/>\nLaravel\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306f\u884c\u672b\u306b\u3010;\u3011\u3092\u4ed8\u3051\u308b\u304b\u3089\u76ee\u304c\u9055\u548c\u611f\u3092\u5bdf\u77e5\u3057\u306a\u304b\u3063\u305f\u3093\u3060\u308d\u3046\u306a\u3041\u3002<\/p>\n<p>\u53cd\u7701\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3010Django\u3011django.core.exceptions.FieldError: Unknown field(s) () specified for \u306a\u304b\u306a\u304b\u60a9\u307f\u307e\u3057\u305f\u3002\u76f4\u8a33\u3059\u308c\u3070\u300c\u77e5\u3089\u306a\u3044\u30d5\u30a3\u30fc\u30eb\u30c9\u64cd\u4f5c\u3057\u3088\u3046\u3068\u3057\u3066 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2174,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"vkexunit_cta_each_option":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[38],"tags":[814,837,147,53,838,46,154,45],"class_list":["post-2257","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-memorandum","tag-django","tag-makemigrations","tag-python","tag-53","tag-838","tag-46","tag-154","tag-45"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/qol-kk.com\/wp2\/wp-content\/uploads\/2020\/11\/django.png?fit=1098%2C498&ssl=1","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/2257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/comments?post=2257"}],"version-history":[{"count":3,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/2257\/revisions"}],"predecessor-version":[{"id":2261,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/2257\/revisions\/2261"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/2174"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=2257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=2257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=2257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}