jessilver-django-seed


Namejessilver-django-seed JSON
Version 2.0.1 PyPI version JSON
download
home_pagehttps://github.com/jessilver/django_seed
SummaryA library to facilitate the creation of fake data (seeds) in Django projects.
upload_time2025-06-22 21:30:29
maintainerNone
docs_urlNone
authorJesse Silva
requires_python>=3.7
licenseMIT License
keywords django seed fake data testing development
VCS
bugtrack_url
requirements asgiref astor build certifi cffi charset-normalizer cryptography Django docutils id idna iniconfig jaraco.classes jaraco.context jaraco.functools jeepney jessilver_django_seed keyring lxml markdown-it-py mdurl more-itertools nh3 packaging pluggy pycparser Pygments pyproject_hooks pytest readme_renderer requests requests-toolbelt rfc3986 rich SecretStorage sqlparse twine unittest-xml-reporting urllib3
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # jessilver_django_seed

A library to facilitate the creation of fake data (seeds) in Django projects, with custom management commands, modularization, selective seeder execution, and easy integration.

## Installation

Install from PyPI:
```bash
pip install jessilver_django_seed
```

## Requirements
- Python 3.7+
- Django >= 3.2

## Configuration

1. Add `'jessilver_django_seed'` to your `INSTALLED_APPS`.
2. In your `settings.py`, define:
   ```python
   SEEDER_APPS = [
       'your_app_name',
       # ...other apps
   ]
   ```
   Each app directory should contain a `seeders/` folder with your seeder files.

## Seeder Structure

Create Python files in the `seeders/` folder of your app. Example:

```python
# myapp/seeders/UserSeeder.py
from jessilver_django_seed.seeders.BaseSeeder import BaseSeeder
from myapp.models import User

class UserSeeder(BaseSeeder):
    @property
    def seeder_name(self):
        return "UserSeeder"
    def seed(self):
        for i in range(10):
            User.objects.create(username=f'user{i}')
        self.succes("10 users created!")
```

## Seed Command

Run all seeders:
```bash
python manage.py seed
```

### Selective Execution
Run only specific seeders:
```bash
python manage.py seed --only UserSeeder,ProductSeeder
```

## Seeder Creation via CLI

You can create a new seeder file automatically using the management command:

```bash
python manage.py seed --create UserSeeder --app myapp
```
- This will create a file `myapp/seeders/UserSeeder.py` with a template class if it does not already exist.
- If the app is not listed in `SEEDER_APPS` in your `settings.py`, it will be added automatically.
- The command validates the seeder class name and ensures no duplicates.

## How it works
- The library looks for all apps listed in `SEEDER_APPS`.
- For each app, it dynamically loads all Python files in the `seeders/` folder.
- It searches for classes ending with `Seeder` (exemple `UserSeeder`).

### Seed Command
- Argument `--only`: Runs only the seeders whose class names are provided.
- Interactive confirmation before execution.
- Status messages and summary at the end.

## Seeder Execution Order

Seeders are loaded and executed in alphabetical order based on their filename. You can control the execution order by naming your seeder files with numeric or alphabetical prefixes, e.g.:

```
01_UserSeeder.py
02_ProductSeeder.py
```

This ensures that seeders run in the desired sequence.

## Compatibility

All file and directory operations use Python's `os.path.join` and standard library functions, ensuring compatibility across Linux, Windows, and MacOS. No hardcoded path separators are used.

## Examples

### Product Seeder
```python
# myapp/seeders/ProductSeeder.py
from jessilver_django_seed.seeders.BaseSeeder import BaseSeeder
from myapp.models import Product

class ProductSeeder(BaseSeeder):
    @property
    def seeder_name(self):
        return "ProductSeeder"
    def seed(self):
        for i in range(5):
            Product.objects.create(name=f'Product {i}')
        self.succes("5 products created!")
```

### Running only the UserSeeder
```bash
python manage.py seed --only UserSeeder
```

## Contributing

Pull requests are welcome! Open issues for suggestions or problems.

