Every time I wipe the database of my Django app during testing (or when cloning or deployin), I have to go into /admin and set up permissions and groups. Where would I put the code that would populate the DB with them and what would it look like?
相关问题
- Django __str__ returned non-string (type NoneType)
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Django restrict pages to certain users
- UnicodeEncodeError with attach_file on EmailMessag
相关文章
- Profiling Django with PyCharm
- Why doesn't Django enforce my unique_together
- MultiValueDictKeyError in Django admin
- Django/Heroku: FATAL: too many connections for rol
- Connection pooling vs persist connection mysqli
- Django is sooo slow? errno 32 broken pipe? dcramer
- Flutter - http.get fails on macos build target: Co
- Django: Replacement for the default ManyToMany Wid
For this you can use fixtures.
For example:
This will store all models of package 'auth' (Users, Groups Relations) into auth.json After Deployment you can use the following command to load:
This will restore your prev state of 'auth'.
Maybe it's good for you to switch to South, a very famous part of Django to migrate databases instead of recreating them.
You can provide fixtures with the initial required data and it will be automatically inserted when you
syncdb
. See docs