https://github.com/friskes/django-loaddata
Extended django loaddata command for uploading fixtures
https://github.com/friskes/django-loaddata
cli database django django-models fixtures json loaddata postgres python
Last synced: 4 months ago
JSON representation
Extended django loaddata command for uploading fixtures
- Host: GitHub
- URL: https://github.com/friskes/django-loaddata
- Owner: Friskes
- License: mit
- Created: 2025-02-02T17:15:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-08T16:01:07.000Z (over 1 year ago)
- Last Synced: 2025-11-18T15:10:54.768Z (7 months ago)
- Topics: cli, database, django, django-models, fixtures, json, loaddata, postgres, python
- Language: Python
- Homepage:
- Size: 25.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
## Extended django loaddata command for uploading fixtures
| Project | | Status |
|-----------|:----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| CI/CD | | [](https://github.com/Friskes/django-loaddata/actions/workflows/publish-to-pypi.yml) |
| Quality | | [](https://codecov.io/github/Friskes/django-loaddata) |
| Package | | [](https://badge.fury.io/py/django-loaddata)   |
| Meta | | [](https://github.com/python/mypy) [](https://spdx.org/licenses/) [](https://github.com/astral-sh/ruff) |
## Benefits of using this cli
1. Adds the `--insert_only` flag to the loaddata command, which filters existing database records from the fixture and leaves only new records to insert, thereby preventing overwriting of field values (which may have been changed by the user) in existing records when loaddata is run again.
2. Adds the `--check_fields` flag, which performs the same functions as the `--insert_only` flag, but additionally remembers the current fields of the loaded table when the fixture is loaded for the first time, so that when adding a new field to the table and restarting loaddata, only the records from the fixture for these new fields are successfully installed, the old fields will not be changed.
## Install
1. Install package
```bash
pip install django-loaddata
```
2. Add app name to `INSTALLED_APPS`
```python
INSTALLED_APPS = [
'django_loaddata',
]
```
3. Run django migrate
```
python manage.py migrate
```
### Command to run the program:
```
python manage.py loaddata
```
## Contributing
We would love you to contribute to `django-loaddata`, pull requests are very welcome! Please see [CONTRIBUTING.md](https://github.com/Friskes/django-loaddata/blob/main/CONTRIBUTING.md) for more information.