I'm not a Django expert (I've done one or two moderately sized projects and, years ago, did some Rails), but to the best of my knowledge:
As someone new to Django how common/acceptable is it to build your DB first and then use inspectdb to generate the models?
It's fine. The Django project provides and documents inspectdb, so there's nothing wrong with using it.
Also inevitably your DB structure will change as you go through development, what are the best practices to deal with this and making sure the layers stay in sync.
Current versions of Django provide migrations, just like Rails does. See the official docs or various tutorials, like this one. Basically:
./manage.py makemigrations to create your migrations. Django will automatically create Python code to set up a database to match your Django models.
./manage.py migrate to apply your migrations.
- Whenever you've changed your models, run
./manage.py makemigrations. Django will automatically inspect your Django models, see what's changed since the last time it ran, and generate Python code to bring the database in sync with your model changes.
Note that, if you ran
inspectdb, the generated models have
managed=False, so they're excluded from Django's migrations logic. I really like migrations, so after I made sure that my inspectdb-created models are good, I would set
managed=True and let Django manage the models from there on out. (I have no experience with this to know how well it works.)
How does syncing the DB and Django affect data existing in the DB too
Migrations modify the database in-place (as if you were manually issuing
ALTER TABLE commands or whatever), so data is left alone where possible. Changes such as adding a column may require new default data (Django can prompt you if needed); changes such as dropping a column will obviously lose data.