I think you might be better off using https://docs.djangoproject.com/en/3.2/topics/migrations/#squashing-migrations <https://docs.djangoproject.com/en/3.2/topics/migrations/#squashing-migrations> than having it recreate all of them.
> On Mar 18, 2021, at 8:28 AM, Olivier <oza.4...@gmail.com> wrote: > > Hello, > > I've got a Django app which has over 200 migration steps. > To shorten its test loading time, I'm trying to erase all current migrations > and restart from scratch. > > I deteted and re-created my app Postgres database. > I deleted all files (but __init__.py) in migrations directory. > I typed "python manage.py makemigrations --verbosity 3". > > 1. Latest makemigrations failed with: > File > "/home/perenip/venv-flexcore/lib/python3.7/site-packages/django/db/migrations/serializer.py", > line 339, in serializer_factory > "topics/migrations/#migration-serializing" % (value, get_docs_version()) > ValueError: Cannot serialize: PosixPath('/var/www/vhosts/foo/vendorstatic') > There are some values Django cannot serialize into migration files. > For more, see > https://docs.djangoproject.com/en/3.1/topics/migrations/#migration-serializing > > If I'm not mistaken, I couldn't read any reference to the Model/Field that > triggered the error. > Should we expect an explicit mention of the faulty statement/line ? > > 2. I edited a Model within models.py with: > class Firmware(models.Model): > #filepath = models.FilePathField(path=settings.VENDOR_STATIC_ROOT, > match=settings.FIRMWARE_REGEX, recursive=True) > filepath = models.CharField(max_length=64) > display_name = models.CharField(default='foobar', max_length=32, > help_text='Value as shown in HTTP User-Agent string') > > def __str__(self): > return self.relative_path() > > def relative_path(self): > return > str(pathlib.Path(self.filepath).relative_to(settings.VENDOR_STATIC_ROOT)) > > After changing from a PathFileField to a CharFiled as shown above, I could > successfully run makemigrations. > > Doc [1] mentions Django can serialize "any Django field". Should it serialize > FilePathField ? > [1] > https://docs.djangoproject.com/en/3.1/topics/migrations/#migration-serializing > > 3. How to work around this with rewriting my app (and its tests) ? > > > Best regards > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com > <mailto:django-users+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/739e8a51-ed79-476c-9945-1076a0491b75n%40googlegroups.com > > <https://groups.google.com/d/msgid/django-users/739e8a51-ed79-476c-9945-1076a0491b75n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CE1E3974-F647-4DA3-BB6E-215B31BDC373%40gmail.com.