-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
django-serializable-model
name can't be imported due to hyphens
#2
Comments
Hi @ninjadev999, thanks for reporting this issue :) There's two different problems here, so let me address them separately:
But addressing the question/problem directly, the actual module name of this package is currently from serializable import SerializableModel and not as You can use the workaround above for now to actually use the module. I'll create a wrapper or mirror module named |
- see #2 - in Python-land, packages are _not_ imported by their package name, but their _module_ name - see also https://stackoverflow.com/a/54599368/3431180 - and the module name of this package was `serializable`, _not_ `django-serializable-model` - also in Python-land, one cannot use the standard `import` syntax for hyphenated modules, it will actually cause a SyntaxError - but for some reason it's not illegal to do so, and is allowed both in `setuptools` naming and PyPI naming (it is discouraged by PEP8) - rename serializable.py to django_serializable_model.py - leave serializable.py and just make it a wrapper / alias of django_serialiazable_model so as not to cause a breaking change (pkg): publish `django_serializable_model` module as well - don't remove `serializable` though so as to not cause a breaking change; should remove it in v1.0.0 (docs): use `django_serializable_model` in Usage docs
- see #2 - in Python-land, packages are _not_ imported by their package name, but their _module_ name - see also https://stackoverflow.com/a/54599368/3431180 - and the module name of this package was `serializable`, _not_ `django-serializable-model` - also in Python-land, one cannot use the standard `import` syntax for hyphenated modules, it will actually cause a SyntaxError - but for some reason it's not illegal to do so, and is allowed both in `setuptools` naming and PyPI naming (it is discouraged by PEP8) - rename serializable.py to django_serializable_model.py - leave serializable.py and just make it a wrapper / alias of django_serialiazable_model so as not to cause a breaking change (pkg): publish `django_serializable_model` module as well - don't remove `serializable` though so as to not cause a breaking change; should remove it in v1.0.0 (docs): use `django_serializable_model` in Usage docs
- see #2 - in Python-land, packages are _not_ imported by their package name, but their _module_ name - see also https://stackoverflow.com/a/54599368/3431180 - and the module name of this package was `serializable`, _not_ `django-serializable-model` - also in Python-land, one cannot use the standard `import` syntax for hyphenated modules, it will actually cause a SyntaxError - but for some reason it's not illegal to do so, and is allowed both in `setuptools` naming and PyPI naming (it is discouraged by PEP8) - rename serializable.py to django_serializable_model.py - leave serializable.py and just make it a wrapper / alias of django_serialiazable_model so as not to cause a breaking change (pkg): publish `django_serializable_model` module as well - don't remove `serializable` though so as to not cause a breaking change; should remove it in v1.0.0 (docs): use `django_serializable_model` in Usage docs
@ninjadev999 the module naming issue has been resolved in v0.0.4. If you re-install with v0.0.4, you should be able to import the module as from django_serializable_model import SerializableModel Also sorry if you saw a stray comment here, that was meant for the PR, not this issue, it was moved there. |
django-serializable-model
name not working in Django 1.11django-serializable-model
name not can't be imported due to hyphens
django-serializable-model
name not can't be imported due to hyphensdjango-serializable-model
name can't be imported due to hyphens
- see agilgur5/django-serializable-model#2 - it had the same issue and its changes were cherry-picked here - in Python-land, packages are _not_ imported by their package name, but their _module_ name - see also https://stackoverflow.com/a/54599368/3431180 - and the module name of this package was `decorators`, _not_ `django-api-decorators` - also in Python-land, one cannot use the standard `import` syntax for hyphenated modules, it will actually cause a SyntaxError - but for some reason it's not illegal to do so, and is allowed both in `setuptools` naming and PyPI naming (it is discouraged by PEP8) - rename decorators.py to django_api_decorators.py - leave decorators.py and just make it a wrapper / alias of django_serialiazable_model so as not to cause a breaking change (pkg): publish `django_api_decorators` module as well - don't remove `decorators` though so as to not cause a breaking change; should remove it in v1.0.0 (docs): use `django_api_decorators` in Usage docs
- see agilgur5/django-serializable-model#2 - it had the same issue and its changes were cherry-picked here - in Python-land, packages are _not_ imported by their package name, but their _module_ name - see also https://stackoverflow.com/a/54599368/3431180 - and the module name of this package was `decorators`, _not_ `django-api-decorators` - also in Python-land, one cannot use the standard `import` syntax for hyphenated modules, it will actually cause a SyntaxError - but for some reason it's not illegal to do so, and is allowed both in `setuptools` naming and PyPI naming (it is discouraged by PEP8) - rename decorators.py to django_api_decorators.py - leave decorators.py and just make it a wrapper / alias of django_serialiazable_model so as not to cause a breaking change (pkg): publish `django_api_decorators` module as well - don't remove `decorators` though so as to not cause a breaking change; should remove it in v1.0.0 (docs): use `django_api_decorators` in Usage docs
I added this code In settings.py file after run
pip install django-serializable-model
:settings.py
But I had this error:
How can I use this package in my Django app?
I think your package name for importing must not include
-
character.The text was updated successfully, but these errors were encountered: