Name | dorm-project JSON |
Version |
0.2.13
JSON |
| download |
home_page | None |
Summary | dorm is a minimal Django wrapper that lets you use its ORM independently, without the full framework. |
upload_time | 2025-01-02 17:24:39 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
django
django orm
orm
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# dorm
[![PyPI - Version](https://img.shields.io/pypi/v/dorm-project)](https://pypi.org/project/dorm-project/)
[![PyPI - Status](https://img.shields.io/pypi/status/dorm-project)](https://pypi.org/project/dorm-project/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dorm-project)](https://pypi.org/project/dorm-project/)
[![PyPI - Versions from Framework Classifiers](https://img.shields.io/pypi/frameworkversions/django/dorm-project)](https://pypi.org/project/dorm-project/)
[![GitHub License](https://img.shields.io/github/license/daadu/dorm)](https://github.com/daadu/dorm/blob/master/LICENSE)
[![ci](https://github.com/daadu/dorm/actions/workflows/ci.yml/badge.svg)](https://github.com/daadu/dorm/actions/workflows/ci.yml)
[![cd](https://github.com/daadu/dorm/actions/workflows/cd.yml/badge.svg)](https://github.com/daadu/dorm/actions/workflows/cd.yml)
[![Stars](https://img.shields.io/github/stars/daadu/dorm?logo=github)](https://github.com/daadu/dorm/stargazers)
**dorm** is a minimal wrapper around Django that allows you to use its ORM
independently—no need for the full Django framework. Quickly integrate Django's
robust ORM into non-Django projects with a simple settings.py file.
> **Note:** This project is under active development. Use with caution.
## Why dorm?
The Django ORM is rich with features like automatic schema migrations and effortless joins.
Other python ORMs, like SQLAlchemy, often felt less intuitive in comparison.
The idea for dorm emerged from a desire to use Django's ORM without unnecessary overhead
like `manage.py`, `views.py`, or complex settings. With dorm, you get the power of Django
ORM, simplified for standalone use.
> **Note:** Since `dorm` is a lightweight wrapper around Django, all of Django's features
> remain accessible if you choose to use them. `dorm` ensures you can leverage Django's ORM
> with minimal setup and footprint.
---
## Installation
```bash
pip install dorm-project "django>=5.1.0,<5.2.0"
# Install Django to a specific version to ensure compatibility and avoid potential issues.
```
## Quick Start
#### 1. Add a settings.py file
Automatically (recommended) add using `dorm init` command:
```bash
cd <proj-root>
dorm init
```
**OR**
Manually add `settings.py` file, ensure `INSTALLED_APPS` and `DATABASES` values are set:
```python
# <proj-root>/settings.py
from pathlib import Path
BASE_DIR = Path(__file__).parent.resolve()
INSTALLED_APPS = []
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
```
#### 2. Setup dorm
Call the `dorm.setup()` method in your project's entry point (e.g., `main.py`, `app.py`, or the script that starts
your application) to initialize the Django ORM and set up the necessary database connections. This step is essential
for using the ORM independently of the full Django framework.
If you're interacting with the project via the `dorm` CLI (e.g., running migrations or using the shell or any
custom Django management command), `dorm.setup()` is automatically called for you.
> **Note:** Ensure that models are imported **after** calling `dorm.setup()` to avoid any initialization issues.
Here's how you might set it up in your entry point:
```python
# entrypoint - main.py, script.py, project.__init__.py etc
import dorm
def main():
dorm.setup()
# You can start importing and using your models from here...
if __name__ == "__main__":
main()
```
#### 3. Define models
Create a `models.py` in a package and add Django models:
```shell
mkdir -p blog
touch blog/models.py
```
Example model:
```python
# blog/models.py
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField(unique=True)
body = models.TextField()
```
#### 4. Register your app
Add your package to `INSTALLED_APPS` in `settings.py`:
```python
# <proj-root>/settings.py
INSTALLED_APPS = [
"blog",
]
```
#### 5. Run migrations
Use `dorm` CLI to manage migrations (or any django management command - like `shell`, `test`, `dbshell`, etc:
```shell
dorm makemigrations
dorm migrate
```
#### 6. Use the ORM
Access your models in an interactive shell:
```shell
dorm shell
```
Example:
```pycon
>>> from blog.models import Post
>>> post = Post(title="Hello", slug="hello-world", body="This is dorm!")
>>> post.save()
>>> Post.objects.all()
```
#### 7. Write `unittest` using the ORM
Example:
```python
# blog/tests.py
from django.test import TestCase
from blog.models import Post
class TestPostModel(TestCase):
def test_creating_object(self):
post = Post()
post.title = "Fake title"
post.slug = "fake-title"
post.post = "fake body"
post.save()
```
Run test with [Django test runner](https://docs.djangoproject.com/en/5.1/topics/testing/overview/#running-tests) via `dorm` CLI:
```shell
dorm test
```
---
## Future Plans
- Features to make `dorm` feasible with other web framework - with proper connection pooling and transactional requests. [full](https://www.reddit.com/r/django/comments/1hqy923/comment/m4tw22n/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button)
- Allow users to access admin site
Raw data
{
"_id": null,
"home_page": null,
"name": "dorm-project",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "django, django orm, orm",
"author": null,
"author_email": "Harsh Bhikadia <harsh@bhikadia.com>",
"download_url": "https://files.pythonhosted.org/packages/7e/cb/7a18b3897e85c3e8f5813a002376ec513e1b6e21693deb2f7fc32e309db7/dorm_project-0.2.13.tar.gz",
"platform": null,
"description": "# dorm\n\n[![PyPI - Version](https://img.shields.io/pypi/v/dorm-project)](https://pypi.org/project/dorm-project/)\n[![PyPI - Status](https://img.shields.io/pypi/status/dorm-project)](https://pypi.org/project/dorm-project/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dorm-project)](https://pypi.org/project/dorm-project/)\n[![PyPI - Versions from Framework Classifiers](https://img.shields.io/pypi/frameworkversions/django/dorm-project)](https://pypi.org/project/dorm-project/)\n[![GitHub License](https://img.shields.io/github/license/daadu/dorm)](https://github.com/daadu/dorm/blob/master/LICENSE)\n[![ci](https://github.com/daadu/dorm/actions/workflows/ci.yml/badge.svg)](https://github.com/daadu/dorm/actions/workflows/ci.yml)\n[![cd](https://github.com/daadu/dorm/actions/workflows/cd.yml/badge.svg)](https://github.com/daadu/dorm/actions/workflows/cd.yml)\n[![Stars](https://img.shields.io/github/stars/daadu/dorm?logo=github)](https://github.com/daadu/dorm/stargazers)\n\n**dorm** is a minimal wrapper around Django that allows you to use its ORM \nindependently\u2014no need for the full Django framework. Quickly integrate Django's \nrobust ORM into non-Django projects with a simple settings.py file.\n\n> **Note:** This project is under active development. Use with caution.\n\n## Why dorm?\nThe Django ORM is rich with features like automatic schema migrations and effortless joins. \nOther python ORMs, like SQLAlchemy, often felt less intuitive in comparison.\n\nThe idea for dorm emerged from a desire to use Django's ORM without unnecessary overhead \nlike `manage.py`, `views.py`, or complex settings. With dorm, you get the power of Django \nORM, simplified for standalone use.\n\n> **Note:** Since `dorm` is a lightweight wrapper around Django, all of Django's features \n> remain accessible if you choose to use them. `dorm` ensures you can leverage Django's ORM \n> with minimal setup and footprint.\n\n---\n\n## Installation\n\n```bash\npip install dorm-project \"django>=5.1.0,<5.2.0\" \n# Install Django to a specific version to ensure compatibility and avoid potential issues. \n```\n\n## Quick Start\n\n#### 1. Add a settings.py file\nAutomatically (recommended) add using `dorm init` command:\n```bash\ncd <proj-root>\ndorm init \n```\n**OR**\n\nManually add `settings.py` file, ensure `INSTALLED_APPS` and `DATABASES` values are set:\n```python\n# <proj-root>/settings.py\nfrom pathlib import Path\n\nBASE_DIR = Path(__file__).parent.resolve()\n\nINSTALLED_APPS = []\nDATABASES = {\n \"default\": {\n \"ENGINE\": \"django.db.backends.sqlite3\",\n \"NAME\": BASE_DIR / \"db.sqlite3\",\n }\n}\n```\n\n#### 2. Setup dorm\n\nCall the `dorm.setup()` method in your project's entry point (e.g., `main.py`, `app.py`, or the script that starts \nyour application) to initialize the Django ORM and set up the necessary database connections. This step is essential\nfor using the ORM independently of the full Django framework.\n\nIf you're interacting with the project via the `dorm` CLI (e.g., running migrations or using the shell or any \ncustom Django management command), `dorm.setup()` is automatically called for you.\n\n> **Note:** Ensure that models are imported **after** calling `dorm.setup()` to avoid any initialization issues.\n\n\nHere's how you might set it up in your entry point:\n```python\n# entrypoint - main.py, script.py, project.__init__.py etc\nimport dorm\n\ndef main():\n dorm.setup()\n \n # You can start importing and using your models from here...\n \n\nif __name__ == \"__main__\":\n main() \n```\n\n#### 3. Define models\nCreate a `models.py` in a package and add Django models:\n```shell\nmkdir -p blog\ntouch blog/models.py\n```\nExample model:\n```python\n# blog/models.py\nfrom django.db import models\n\nclass Post(models.Model):\n title = models.CharField(max_length=100)\n slug = models.SlugField(unique=True)\n body = models.TextField()\n```\n\n#### 4. Register your app\nAdd your package to `INSTALLED_APPS` in `settings.py`:\n```python\n# <proj-root>/settings.py\nINSTALLED_APPS = [\n \"blog\",\n]\n```\n\n#### 5. Run migrations\nUse `dorm` CLI to manage migrations (or any django management command - like `shell`, `test`, `dbshell`, etc:\n```shell\ndorm makemigrations\ndorm migrate\n```\n\n#### 6. Use the ORM\nAccess your models in an interactive shell:\n```shell\ndorm shell\n```\nExample:\n```pycon\n>>> from blog.models import Post\n>>> post = Post(title=\"Hello\", slug=\"hello-world\", body=\"This is dorm!\")\n>>> post.save()\n>>> Post.objects.all()\n```\n\n#### 7. Write `unittest` using the ORM\nExample:\n```python\n# blog/tests.py\nfrom django.test import TestCase\n\nfrom blog.models import Post\n\nclass TestPostModel(TestCase):\n def test_creating_object(self):\n post = Post()\n post.title = \"Fake title\"\n post.slug = \"fake-title\"\n post.post = \"fake body\"\n post.save()\n```\nRun test with [Django test runner](https://docs.djangoproject.com/en/5.1/topics/testing/overview/#running-tests) via `dorm` CLI:\n```shell\ndorm test\n```\n\n--- \n\n## Future Plans\n- Features to make `dorm` feasible with other web framework - with proper connection pooling and transactional requests. [full](https://www.reddit.com/r/django/comments/1hqy923/comment/m4tw22n/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button)\n- Allow users to access admin site",
"bugtrack_url": null,
"license": null,
"summary": "dorm is a minimal Django wrapper that lets you use its ORM independently, without the full framework.",
"version": "0.2.13",
"project_urls": {
"Source code": "https://github.com/daadu/dorm"
},
"split_keywords": [
"django",
" django orm",
" orm"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ec937781db9878119ec58639e85d9a87fdff369781b50497f5ecad2f93753c3a",
"md5": "6658abb04aed531d80aeffda61cd9f5f",
"sha256": "9ca770ff21984321f9be20e2ed9f8d9dd8fcd9273345099b15a2858b5fa26739"
},
"downloads": -1,
"filename": "dorm_project-0.2.13-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6658abb04aed531d80aeffda61cd9f5f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 7221,
"upload_time": "2025-01-02T17:24:36",
"upload_time_iso_8601": "2025-01-02T17:24:36.563988Z",
"url": "https://files.pythonhosted.org/packages/ec/93/7781db9878119ec58639e85d9a87fdff369781b50497f5ecad2f93753c3a/dorm_project-0.2.13-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7ecb7a18b3897e85c3e8f5813a002376ec513e1b6e21693deb2f7fc32e309db7",
"md5": "3b8d016070d30aed48c393427e7dc939",
"sha256": "8cdbda5bd4cd0d37918c9551b0b0144a12ca3119bb6acfdb6e8257502a6f5581"
},
"downloads": -1,
"filename": "dorm_project-0.2.13.tar.gz",
"has_sig": false,
"md5_digest": "3b8d016070d30aed48c393427e7dc939",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 13226,
"upload_time": "2025-01-02T17:24:39",
"upload_time_iso_8601": "2025-01-02T17:24:39.626332Z",
"url": "https://files.pythonhosted.org/packages/7e/cb/7a18b3897e85c3e8f5813a002376ec513e1b6e21693deb2f7fc32e309db7/dorm_project-0.2.13.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-02 17:24:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "daadu",
"github_project": "dorm",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "dorm-project"
}