Skip to content
A django app to upload image
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cooggerimages index.html update May 12, 2019
media example img May 11, 2019
.gitignore gitignore May 11, 2019
LICENSE
MANIFEST.in template -> templates May 11, 2019
README.md
requirements.txt
setup.py

README.md

MIT License

cooggerimages

A django app to upload image service

Install

pip install cooggerimages

Usege

/settings.py

INSTALLED_APPS += ["cooggerimages"]


# default cooggerimages settings
COOGGERIMAGES = dict(
    folder_name="images/"
    upload_url="coogger-images/"
    upload_url_name="coogger-images"
    max_size=4 # MB
)

If you want to use a new db for images

/settings.py

DATABASES["coogger_images"] = dict(
    ENGINE="django.db.backends.sqlite3",
    NAME="coogger_images",
)

# **Example router**

DATABASE_ROUTERS = [
    "pat.to.routers.DBRouter",
]

class DBRouter:
    default_apps = [
        "admin", "auth", 
        "contenttypes", "sessions", 
        "steemconnect_auth", "cooggerapp", 
    ]
    coogger_images = [
        "cooggerimages"
    ]

    def db_for_read(self, model, **hints):
        app_label = model._meta.app_label
        if app_label in self.default_apps:
            return "default"
        elif app_label in self.coogger_images:
            return "coogger_images"

    def db_for_write(self, model, **hints):
        return self.db_for_read(model, **hints)

    def allow_relation(self, obj1, obj2, **hints):
        return True

    def allow_migrate(self, db, app_label, model_name=None, **hints):
        if db == "default":
            if app_label in self.default_apps:
                return True
        elif db == "coogger_images":
            if app_label in self.coogger_images:
                return True
        return False

/urls.py

urlpatterns.append(
    path("", include("cooggerimages.urls")
)

Then check http://127.0.0.1:8000/coogger-images/ in your project

coogger-images

You can’t perform that action at this time.