We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AttributeError: 'NoneType' object has no attribute 'sites'
**Summary**
_What is the problem?_
I was installing `Kuma` on my computer.
When I run the command `docker-compose exec web ./manage.py configure_github_social`, console desk show the Error `AttributeError: 'NoneType' object has no attribute 'sites'`.

**Steps To Reproduce (STR)**
_How can we reproduce the problem?_

1. Get in [https://kuma.readthedocs.io/en/latest/installation.html#load-the-sample-database](https://kuma.readthedocs.io/en/latest/installation.html#load-the-sample-database)
2. Find the step **Enable GitHub authentication (optional)**
3. At that step I run `docker-compose exec web ./manage.py configure_github_social`, and error occured.


**Actual behavior**
_What actually happened?_
I checked the code and found that in file `kuma/attachments/management/commands/configure_github_social.py` line 75, the variable `social_app` is None. Was I got something wrong? 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kuma/attachments/management/commands/configure_github_social.py`
Content:
```
1 import fileinput
2 import os
3 import sys
4 
5 from allauth.socialaccount.models import SocialApp
6 from django.conf import settings
7 from django.contrib.sites.models import Site
8 from django.core.management.base import BaseCommand
9 
10 try:
11     input = raw_input
12 except NameError:
13     # Python3's input behaves like raw_input
14     # TODO: Delete this block when we've migrated
15     pass
16 
17 LOCALHOST = 'localhost:8000'
18 MDN_LOCALHOST = 'mdn.localhost'
19 
20 OVERWRITE_PROMPT = 'There\'s already a SocialApp for GitHub, if you want to overwrite it type "yes":'
21 GITHUB_INFO = (
22     'Visit https://github.com/settings/developers and click "New OAuth App"\n'
23     'Set "Homepage URL" to "http://mdn.localhost:8000/" and Authorization callback URL to ' +
24     '"http://mdn.localhost:8000/users/github/login/callback/" respectively'
25 )
26 ENV_INFO = 'Putting SITE_ID and DOMAIN into .env'
27 HOSTS_INFO = (
28     'Make sure your hosts file contains these lines:\n'
29     '127.0.0.1 localhost demos mdn.localhost beta.mdn.localhost wiki.mdn.localhost\n'
30     '::1             mdn.localhost beta.mdn.localhost wiki.mdn.localhost'
31 )
32 
33 
34 def overwrite_or_create_env_vars(env_vars):
35     file_path = os.path.join(os.getcwd(), '.env')
36 
37     for line in fileinput.input(file_path, inplace=True):
38         key = line.strip().split('=')[0]
39         if key not in env_vars:
40             sys.stdout.write(line)
41 
42     with open(file_path, 'a') as file:
43         file.write('\n')
44         for key, value in env_vars.items():
45             file.write(key + '=' + str(value) + '\n')
46 
47 
48 class Command(BaseCommand):
49     help = 'Configure Kuma for Sign-In with GitHub'
50 
51     def handle(self, **options):
52         print('\n')
53 
54         social_app = SocialApp.objects.filter(provider='github').first()
55         if social_app is not None and input(OVERWRITE_PROMPT) == 'yes':
56             print('\n')
57 
58             print(GITHUB_INFO)
59             client_id = input('Client ID: ').strip()
60             client_secret = input('Client Secret: ').strip()
61 
62             social_app, created = SocialApp.objects.update_or_create(
63                 provider='github',
64                 defaults={
65                     'name': 'MDN Development',
66                     'client_id': client_id,
67                     'secret': client_secret
68                 }
69             )
70 
71         site, created = Site.objects.update_or_create(
72             domain=LOCALHOST,
73             defaults={'name': LOCALHOST}
74         )
75         social_app.sites.add(site)
76 
77         print('\n')
78 
79         print(ENV_INFO)
80         overwrite_or_create_env_vars(
81             {'SITE_ID': site.id, 'DOMAIN': MDN_LOCALHOST} if site.id != settings.SITE_ID else
82             {'DOMAIN': MDN_LOCALHOST})
83 
84         print(HOSTS_INFO)
85
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/kuma/attachments/management/commands/configure_github_social.py b/kuma/attachments/management/commands/configure_github_social.py
--- a/kuma/attachments/management/commands/configure_github_social.py
+++ b/kuma/attachments/management/commands/configure_github_social.py
@@ -52,7 +52,7 @@
         print('\n')
 
         social_app = SocialApp.objects.filter(provider='github').first()
-        if social_app is not None and input(OVERWRITE_PROMPT) == 'yes':
+        if social_app is None or input(OVERWRITE_PROMPT) == 'yes':
             print('\n')
 
             print(GITHUB_INFO)

{"golden_diff": "diff --git a/kuma/attachments/management/commands/configure_github_social.py b/kuma/attachments/management/commands/configure_github_social.py\n--- a/kuma/attachments/management/commands/configure_github_social.py\n+++ b/kuma/attachments/management/commands/configure_github_social.py\n@@ -52,7 +52,7 @@\n         print('\\n')\n \n         social_app = SocialApp.objects.filter(provider='github').first()\n-        if social_app is not None and input(OVERWRITE_PROMPT) == 'yes':\n+        if social_app is None or input(OVERWRITE_PROMPT) == 'yes':\n             print('\\n')\n \n             print(GITHUB_INFO)\n", "issue": "AttributeError: 'NoneType' object has no attribute 'sites'\n**Summary**\r\n_What is the problem?_\r\nI was installing `Kuma` on my computer.\r\nWhen I run the command `docker-compose exec web ./manage.py configure_github_social`, console desk show the Error `AttributeError: 'NoneType' object has no attribute 'sites'`.\r\n\r\n**Steps To Reproduce (STR)**\r\n_How can we reproduce the problem?_\r\n\r\n1. Get in [https://kuma.readthedocs.io/en/latest/installation.html#load-the-sample-database](https://kuma.readthedocs.io/en/latest/installation.html#load-the-sample-database)\r\n2. Find the step **Enable GitHub authentication (optional)**\r\n3. At that step I run `docker-compose exec web ./manage.py configure_github_social`, and error occured.\r\n\r\n\r\n**Actual behavior**\r\n_What actually happened?_\r\nI checked the code and found that in file `kuma/attachments/management/commands/configure_github_social.py` line 75, the variable `social_app` is None. Was I got something wrong? \n", "before_files": [{"content": "import fileinput\nimport os\nimport sys\n\nfrom allauth.socialaccount.models import SocialApp\nfrom django.conf import settings\nfrom django.contrib.sites.models import Site\nfrom django.core.management.base import BaseCommand\n\ntry:\n    input = raw_input\nexcept NameError:\n    # Python3's input behaves like raw_input\n    # TODO: Delete this block when we've migrated\n    pass\n\nLOCALHOST = 'localhost:8000'\nMDN_LOCALHOST = 'mdn.localhost'\n\nOVERWRITE_PROMPT = 'There\\'s already a SocialApp for GitHub, if you want to overwrite it type \"yes\":'\nGITHUB_INFO = (\n    'Visit https://github.com/settings/developers and click \"New OAuth App\"\\n'\n    'Set \"Homepage URL\" to \"http://mdn.localhost:8000/\" and Authorization callback URL to ' +\n    '\"http://mdn.localhost:8000/users/github/login/callback/\" respectively'\n)\nENV_INFO = 'Putting SITE_ID and DOMAIN into .env'\nHOSTS_INFO = (\n    'Make sure your hosts file contains these lines:\\n'\n    '127.0.0.1 localhost demos mdn.localhost beta.mdn.localhost wiki.mdn.localhost\\n'\n    '::1             mdn.localhost beta.mdn.localhost wiki.mdn.localhost'\n)\n\n\ndef overwrite_or_create_env_vars(env_vars):\n    file_path = os.path.join(os.getcwd(), '.env')\n\n    for line in fileinput.input(file_path, inplace=True):\n        key = line.strip().split('=')[0]\n        if key not in env_vars:\n            sys.stdout.write(line)\n\n    with open(file_path, 'a') as file:\n        file.write('\\n')\n        for key, value in env_vars.items():\n            file.write(key + '=' + str(value) + '\\n')\n\n\nclass Command(BaseCommand):\n    help = 'Configure Kuma for Sign-In with GitHub'\n\n    def handle(self, **options):\n        print('\\n')\n\n        social_app = SocialApp.objects.filter(provider='github').first()\n        if social_app is not None and input(OVERWRITE_PROMPT) == 'yes':\n            print('\\n')\n\n            print(GITHUB_INFO)\n            client_id = input('Client ID: ').strip()\n            client_secret = input('Client Secret: ').strip()\n\n            social_app, created = SocialApp.objects.update_or_create(\n                provider='github',\n                defaults={\n                    'name': 'MDN Development',\n                    'client_id': client_id,\n                    'secret': client_secret\n                }\n            )\n\n        site, created = Site.objects.update_or_create(\n            domain=LOCALHOST,\n            defaults={'name': LOCALHOST}\n        )\n        social_app.sites.add(site)\n\n        print('\\n')\n\n        print(ENV_INFO)\n        overwrite_or_create_env_vars(\n            {'SITE_ID': site.id, 'DOMAIN': MDN_LOCALHOST} if site.id != settings.SITE_ID else\n            {'DOMAIN': MDN_LOCALHOST})\n\n        print(HOSTS_INFO)\n", "path": "kuma/attachments/management/commands/configure_github_social.py"}], "after_files": [{"content": "import fileinput\nimport os\nimport sys\n\nfrom allauth.socialaccount.models import SocialApp\nfrom django.conf import settings\nfrom django.contrib.sites.models import Site\nfrom django.core.management.base import BaseCommand\n\ntry:\n    input = raw_input\nexcept NameError:\n    # Python3's input behaves like raw_input\n    # TODO: Delete this block when we've migrated\n    pass\n\nLOCALHOST = 'localhost:8000'\nMDN_LOCALHOST = 'mdn.localhost'\n\nOVERWRITE_PROMPT = 'There\\'s already a SocialApp for GitHub, if you want to overwrite it type \"yes\":'\nGITHUB_INFO = (\n    'Visit https://github.com/settings/developers and click \"New OAuth App\"\\n'\n    'Set \"Homepage URL\" to \"http://mdn.localhost:8000/\" and Authorization callback URL to ' +\n    '\"http://mdn.localhost:8000/users/github/login/callback/\" respectively'\n)\nENV_INFO = 'Putting SITE_ID and DOMAIN into .env'\nHOSTS_INFO = (\n    'Make sure your hosts file contains these lines:\\n'\n    '127.0.0.1 localhost demos mdn.localhost beta.mdn.localhost wiki.mdn.localhost\\n'\n    '::1             mdn.localhost beta.mdn.localhost wiki.mdn.localhost'\n)\n\n\ndef overwrite_or_create_env_vars(env_vars):\n    file_path = os.path.join(os.getcwd(), '.env')\n\n    for line in fileinput.input(file_path, inplace=True):\n        key = line.strip().split('=')[0]\n        if key not in env_vars:\n            sys.stdout.write(line)\n\n    with open(file_path, 'a') as file:\n        file.write('\\n')\n        for key, value in env_vars.items():\n            file.write(key + '=' + str(value) + '\\n')\n\n\nclass Command(BaseCommand):\n    help = 'Configure Kuma for Sign-In with GitHub'\n\n    def handle(self, **options):\n        print('\\n')\n\n        social_app = SocialApp.objects.filter(provider='github').first()\n        if social_app is None or input(OVERWRITE_PROMPT) == 'yes':\n            print('\\n')\n\n            print(GITHUB_INFO)\n            client_id = input('Client ID: ').strip()\n            client_secret = input('Client Secret: ').strip()\n\n            social_app, created = SocialApp.objects.update_or_create(\n                provider='github',\n                defaults={\n                    'name': 'MDN Development',\n                    'client_id': client_id,\n                    'secret': client_secret\n                }\n            )\n\n        site, created = Site.objects.update_or_create(\n            domain=LOCALHOST,\n            defaults={'name': LOCALHOST}\n        )\n        social_app.sites.add(site)\n\n        print('\\n')\n\n        print(ENV_INFO)\n        overwrite_or_create_env_vars(\n            {'SITE_ID': site.id, 'DOMAIN': MDN_LOCALHOST} if site.id != settings.SITE_ID else\n            {'DOMAIN': MDN_LOCALHOST})\n\n        print(HOSTS_INFO)\n", "path": "kuma/attachments/management/commands/configure_github_social.py"}]}