## License
MIT

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jessilver/django_seed",
    "name": "jessilver-django-seed",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "django, seed, fake data, testing, development",
    "author": "Jesse Silva",
    "author_email": "jesse1eliseu@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/73/75/f3ac838b55c3d04e0bb65277a47064b0202cf2fe98a027692aacf97f807e/jessilver_django_seed-2.0.1.tar.gz",
    "platform": null,
    "description": "# jessilver_django_seed\n\nA library to facilitate the creation of fake data (seeds) in Django projects, with custom management commands, modularization, selective seeder execution, and easy integration.\n\n## Installation\n\nInstall from PyPI:\n```bash\npip install jessilver_django_seed\n```\n\n## Requirements\n- Python 3.7+\n- Django >= 3.2\n\n## Configuration\n\n1. Add `'jessilver_django_seed'` to your `INSTALLED_APPS`.\n2. In your `settings.py`, define:\n   ```python\n   SEEDER_APPS = [\n       'your_app_name',\n       # ...other apps\n   ]\n   ```\n   Each app directory should contain a `seeders/` folder with your seeder files.\n\n## Seeder Structure\n\nCreate Python files in the `seeders/` folder of your app. Example:\n\n```python\n# myapp/seeders/UserSeeder.py\nfrom jessilver_django_seed.seeders.BaseSeeder import BaseSeeder\nfrom myapp.models import User\n\nclass UserSeeder(BaseSeeder):\n    @property\n    def seeder_name(self):\n        return \"UserSeeder\"\n    def seed(self):\n        for i in range(10):\n            User.objects.create(username=f'user{i}')\n        self.succes(\"10 users created!\")\n```\n\n## Seed Command\n\nRun all seeders:\n```bash\npython manage.py seed\n```\n\n### Selective Execution\nRun only specific seeders:\n```bash\npython manage.py seed --only UserSeeder,ProductSeeder\n```\n\n## Seeder Creation via CLI\n\nYou can create a new seeder file automatically using the management command:\n\n```bash\npython manage.py seed --create UserSeeder --app myapp\n```\n- This will create a file `myapp/seeders/UserSeeder.py` with a template class if it does not already exist.\n- If the app is not listed in `SEEDER_APPS` in your `settings.py`, it will be added automatically.\n- The command validates the seeder class name and ensures no duplicates.\n\n## How it works\n- The library looks for all apps listed in `SEEDER_APPS`.\n- For each app, it dynamically loads all Python files in the `seeders/` folder.\n- It searches for classes ending with `Seeder` (exemple `UserSeeder`).\n\n### Seed Command\n- Argument `--only`: Runs only the seeders whose class names are provided.\n- Interactive confirmation before execution.\n- Status messages and summary at the end.\n\n## Seeder Execution Order\n\nSeeders are loaded and executed in alphabetical order based on their filename. You can control the execution order by naming your seeder files with numeric or alphabetical prefixes, e.g.:\n\n```\n01_UserSeeder.py\n02_ProductSeeder.py\n```\n\nThis ensures that seeders run in the desired sequence.\n\n## Compatibility\n\nAll file and directory operations use Python's `os.path.join` and standard library functions, ensuring compatibility across Linux, Windows, and MacOS. No hardcoded path separators are used.\n\n## Examples\n\n### Product Seeder\n```python\n# myapp/seeders/ProductSeeder.py\nfrom jessilver_django_seed.seeders.BaseSeeder import BaseSeeder\nfrom myapp.models import Product\n\nclass ProductSeeder(BaseSeeder):\n    @property\n    def seeder_name(self):\n        return \"ProductSeeder\"\n    def seed(self):\n        for i in range(5):\n            Product.objects.create(name=f'Product {i}')\n        self.succes(\"5 products created!\")\n```\n\n### Running only the UserSeeder\n```bash\npython manage.py seed --only UserSeeder\n```\n\n## Contributing\n\nPull requests are welcome! Open issues for suggestions or problems.\n\n## License\nMIT\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A library to facilitate the creation of fake data (seeds) in Django projects.",
    "version": "2.0.1",
    "project_urls": {
        "Documentation": "https://github.com/jessilver/django_seed#readme",
        "Homepage": "https://github.com/jessilver/django_seed",
        "Source": "https://github.com/jessilver/django_seed",
        "Tracker": "https://github.com/jessilver/django_seed/issues"
    },
    "split_keywords": [
        "django",
        " seed",
        " fake data",
        " testing",
        " development"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d5439aa6f270880a46c0b7f3d9323b97af41fe038ec2f4f64f280ef4ddde485d",
                "md5": "e405070cd024591219bad4c4312171e2",
                "sha256": "8199d0d6e153e007d8cbfdca45220329ddbfe5c2bb1d39f8ab23014f7d7a26c0"
            },
            "downloads": -1,
            "filename": "jessilver_django_seed-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e405070cd024591219bad4c4312171e2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 17100,
            "upload_time": "2025-06-22T21:30:28",
            "upload_time_iso_8601": "2025-06-22T21:30:28.180511Z",
            "url": "https://files.pythonhosted.org/packages/d5/43/9aa6f270880a46c0b7f3d9323b97af41fe038ec2f4f64f280ef4ddde485d/jessilver_django_seed-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7375f3ac838b55c3d04e0bb65277a47064b0202cf2fe98a027692aacf97f807e",
                "md5": "c2f1a9583d89254455b8f07474dd4488",
                "sha256": "5150d9dbf68743a89333da1e2a1a9847135211cc7207a9d6496490fa7303e0f3"
            },
            "downloads": -1,
            "filename": "jessilver_django_seed-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c2f1a9583d89254455b8f07474dd4488",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 16183,
            "upload_time": "2025-06-22T21:30:29",
            "upload_time_iso_8601": "2025-06-22T21:30:29.608150Z",
            "url": "https://files.pythonhosted.org/packages/73/75/f3ac838b55c3d04e0bb65277a47064b0202cf2fe98a027692aacf97f807e/jessilver_django_seed-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-06-22 21:30:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jessilver",
    "github_project": "django_seed",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "asgiref",
            "specs": [
                [
                    "==",
                    "3.8.1"
                ]
            ]
        },
        {
            "name": "astor",
            "specs": [
                [
                    "==",
                    "0.8.1"
                ]
            ]
        },
        {
            "name": "build",
            "specs": [
                [
                    "==",
                    "1.2.2.post1"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2025.6.15"
                ]
            ]
        },
        {
            "name": "cffi",
            "specs": [
                [
                    "==",
                    "1.17.1"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "3.4.2"
                ]
            ]
        },
        {
            "name": "cryptography",
            "specs": [
                [
                    "==",
                    "45.0.4"
                ]
            ]
        },
        {
            "name": "Django",
            "specs": [
                [
                    "==",
                    "5.2.3"
                ]
            ]
        },
        {
            "name": "docutils",
            "specs": [
                [
                    "==",
                    "0.21.2"
                ]
            ]
        },
        {
            "name": "id",
            "specs": [
                [
                    "==",
                    "1.5.0"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.10"
                ]
            ]
        },
        {
            "name": "iniconfig",
            "specs": [
                [
                    "==",
                    "2.1.0"
                ]
            ]
        },
        {
            "name": "jaraco.classes",
            "specs": [
                [
                    "==",
                    "3.4.0"
                ]
            ]
        },
        {
            "name": "jaraco.context",
            "specs": [
                [
                    "==",
                    "6.0.1"
                ]
            ]
        },
        {
            "name": "jaraco.functools",
            "specs": [
                [
                    "==",
                    "4.2.1"
                ]
            ]
        },
        {
            "name": "jeepney",
            "specs": [
                [
                    "==",
                    "0.9.0"
                ]
            ]
        },
        {
            "name": "jessilver_django_seed",
            "specs": [
                [
                    "==",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "keyring",
            "specs": [
                [
                    "==",
                    "25.6.0"
                ]
            ]
        },
        {
            "name": "lxml",
            "specs": [
                [
                    "==",
                    "5.4.0"
                ]
            ]
        },
        {
            "name": "markdown-it-py",
            "specs": [
                [
                    "==",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "mdurl",
            "specs": [
                [
                    "==",
                    "0.1.2"
                ]
            ]
        },
        {
            "name": "more-itertools",
            "specs": [
                [
                    "==",
                    "10.7.0"
                ]
            ]
        },
        {
            "name": "nh3",
            "specs": [
                [
                    "==",
                    "0.2.21"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "25.0"
                ]
            ]
        },
        {
            "name": "pluggy",
            "specs": [
                [
                    "==",
                    "1.6.0"
                ]
            ]
        },
        {
            "name": "pycparser",
            "specs": [
                [
                    "==",
                    "2.22"
                ]
            ]
        },
        {
            "name": "Pygments",
            "specs": [
                [
                    "==",
                    "2.19.2"
                ]
            ]
        },
        {
            "name": "pyproject_hooks",
            "specs": [
                [
                    "==",
                    "1.2.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.4.1"
                ]
            ]
        },
        {
            "name": "readme_renderer",
            "specs": [
                [
                    "==",
                    "44.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.32.4"
                ]
            ]
        },
        {
            "name": "requests-toolbelt",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "rfc3986",
            "specs": [
                [
                    "==",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "rich",
            "specs": [
                [
                    "==",
                    "14.0.0"
                ]
            ]
        },
        {
            "name": "SecretStorage",
            "specs": [
                [
                    "==",
                    "3.3.3"
                ]
            ]
        },
        {
            "name": "sqlparse",
            "specs": [
                [
                    "==",
                    "0.5.3"
                ]
            ]
        },
        {
            "name": "twine",
            "specs": [
                [
                    "==",
                    "6.1.0"
                ]
            ]
        },
        {
            "name": "unittest-xml-reporting",
            "specs": [
                [
                    "==",
                    "3.2.0"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "2.5.0"
                ]
            ]
        }
    ],
    "lcname": "jessilver-django-seed"
}
        
Elapsed time: 1.86297s