{"componentChunkName":"component---src-templates-post-template-js","path":"/note-how-to-troubleshoot-01-en","result":{"data":{"markdownRemark":{"id":"e4be3e35-a176-5286-aaa3-b08747fd6e5c","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/note-how-to-troubleshoot-01\">original page</a>.</p>\n</blockquote>\n<h2 id=\"introduction\" style=\"position:relative;\"><a href=\"#introduction\" aria-label=\"introduction permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Introduction</h2>\n<p>While using a Python web application framework, I ran into the following error.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">Error details:\ndjango.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:\n\nERRORS:\nauth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.\n        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.\nauth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.\n        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.\nmocrat_user.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.\n        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.\nmocrat_user.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.\n        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.\n\nSystem check identified 4 issues (0 silenced).</code></pre></div>\n<p>In the end, the cause was very basic: I had configured a custom user, but I had forgotten to set <code class=\"language-text\">AUTH_USER_MODEL</code> in Settings.</p>\n<p>By the way, the fix was simply to add the following line to <code class=\"language-text\">Settings.py</code>.</p>\n<p><code class=\"language-text\">AUTH_USER_MODEL = 'AppName.ClassName'</code></p>\n<p>This error turned out to be a perfect sample for explaining the basics of troubleshooting, so in this article I will use it to explain a basic troubleshooting approach.</p>\n<p>This is a summary of basic ways to search and think when an error occurs.</p>\n<h2 id=\"read-the-error-message-first\" style=\"position:relative;\"><a href=\"#read-the-error-message-first\" aria-label=\"read the error message first permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Read the error message first</h2>\n<p>Now then, the first step in troubleshooting is this: <strong>do not resist it—read the error message first.</strong></p>\n<p>Compilers and interpreters are very smart, so <strong>for minor problems, just reading the error message is often enough to resolve the issue.</strong><br>\nFor example, in Python, you might see output like the following when an error occurs.</p>\n<div class=\"gatsby-highlight\" data-language=\"python\"><pre class=\"language-python\"><code class=\"language-python\"><span class=\"token keyword\">print</span><span class=\"token punctuation\">(</span><span class=\"token number\">100</span> <span class=\"token operator\">+</span> <span class=\"token string\">\"Hello\"</span><span class=\"token punctuation\">)</span>\n\nTraceback <span class=\"token punctuation\">(</span>most recent call last<span class=\"token punctuation\">)</span><span class=\"token punctuation\">:</span>\nFile <span class=\"token string\">\"stdin\"</span><span class=\"token punctuation\">,</span> line <span class=\"token number\">1</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">in</span> module\nTypeError<span class=\"token punctuation\">:</span> unsupported operand <span class=\"token builtin\">type</span><span class=\"token punctuation\">(</span>s<span class=\"token punctuation\">)</span> <span class=\"token keyword\">for</span> <span class=\"token operator\">+</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'int'</span> <span class=\"token keyword\">and</span> <span class=\"token string\">'str'</span></code></pre></div>\n<p>First, right below the traceback, the location that caused the error is shown.<br>\nIn this example, it looks like the problem is on line 1.</p>\n<p>Next, the reason for the error is written there.</p>\n<p><code class=\"language-text\">TypeError: unsupported operand type(s) for +: 'int' and 'str'</code><br>\nSo it says that addition between <code class=\"language-text\">int</code> and <code class=\"language-text\">str</code> types is not supported.</p>\n<p>In this example, just by reading that, you can tell that the error happened because <code class=\"language-text\">100</code> was not enclosed in quotation marks.</p>\n<h2 id=\"search-the-error-message\" style=\"position:relative;\"><a href=\"#search-the-error-message\" aria-label=\"search the error message permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Search the error message</h2>\n<p>Now, let’s look again at the error message quoted at the beginning.</p>\n<p>There is a lot written there, but <strong>it does not mention the file name or the line number that caused the error.</strong></p>\n<p>Also, <strong>the message <code class=\"language-text\">SystemCheckError: System check identified some issues</code> appears to be related to the cause, but it is not obvious what it means.</strong></p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">Error details:\n\ndjango.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:\n\nERRORS:\nauth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.\n        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.\nauth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.\n        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.\nmocrat_user.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.\n        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.\nmocrat_user.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.\n        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.\n\nSystem check identified 4 issues (0 silenced).</code></pre></div>\n<p>At times like this, <strong>copy and paste the error message into a search engine.</strong></p>\n<p>In that case, <strong>if you paste the whole thing, the search may not work well, so narrow it down to about one sentence.</strong></p>\n<p>Also, <strong>try to use a part that does not include the names of files you created yourself.</strong></p>\n<p>In this case, <code class=\"language-text\">mocrat_user</code> is the name of a file I created myself, so I made sure not to include that part in the search.<br>\nThis is because if the name of a custom file is included in the search terms, it can become noise and keep you from getting the results you want.</p>\n<p>So let’s search for it.  </p>\n<p>First, I searched for <code class=\"language-text\">SystemCheckError: System check identified some issues</code>.</p>\n<p>Let’s start by opening the top three articles.</p>\n<p>The contents were completely different.</p>\n<p>In the first article, <code class=\"language-text\">SystemCheckError</code> was caused by a failed <code class=\"language-text\">MEDIA_URL</code> setting, the second article was about missing <code class=\"language-text\">admin.py</code> settings, and the last one was about the migration mechanism.</p>\n<p>From this, we can infer that <strong><code class=\"language-text\">SystemCheckError</code> is probably not tied to one specific phenomenon, but is instead a generic message used for errors.</strong></p>\n<h2 id=\"narrow-down-the-cause-and-search-again\" style=\"position:relative;\"><a href=\"#narrow-down-the-cause-and-search-again\" aria-label=\"narrow down the cause and search again permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Narrow down the cause and search again</h2>\n<p>In the previous section, we learned that <code class=\"language-text\">SystemCheckError</code> seems to be output for a variety of different cases.</p>\n<p>Because of that, <strong>I want to change the search terms, but before doing that I first need to narrow down the cause of the problem.</strong><br>\nIn this case, because the error message does not include a file name, and based on the results of searching for <code class=\"language-text\">SystemCheckError</code>, I could guess that the cause might be a mistake in a configuration file or permissions.</p>\n<p>Also, from the details of the error, it looks very likely that the problem is related to the <code class=\"language-text\">User</code> model.<br>\nSpecifically, there was a note about a Reverse accessor.</p>\n<p>At this point, let’s search for the sentence <code class=\"language-text\">Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.</code></p>\n<p>This time, all of the top results were articles about the same problem.<br>\nThat looked very promising.</p>\n<p>That turned out to be the correct answer: even though I had defined a custom user, I had not written <code class=\"language-text\">AUTH_USER_MODEL</code>, so the models were conflicting.</p>\n<h2 id=\"search-by-error-code\" style=\"position:relative;\"><a href=\"#search-by-error-code\" aria-label=\"search by error code permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Search by error code</h2>\n<p>This time, I was able to find the solution by searching for the error text itself, but another technique is to <strong>search by the error code</strong>.</p>\n<p>In particular, <strong>if you are using a minor system, searching by the error text may not hit the information you want.</strong><br>\nIn that case, <strong>searching with the displayed error code can sometimes lead you to official documentation and other information related to the cause,</strong> so please give it a try.</p>\n<p>In this case, the error code <code class=\"language-text\">fields.E304</code> is displayed.</p>\n<p>Because of that, the search term <code class=\"language-text\">Django fields.E304</code> also found pages about the cause of this problem and how to fix it.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>This time, I used Django troubleshooting as a theme to summarize basic knowledge such as reading error messages and how to search.</p>\n<p>There is surprisingly little information about the troubleshooting process itself, and it often feels like a field where a lot depends on individual instinct.</p>\n<p>If I find another good example in the future, I would like to introduce more detailed troubleshooting know-how, so please check back.</p>","fields":{"slug":"/note-how-to-troubleshoot-01-en","tagSlugs":["/tag/notes/","/tag/english/"]},"frontmatter":{"date":"2020-07-05","description":"In this article, I use this case study to explain the basics of troubleshooting.","tags":["Notes","English"],"title":"Troubleshooting Basics #1: Search the Error Message","socialImage":{"publicURL":"/static/dc4d8b7f8795f3c3d3489d9957d155f2/no-image.png"}}}},"pageContext":{"slug":"/note-how-to-troubleshoot-01-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}