This django Migration Operation can be used to transfera fields default value to the database scheme.
Project description
# django-add-default-value
> Django Migration Operation that can be used to transfer a field’s default value
to the database scheme.
<a href="https://pypi.python.org/pypi/django-add-default-value/"><img src="https://img.shields.io/pypi/v/django-add-default-value.svg" alt="PyPi version" /></a>
<a href="./LICENSE"><img src="https://img.shields.io/github/license/3yourmind/django-add-default-value.svg" alt="badge of license" /></a>
<a href="https://github.com/3YOURMIND/django-add-default-value/pulls"><img src="https://img.shields.io/badge/PR-welcome-green.svg" alt="badge of pull request welcome" /></a>
<a href="https://www.3yourmind.com/career"><img src="https://img.shields.io/badge/3YOURMIND-Hiring-brightgreen.svg" alt="badge of hiring advertisement of 3yourmind" /></a>
<a href="https://github.com/3YOURMIND/django-add-default-value/stargazers"><img src="https://img.shields.io/github/stars/3YOURMIND/django-add-default-value.svg?style=social&label=Stars" alt="badge of github star" /></a>
## Dependencies
* [MySQL][mysql] (or compatible)
* [PostgreSQL][postgresql]
## Installation
<pre>
<a href="https://.com">pip</a> install <a href="https://pypi.org/project/django-add-default-value/">django-add-default-value</a>
</pre>
You can then use `AddDefaultValue` in your migration file to transfer the default
values to your database. Afterwards, it’s just the usual `./manage.py migrate`.
## Usage
```python
AddDefaultValue(
model_name='my_model',
name='my_field',
value='my_default'
)
```
### Example
Given the following migration:
```python
operations = [
migrations.AddField(
field=models.CharField(default='my_default', max_length=255),
model_name='my_model',
name='my_field',
),
]
```
Modify the migration to add a default value:
```diff
+from django_add_default_value import AddDefaultValue
+
operations = [
migrations.AddField(
field=models.CharField(default='my_default', max_length=255),
model_name='my_model',
name='my_field',
),
+ AddDefaultValue(
+ model_name='my_model',
+ name='my_field',
+ value='my_default'
+ )
]
```
If you check `python manage.py sqlmigrate [app name] [migration]`,
you will see that the default value now gets set.
## Contributing
First of all, thank you very much for contributing to this project. Please base
your work on the `master` branch and target `master` in your pull request.
## License
`django-add-default-value` is released under the [Apache 2.0 License](./LICENSE).
[mysql]: https://www.mysql.com
[postgresql]: https://www.postgresql.org
> Django Migration Operation that can be used to transfer a field’s default value
to the database scheme.
<a href="https://pypi.python.org/pypi/django-add-default-value/"><img src="https://img.shields.io/pypi/v/django-add-default-value.svg" alt="PyPi version" /></a>
<a href="./LICENSE"><img src="https://img.shields.io/github/license/3yourmind/django-add-default-value.svg" alt="badge of license" /></a>
<a href="https://github.com/3YOURMIND/django-add-default-value/pulls"><img src="https://img.shields.io/badge/PR-welcome-green.svg" alt="badge of pull request welcome" /></a>
<a href="https://www.3yourmind.com/career"><img src="https://img.shields.io/badge/3YOURMIND-Hiring-brightgreen.svg" alt="badge of hiring advertisement of 3yourmind" /></a>
<a href="https://github.com/3YOURMIND/django-add-default-value/stargazers"><img src="https://img.shields.io/github/stars/3YOURMIND/django-add-default-value.svg?style=social&label=Stars" alt="badge of github star" /></a>
## Dependencies
* [MySQL][mysql] (or compatible)
* [PostgreSQL][postgresql]
## Installation
<pre>
<a href="https://.com">pip</a> install <a href="https://pypi.org/project/django-add-default-value/">django-add-default-value</a>
</pre>
You can then use `AddDefaultValue` in your migration file to transfer the default
values to your database. Afterwards, it’s just the usual `./manage.py migrate`.
## Usage
```python
AddDefaultValue(
model_name='my_model',
name='my_field',
value='my_default'
)
```
### Example
Given the following migration:
```python
operations = [
migrations.AddField(
field=models.CharField(default='my_default', max_length=255),
model_name='my_model',
name='my_field',
),
]
```
Modify the migration to add a default value:
```diff
+from django_add_default_value import AddDefaultValue
+
operations = [
migrations.AddField(
field=models.CharField(default='my_default', max_length=255),
model_name='my_model',
name='my_field',
),
+ AddDefaultValue(
+ model_name='my_model',
+ name='my_field',
+ value='my_default'
+ )
]
```
If you check `python manage.py sqlmigrate [app name] [migration]`,
you will see that the default value now gets set.
## Contributing
First of all, thank you very much for contributing to this project. Please base
your work on the `master` branch and target `master` in your pull request.
## License
`django-add-default-value` is released under the [Apache 2.0 License](./LICENSE).
[mysql]: https://www.mysql.com
[postgresql]: https://www.postgresql.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-add-default-value-0.0.2.tar.gz
.
File metadata
- Download URL: django-add-default-value-0.0.2.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2e0d4eecbac624f96c7e580bae87bfad0bb0c31358273065881bf72c46b2455 |
|
MD5 | eb943c551400401b6e45c96bb0335e95 |
|
BLAKE2b-256 | 606a69211f89f36cccd86628a9cf607b74a2578a0fd2f0db5c0157e3e36bcaa1 |
File details
Details for the file django_add_default_value-0.0.2-py2-none-any.whl
.
File metadata
- Download URL: django_add_default_value-0.0.2-py2-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12b04584522c667d853eebc7703d72331c648782e1e83230228618561e9c4100 |
|
MD5 | b3df21fd3fa76304a21c5a5c19ac4d64 |
|
BLAKE2b-256 | db144a0c80ea243539353f2653bb93aab14dc939a3a56217a53bbe621b767e9d |