Reputation: 35
please help i get this error from python manage.py makemigrations
Migrations for 'post': post/migrations/0022_auto_20200929_1749.py - Remove field category from post - Remove field tag from post Traceback (most recent call last): File "manage.py", line 22, in main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/usr/lib/python3.8/site-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/usr/lib/python3.8/site-packages/django/core/management/init.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python3.8/site-packages/django/core/management/base.py", line 336, in run_from_argv connections.close_all() File "/usr/lib/python3.8/site-packages/django/db/utils.py", line 224, in close_all connection.close() File "/usr/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 248, in close if not self.is_in_memory_db(): File "/usr/lib/python3.8/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 "/usr/lib/python3.8/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 'PosixPath' is not iterabl
models.py from django.db import models
> # Create your models here. from django.db import models from django.utils import timezone
>
>
> class Post(models.Model):
> author = models.ForeignKey('auth.User', on_delete=models.CASCADE ,null=True)
> title = models.CharField(max_length=200,null=True)
> description=models.TextField(default='a')
> text = models.TextField(null=True)
> Img = models.ImageField(upload_to='images/',null =True)
> UserImg= models.ImageField(upload_to='images/user/',null =True)
>
> created_date = models.DateTimeField(
> default=timezone.now)
> published_date = models.DateTimeField(
> blank=True, null=True)
>
> def publish(self):
> self.published_date = timezone.now()
> self.save()
>
> def __str__(self):
> return self.title
> def approved_comments(self):
> return self.comments.filter(approved_comment=True)
>
> class Comment(models.Model):
> post = models.ForeignKey('post.Post', on_delete=models.CASCADE, related_name='comments')
> name = models.CharField(max_length=200)
> text = models.TextField()
> email=models.EmailField(null=True)
> created_date = models.DateTimeField(default=timezone.now)
> approved_comment = models.BooleanField(default=False)
>
> def approve(self):
> self.approved_comment = True
> self.save()
>
> def __str__(self):
> return self.text
Upvotes: 1
Views: 2754
Reputation: 7744
The error is somewhat misrepresented, telling it to delete a field
that doesn't exist(or may have existed before) but shouldn't be the cause of the error when making migrations.
Migrations for 'post': post/migrations/0022_auto_20200929_1749.py - Remove field category from post - Remove field tag from post Traceback
If I am correct, you may be using Django 3.1
, which moved the BASE_DIR pseudo-setting to use pathlib.Path
rather than a plain string. Support for this needed adding str()
to some places like the sqlite driver.
If you look at the definition of BASE_DIR in your settings file, is it using a Path() ? If so you can use str() around its use in your DATABASES setting, i.e. str(BASE_DIR / "something.sqlite")
.
Read here for more - Use Pathlib in Your Django Settings File
Upvotes: 1