Я не знаю, почему я получаю эту проблему сейчас. До этого все работало нормально
System check identified no issues (0 silenced).
May 03, 2020 - 10:55:21
Django version 2.2.11, using settings 'server.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Internal Server Error: /api/signup/
Traceback (most recent call last):
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 476, in raise_uncaught_exception
raise exc
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "C:\Users\Umar\Desktop\Umar\Project\Backend\server\accounts\views.py", line 26, in post
serializer.save()
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\serializers.py", line 212, in save
self.instance = self.create(validated_data)
File "C:\Users\Umar\Desktop\Umar\Project\Backend\server\accounts\serializers.py", line 38, in create
user = User.objects.create_user(**validated_data)
File "C:\Users\Umar\Desktop\Umar\Project\Backend\server\accounts\models.py", line 25, in create_user
user.save(using=self._db)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\auth\base_user.py", line 66, in save
super().save(*args, **kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 740, in save
self.save_base(using=using, force_insert=force_insert,
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 777, in save_base
updated = self._save_table(
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 870, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 907, in _do_insert
return manager._insert([self], fields=fields, return_id=update_pk,
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\query.py", line 1186, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\sql\compiler.py", line 1375, in execute_sql
cursor.execute(sql, params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 99, in execute
return super().execute(sql, params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\cursor.py", line 48, in execute
self.result = Result(
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 753, in __init__
self.parse()
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 824, in parse
return handler(self, statement)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 959, in _insert
self._query = InsertQuery(self, self.db, self.connection_properties, sm, self._params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 351, in __init__
super().__init__(*args)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 72, in __init__
self.parse()
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 439, in parse
tok_id = self._table(2)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 358, in _table
raise MigrationError(f'Table {collection} does not exist in database')
djongo.sql2mongo.MigrationError: Table login does not exist in database
[03/May/2020 10:55:42] "POST /api/signup/ HTTP/1.1" 500 205347
Редактировать 2: Код миграции
operations = [
migrations.CreateModel(
name='User',
fields=[
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('email', models.EmailField(max_length=255, unique=True, verbose_name='email address')),
('is_active', models.BooleanField(default=True)),
('is_staff', models.BooleanField(default=False)),
('is_superuser', models.BooleanField(default=False)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='UserProfile',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('phone_number', models.CharField(max_length=10, unique=True)),
('age', models.PositiveIntegerField()),
('gender', models.CharField(choices=[('M', 'Male'), ('F', 'Female')], max_length=1)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL)),
],
),
]
Обновление 3: Новый Django Выход оболочки
System check identified no issues (0 silenced).
May 03, 2020 - 11:24:59
Django version 2.2.11, using settings 'server.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Bad Request: /api/signup/
[03/May/2020 11:25:02] "POST /api/signup/ HTTP/1.1" 400 9699
Internal Server Error: /api/signup/
Traceback (most recent call last):
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 476, in raise_uncaught_exception
raise exc
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "C:\Users\Umar\Desktop\Umar\Project\Backend\server\accounts\views.py", line 26, in post
serializer.save()
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\serializers.py", line 212, in save
self.instance = self.create(validated_data)
File "C:\Users\Umar\Desktop\Umar\Project\Backend\server\accounts\serializers.py", line 39, in create
UserProfile.objects.create(
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\query.py", line 422, in create
obj.save(force_insert=True, using=self.db)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 740, in save
self.save_base(using=using, force_insert=force_insert,
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 777, in save_base
updated = self._save_table(
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 870, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 907, in _do_insert
return manager._insert([self], fields=fields, return_id=update_pk,
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\query.py", line 1186, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\sql\compiler.py", line 1375, in execute_sql
cursor.execute(sql, params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 99, in execute
return super().execute(sql, params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\cursor.py", line 48, in execute
self.result = Result(
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 753, in __init__
self.parse()
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 824, in parse
return handler(self, statement)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 959, in _insert
self._query = InsertQuery(self, self.db, self.connection_properties, sm, self._params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 351, in __init__
super().__init__(*args)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 72, in __init__
self.parse()
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 439, in parse
tok_id = self._table(2)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 358, in _table
raise MigrationError(f'Table {collection} does not exist in database')
djongo.sql2mongo.MigrationError: Table accounts_userprofile does not exist in database
[03/May/2020 11:25:10] "POST /api/signup/ HTTP/1.1" 500 204612
Модели:
import uuid
from django.db import models
from django.contrib.auth.models import BaseUserManager, AbstractBaseUser
class UserManager(BaseUserManager):
def create_user(self, email, password=None):
if not email:
raise ValueError('Users Must Have an email address')
user = self.model(
email=self.normalize_email(email),
)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, email, password):
"""
Create and return a `User` with superuser (admin) permissions.
"""
if password is None:
raise TypeError('Superusers must have a password.')
user = self.create_user(email, password)
user.is_superuser = True
user.is_staff = True
user.save()
return user
class User(AbstractBaseUser):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
email = models.EmailField(
verbose_name='email address',
max_length=255,
unique=True
)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
# Tells Django that the UserManager class defined above should manage
# objects of this type.
objects = UserManager()
def __str__(self):
return self.email
class UserProfile(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
first_name = models.CharField(max_length=50, unique=False)
last_name = models.CharField(max_length=50, unique=False)
phone_number = models.CharField(max_length=10, unique=True, null=False, blank=False)
age = models.PositiveIntegerField(null=False, blank=False)
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
Обновление 5: Mongodb Shell, я вытащил имена БД
MongoDB server version: 4.2.6
MongoDB Enterprise Accounts-shard-0:PRIMARY> show dbs
accounts 0.000GB
accounts_userprofile 0.000GB
admin 0.000GB
local 3.731GB
login 0.000GB
Я удалял и воссоздавал миграции каждый раз после каждого обновления.
Обновление 6: я говорил вам, я использую djon go так дБ выходы уже в * оболочки * 1029, но здесь, я его еще раз :) Это все, что я имею в моей руке
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\query.py", line 422, in create
obj.save(force_insert=True, using=self.db)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 740, in save
self.save_base(using=using, force_insert=force_insert,
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 777, in save_base
updated = self._save_table(
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 870, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 907, in _do_insert
return manager._insert([self], fields=fields, return_id=update_pk,
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\query.py", line 1186, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\sql\compiler.py", line 1375, in execute_sql
cursor.execute(sql, params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 99, in execute
return super().execute(sql, params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\cursor.py", line 48, in execute
self.result = Result(
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 753, in __init__
self.parse()
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 824, in parse
return handler(self, statement)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 959, in _insert
self._query = InsertQuery(self, self.db, self.connection_properties, sm, self._params)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 351, in __init__
super().__init__(*args)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 72, in __init__
self.parse()
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 439, in parse
tok_id = self._table(2)
File "C:\Users\Umar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\djongo\sql2mongo\query.py", line 358, in _table
raise MigrationError(f'Table {collection} does not exist in database')
djongo.sql2mongo.MigrationError: Table accounts_userprofile does not exist in database
[03/May/2020 11:25:10] "POST /api/signup/ HTTP/1.1" 500 204612
fadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfads