Django and Databases: Difference between revisions
Jump to navigation
Jump to search
| (One intermediate revision by the same user not shown) | |||
| Line 13: | Line 13: | ||
=== Editing models in a reusable package/app === | === Editing models in a reusable package/app === | ||
Edit `models.py` in the package. | |||
Repackage the app (from within the root package directory).<ref>[https://docs.djangoproject.com/en/1.8/intro/reusable-apps/ How to Write Reusable Apps] - Django Documentation</ref> | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
$ pip uninstall django- | $ python setup.py sdist | ||
$ pip install ~/develop/labs/shared/django-addresses/dist/django- | </syntaxhighlight> | ||
Update the package/app (See also [[Reusable Django Packages/Apps]]), e.g: | |||
<syntaxhighlight lang="bash"> | |||
$ pip uninstall django-contact_info | |||
$ pip install ~/develop/labs/shared/django-addresses/dist/django-contact_info-1.2.1.tar.gz | |||
</syntaxhighlight> | |||
Make migrations in the Django project. | |||
<syntaxhighlight lang="bash"> | |||
$ cd /path/to/django/project/ | |||
$ python manage.py makemigrations contact_info | |||
$ python manage.py migrate contact_info | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== Notes == | == Notes == | ||
<references /> | <references /> | ||
Latest revision as of 18:45, 1 September 2015
Updating database structure[edit]
Workflow [1][edit]
After changing the structure of a model in the Django code,
$ python manage.py makemigrations $ python manage.py migrate
Editing models in a reusable package/app[edit]
Edit models.py in the package.
Repackage the app (from within the root package directory).[2]
$ python setup.py sdist
Update the package/app (See also Reusable Django Packages/Apps), e.g:
$ pip uninstall django-contact_info $ pip install ~/develop/labs/shared/django-addresses/dist/django-contact_info-1.2.1.tar.gz
Make migrations in the Django project.
$ cd /path/to/django/project/ $ python manage.py makemigrations contact_info $ python manage.py migrate contact_info
Notes[edit]
- ↑ Migrations - Django Documentation (v1.8)
- ↑ How to Write Reusable Apps - Django Documentation