Reputation: 72
I successfully followed this tutorial and everything seemed to be ok. I then created a Profile model and managed to create it's objects through POST requests and through the admin panel. I then created signals so the profile could be created as soon as the user registered. After some trial and error I finally made it and decided I'd flush the database. When I tried to do so and ran python manage.py flush I got this error:
raise ValueError("Table %s does not exist" % table_name)
ValueError: Table allauth_socialapp does not exist
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\arthu\Desktop\dev\env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\arthu\Desktop\dev\env\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\arthu\Desktop\dev\env\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\arthu\Desktop\dev\env\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\arthu\Desktop\dev\env\lib\site-packages\django\core\management\commands\flush.py", line 49, in handle
allow_cascade=allow_cascade)
File "C:\Users\arthu\Desktop\dev\env\lib\site-packages\django\core\management\sql.py", line 16, in sql_flush
seqs = connection.introspection.sequence_list() if reset_sequences else ()
File "C:\Users\arthu\Desktop\dev\env\lib\site-packages\django\db\backends\base\introspection.py", line 118, in sequence_list
sequence_list.extend(self.get_sequences(cursor, model._meta.db_table, model._meta.local_fields))
File "C:\Users\arthu\Desktop\dev\env\lib\site-packages\django\db\backends\sqlite3\introspection.py", line 96, in get_sequences
pk_col = self.get_primary_key_column(cursor, table_name)
File "C:\Users\arthu\Desktop\dev\env\lib\site-packages\django\db\backends\sqlite3\introspection.py", line 196, in get_primary_key_column
raise ValueError("Table %s does not exist" % table_name)
ValueError: Table allauth_socialapp does not exist
I already tried doing python manage.py migrate for each of the installed apps but nothing seems to work and already tried removing the Profile model and the receiver it is using but that doesn't solve the problem. Also tried deleting the sqlite file and all the migrations but it didn't help.
My models.py file looks like this:
class Profile(models.Model):
GENDER_CHOICES = (
('Male', 'Male'),
('Female', 'Female')
)
user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
interests = models.CharField(max_length=100, null=True)
gender = models.CharField(max_length=6, choices=GENDER_CHOICES, null=True)
def __str__(self):
return f"{self.user}'s Profile"
@receiver(user_signed_up)
def user_registered(sender, request, user, **kwargs):
print(f"Created profile for { user}")
Profile.objects.create(user=user)
"""Creates the Profile after user registers"""
and my settings.py file:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'django.contrib.sites',
'allauth',
'allauth.account',
'rest_auth.registration',
'core'
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.TokenAuthentication',
],
}
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
SITE_ID = 1
Can someone please help me with this? I have no idea what I'm supposed to do and couldn't really find the answer online.
Upvotes: 0
Views: 1638
Reputation: 72
Simply solved this by adding 'allauth.socialaccount'
to my INSTALLED_APPS
and doing the migrations. Everything works fine now.
Upvotes: 1
Reputation: 53
Try python manage.py makemigrations AppName
If this didnt work you can delete migration folder
and your database
and try.
Upvotes: 0