Override admin path in cli with env param

This commit is contained in:
Holger Sielaff
2025-08-04 17:07:26 +02:00
parent 79c68169f6
commit 95689efbbf
11 changed files with 108 additions and 9 deletions

3
.gitignore vendored
View File

@@ -7,3 +7,6 @@ venv
!CHANGELOG.md !CHANGELOG.md
!README.md !README.md
/*.md /*.md
/venv*
/dist
/django_translatable_fields/dist/

View File

@@ -1,4 +1,4 @@
Metadata-Version: 2.1 Metadata-Version: 2.4
Name: django-translatable-fields Name: django-translatable-fields
Version: 0.1.0 Version: 0.1.0
Summary: Django plugin that mimics Odoo's translate=True functionality with admin interface integration Summary: Django plugin that mimics Odoo's translate=True functionality with admin interface integration
@@ -52,9 +52,19 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9 Requires-Python: >=3.9
Description-Content-Type: text/markdown Description-Content-Type: text/markdown
Provides-Extra: dev
Provides-Extra: drf
License-File: LICENSE License-File: LICENSE
Requires-Dist: Django>=4.2
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-django; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: django-stubs; extra == "dev"
Provides-Extra: drf
Requires-Dist: djangorestframework>=3.14.0; extra == "drf"
Dynamic: license-file
# Django Translatable Fields # Django Translatable Fields

View File

@@ -1,13 +1,13 @@
Django>=4.2 Django>=4.2
[dev] [dev]
black
django-stubs
flake8
isort
mypy
pytest pytest
pytest-django pytest-django
black
isort
flake8
mypy
django-stubs
[drf] [drf]
djangorestframework>=3.14.0 djangorestframework>=3.14.0

View File

@@ -0,0 +1,55 @@
Metadata-Version: 2.4
Name: django-translatable-fields
Version: 0.1.0
Summary: Django fields with Odoo-style translate=True functionality
Home-page: https://github.com/holger/django-translatable-fields
Author: Holger Sielaff
Author-email: holger@backender.de
Keywords: django,translation,i18n,l10n,fields,postgresql,json,odoo
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Framework :: Django :: 5.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Database
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: Django<6.0,>=4.2
Requires-Dist: psycopg2-binary>=2.9.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-django>=4.5.0; extra == "dev"
Requires-Dist: black>=22.0.0; extra == "dev"
Requires-Dist: flake8>=4.0.0; extra == "dev"
Requires-Dist: mypy>=0.991; extra == "dev"
Provides-Extra: postgres
Requires-Dist: psycopg2-binary>=2.9.0; extra == "postgres"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary
Django Translatable Fields - Odoo-style translatable fields for Django

View File

@@ -0,0 +1,13 @@
setup.py
django_translatable_fields.egg-info/PKG-INFO
django_translatable_fields.egg-info/SOURCES.txt
django_translatable_fields.egg-info/dependency_links.txt
django_translatable_fields.egg-info/entry_points.txt
django_translatable_fields.egg-info/not-zip-safe
django_translatable_fields.egg-info/requires.txt
django_translatable_fields.egg-info/top_level.txt
management/__init__.py
management/commands/__init__.py
management/commands/makemigrations_translatable.py
templatetags/__init__.py
templatetags/translatable_tags.py

View File

@@ -0,0 +1,2 @@
[console_scripts]
translatable-migrate = django_translatable_fields.management.commands.makemigrations_translatable:main

View File

@@ -0,0 +1,12 @@
Django<6.0,>=4.2
psycopg2-binary>=2.9.0
[dev]
pytest>=7.0.0
pytest-django>=4.5.0
black>=22.0.0
flake8>=4.0.0
mypy>=0.991
[postgres]
psycopg2-binary>=2.9.0

View File

@@ -0,0 +1,2 @@
management
templatetags

View File

@@ -75,7 +75,7 @@ class TranslatableMixin:
# Check if we're in admin context by looking at the call stack # Check if we're in admin context by looking at the call stack
frames = inspect.getouterframes(inspect.currentframe()) frames = inspect.getouterframes(inspect.currentframe())
is_admin_context = any('admin' in frame.filename or 'forms' in frame.filename for frame in frames[:5]) is_admin_context = os.environ.get('DJANGO_ADMIN_OVERRIDE', False) == '1' or any('admin' in frame.filename or 'forms' in frame.filename for frame in frames[:5])
logging.debug(f"{self.__class__.__name__} from_db_value - admin context: {is_admin_context}") logging.debug(f"{self.__class__.__name__} from_db_value - admin context: {is_admin_context}")