Skip to content

Using DatabaseStorage in Python3 #3

@ryanmcfall

Description

@ryanmcfall

First of all, if this code is dead, just let me know. It hasn't been touched in quite a while.

I tried to use the code as is, and ran into a problem simply executing:

from database_storage import DatabaseStorage

I believe this is due to some problems with changes between Python 2 and Python 3. I was able to make a local copy of database_storage.py and get it to work by modifying a couple of imports:

from io import StringIO
from urllib.parse import urljoin

and then changing the call to urljoin within the url method to be just

result = urljoin(self.base_url, name).replace('\\', '/')

I also had to do the following to make the Django migration framework happy:

from django.utils.deconstruct import deconstructible

@deconstructible
class DatabaseStorage(Storage):

Without this makemigrations complains that the ImageField that uses DatabaseStorage isn't serializable.

Can you verify these changes are correct, and if so, integrate them so I can reinstall the module using pip?

I can submit a pull request if you'd prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions