i would like to make a model that will allow the user in the Wagtail admin site to choose a directory of images give the name of the collection in a CharField and upon a button press a collection with the given name would be created, then the images from a the given directory would then be saved to the database (so that they are avaialable in the CMS). The title of the image would be it's filename, while it's tag would be the directory name where the image is found.
I found another post on how to save Images to the database with code (image saving) but I have a problem creating collections programatically. I found here this code (from here) should work, but apparently for me it doesn't, when I do manage.py makemigrations, I get this error:
django.db.utils.IntegrityError: UNIQUE constraint failed: wagtailcore_collection.path
Do I need to provide the path in add_child? What path is it supposed to be? Thanks for any help in advance!
root_coll = Collection.get_first_root_node()
root_coll.add_child(name='testcoll')