یلدا ادامه داره... ❤️ ۴۰ درصد تخفیف همه دورهها
استفاده از تخفیفهاسلام بنده جنگو کار هستم و تازه دوره جنگو رو شروع کردم و موقع زدن دستور
py manage.py makemigrations
با خطا زیر مواجعه شدم
articels.Articel.created_at: (fields.E160) The options auto_now, auto_now_add, and default are mutually exclusive. Only one of these options may be present.
اگه می تونید کمک کنید
انگار تو مدل Articel و جدول created_at همزمان از auto_now و auto_now_add استفاده کردین! که اگر اینطوریه فقط از یکی باید استفاده بشه.
اگر مشکل حل نشد، کدهای مدل اپ articels رو بزارین تا ببینیم ارور از کجاست.
کد
from django.db import models
from django.utils import timezone
# Create your models here.
class Articel(models.Model):
title = models.CharField(max_length = 100)
body = models.TextField()
view = models.IntegerField(default = 0)
created_at = models.DateField(auto_now_add=True , default = timezone.now)
updated_at = models.DateField(auto_now = True)
created_at رو یا باید اینجوری برارین:
created_at = models.DateTimeField(default=timezone.now, editable=True, verbose_name='زمان انتشار')
یا اینطوری:
created_at = models.DateTimeField(auto_now_add=True, verbose_name='تاریخ ایجاد')
دوتاش همزمان نمیشه.
@electera
من همین کار رو کردم و درست شد ویدئو رو چک کردم و دیدم که غلط وارد کردم بعد اینکه درست شد ارور زیر
SystemCheckError: System check identified some issues:
ERRORS:
articels.Articel.created_at: (fields.E160) The options auto_now, auto_now_add, and default are mutually exclusive. Only one of these options may be present.
Traceback (most recent call last):
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\management\base.py", line 361, in execute
self.check()
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\management\base.py", line 436, in check
raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
articels.Articel.created_at: (fields.E160) The options auto_now, auto_now_add, and default are mutually exclusive. Only one of these options may be present.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\management\base.py", line 333, in run_from_argv
sys.exit(1)
SystemExit: 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ASUS\Desktop\mysite\roocket\manage.py", line 22, in <module>
main()
File "C:\Users\ASUS\Desktop\mysite\roocket\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\management\base.py", line 336, in run_from_argv
connections.close_all()
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\db\utils.py", line 224, in close_all
connection.close()
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\db\backends\sqlite3\base.py", line 248, in close
if not self.is_in_memory_db():
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\db\backends\sqlite3\base.py", line 367, in is_in_memory_db
return self.creation.is_in_memory_db(self.settings_dict['NAME'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\db\backends\sqlite3\creation.py", line 12, in is_in_memory_db
return database_name == ':memory:' or 'mode=memory' in database_name
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'WindowsPath' is not iterable
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