سینا قاسم خانی
8 ماه پیش توسط سینا قاسم خانی مطرح شد
0 پاسخ

مشکل در پیاده سازی mysql در cpanel با کتابخانه Django


Username: ali
Email address:
Password:
Password (again):
Error: Your passwords didn't match.
Password:
Password (again):
Traceback (most recent call last):
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 75, in execute
    return self.cursor.execute(query, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib64/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib64/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/home/wikimath/virtualenv/wikimath/3.11/lib64/python3.11/site-packages/MySQLdb/connections.py", line 257, in query
    _mysql.connection.query(self, query)
MySQLdb.OperationalError: (1054, "Unknown column 'hearts_time' in 'field list'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/wikimath/wikimath/manage.py", line 22, in <module>
    main()
  File "/home/wikimath/wikimath/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/core/management/base.py", line412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 88, in execute
    return super().execute(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/core/management/base.py", line458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 233, in handle
    self.UserModel._default_manager.db_manager(database).create_superuser(
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/contrib/auth/models.py", line 172, in create_superuser
    return self._create_user(username, email, password, **extra_fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/contrib/auth/models.py", line 155, in _create_user
    user.save(using=self._db)
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/contrib/auth/base_user.py", line 76, in save
    super().save(*args, **kwargs)
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/base.py", line 814, in save
    self.save_base(
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/base.py", line 892, in save_base
    post_save.send(
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/dispatch/dispatcher.py", line 176, in send
    return [
           ^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/wikimath/accounts/models.py", line 40, in create_profile
    Profile.objects.create(user = instance)
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/query.py", line 658,in create
    obj.save(force_insert=True, using=self.db)
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/base.py", line 814, in save
    self.save_base(
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/base.py", line 877, in save_base
    updated = self._save_table(
              ^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/base.py", line 1020,in _save_table
    results = self._do_insert(
              ^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/base.py", line 1061,in _do_insert
    return manager._insert(
           ^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/query.py", line 1805, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1822, in execute_sql
    cursor.execute(sql, params)
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 75, in execute
    return self.cursor.execute(query, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib64/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wikimath/virtualenv/wikimath/3.11/lib64/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/home/wikimath/virtualenv/wikimath/3.11/lib64/python3.11/site-packages/MySQLdb/connections.py", line 257, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (1054, "Unknown column 'hearts_time' in 'field list'")```
این از ارور بود.
این هم فایل models.py:
```from django.db import models
from django.db.models.signals import post_save
from django.contrib.auth.models import User
from django_jalali.db import models as jmodels
from django.utils.text import slugify
from random import randint

roles = (
    ('DFU','Default'),
    ('STU/TEA','Student/Teacher')
)
class Profile(models.Model):
    user = models.OneToOneField(to=User,on_delete=models.CASCADE)
    score = models.IntegerField(default=0)
    IS_ACTIVE_EMAIL = models.BooleanField(default=False)
    avator = models.ImageField(upload_to='img/avatars/',blank=True,null=True,default='bas.png')
    role = models.CharField(max_length=100,choices=roles,default='DFU')
    password = models.IntegerField(blank=True,null=True)
    baserole = models.CharField(max_length=50,blank=True,null=True)
    is_email_veri = models.BooleanField(blank = True, null = True, default = False)
    phone_number = models.CharField(max_length = 11,null = True,blank = True)
    is_phone_veri = models.BooleanField(default = False, blank = True,null = True)
    hearts = models.IntegerField(blank = True,null = True,default = 20)
    hearts_time = jmodels.jDateTimeField(auto_now_add=True)
    pool = models.IntegerField(blank = True, null = True, default = 0)
    darktheme = models.BooleanField(blank=True,null = True, default = False)
    backgroundpic = models.ImageField(blank=True,null=True,upload_to="backgroundspics/")```

ثبت پرسش جدید

به همدیگه کمک کنیم

به سینا قاسم خانی کمک کنید تا مشکل خودش را حل کند؛ این‌طور می‌توانیم با هم پیشرفت کنیم.

برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام