solo-django-admin
Django admin for non Django ORM
For now support only Tortoise ORM
https://github.com/tortoise/tortoise-orm
Install
pip install solo-django-admin
Config
- Create settings.py file and redefine DATABASES if needed because by default db engine is 'django.db.backends.sqlite3'
from solo_django_admin.core.settings import *
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv(f'{ENV_PREFIX}_DB_NAME'),
'USER': os.getenv(f'{ENV_PREFIX}_DB_USER'),
'PASSWORD': os.getenv(f'{ENV_PREFIX}_DB_PASSWORD'),
'HOST': os.getenv(f'{ENV_PREFIX}_DB_HOST'),
'PORT': os.getenv(f'{ENV_PREFIX}_DB_PORT', default=5432)
}
}
INSTALLED_APPS.append('YOR_APP_NAME')
- Create .env and/or set environments variables if needed, all values are optional
ENV_PREFIX=DJANGO_ADMIN # by default
DJANGO_ADMIN_DEBUG=True # default False
DJANGO_ADMIN_DJANGO_SETTINGS_MODULE=path_to_settings_file
DJANGO_ADMIN_DB_USER=postgres
DJANGO_ADMIN_DB_NAME=postgres
DJANGO_ADMIN_DB_HOST=localhost
DJANGO_ADMIN_DB_PASSWORD=postgres
DJANGO_ADMIN_DB_PORT=5432
DJANGO_ADMIN_STATIC_URL=/django-admin-static/ # by default
DJANGO_ADMIN_STATIC_ROOT=path_to_static_files
DJANGO_ADMIN_MEDIA_URL=/django-admin-media/ # by default
DJANGO_ADMIN_MEDIA_ROOT=path_to_media_files
DJANGO_ADMIN_ALLOWED_HOSTS=* # by default (example: https://site.com,localhost)
- Collect static
python -m solo_django_admin.manage collectstatic --settings=path_to_settings
- Migrate database
Attention! the following tables will be created in the database, they are necessary for the operation of the Django admin panel
auth_group
auth_group_permissions
auth_permission
auth_user
auth_user_groups
auth_user_user_permissions
django_admin_log
django_content_type
django_migrations
django_session
- Create superuser
python -m solo_django_admin.manage createsuperuser
- Start app
Adding models to the admin panel is no different from Django, but adding models is a little different
create your own app, for example mappers
python -m solo_django_admin.manage startapp mappers
add the same models as in your application on fastapi
models.py
from solo_django_admin.models import MapperModel
from path_to_fastapi_model import Account as FastAPIAccount
class Account(MapperModel):
fast_api_model = FastAPIAccount
admin.py
from django.contrib import admin
from .models import Account
@admin.register(Account)
class AccountAdmin(admin.ModelAdmin):
...
Don`t forget add your app to settings
INSTALLED_APPS.append('mappers')
How to use FK, ManyToMany, OneToOne etc. fields see examples
Example how to connect with FastAPI
import os
from fastapi import FastAPI
from solo_django_admin.core.asgi import application
from solo_django_admin.core.settings import BASE_DIR
from starlette.middleware.cors import CORSMiddleware
from starlette.staticfiles import StaticFiles
from path_to_your_lifespan import lifespan
def create_app():
app_ = FastAPI(lifespan=lifespan)
app_.mount(
"/django-admin-static",
StaticFiles(
directory=os.path.join(BASE_DIR, "django_admin_static_files")),
name="static",
)
app_.mount("/admin", application)
app_.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=False,
allow_methods=["*"],
allow_headers=["*"],
expose_headers=["*"],
)
# YOUR SETTINGS HERE
return app_
app = create_app()
if __name__ == '__main__':
...
Metadata
Release files for solo-django-admin 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| solo_django_admin-0.1.5.tar.gz | 8.4 kB | Without provenance | Details for solo_django_admin-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| solo_django_admin-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for solo_django_admin-0.1.5-py3-none-any.whl |
Total release size: 17.0 kB
Release files / solo_django_admin-0.1.5.tar.gz
| Download URL | solo_django_admin-0.1.5.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
433848e386eff4e298b14ad256cc0c7c83df56948fb8b182ce3a8f7c16062d37
|
|
BLAKE2b-256 checksum How to use checksums |
724256f31e8520d47a52783dc77961d7f8de3725df29735ce432f5b214e00458
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Release files / solo_django_admin-0.1.5-py3-none-any.whl
| Download URL | solo_django_admin-0.1.5-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ceddf29b7b5ddc180b78e37f5a02ae755d954dad068ada2867416d11bf0cfd4e
|
|
BLAKE2b-256 checksum How to use checksums |
7e8657320d516da17b21b2d6262d9ff1cda86eca9fd316604f776818b6a32f98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Security for solo-django-admin 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.