How to organize a database in Django with several separate applications?

I'm new to Django (and the database in general), and I'm not sure how to structure the following. The sources of data that I will use for my site are:

  • the blog
  • for several different games:
    • high score list
    • user levels

If I stored data in regular files, I would only have one file for each of the above. In Django, ideally (I think), I will have a separate database for each of them, but apparently there is not yet support for multiple databases to support Django. I am worried (unnecessarily?) About storing just one database for two reasons:

  • If I screw something in one of the sections, I do not want to ruin the rest of the data.

  • When I work on one of these sections, I would like freedom to easily change the model around. Since I found out that it syncdbactually does not synchronize the database, I decided that the easiest thing to do when messing with the model is to simply erase the database and start over. Again, I'm worried about ruining the other sections. I looked at south , and this seems like more problems than it costs in the planning stages of the application (but I will change my mind later when there is really valuable data).

Part of the problem is that it’s not very convenient for me to store my data in binary format. I'm used to the text, so I can easily distinguish it, change it in the editor, etc., without going through any magic database interface (by the way, I use postgresql).

? ?

+3
4

, , . , (, ), , .

, , - . , . czarchaic, python manage.py reset app_name reset , . .

, python manage.py dumpdata > file_name.json, python manage.py loaddata file_name.json. , (: ).

- NoSQL , , , . , Django . , ModelForms. , .

+6

, . "" , Django. , . , , .

, , , /dev, , - .

, , , . , , Python .

, , "pg_dump" . , , . , , , , , , , , . , , , , .

, , , .

+4

reset

>>> python manage.py reset blog

reset INSTALLED_APPS.blog

, , , DB.

+4

Syncdb . , , , json, .

, . , , , SQL . django-admin.py SQL, script . , , , , .

Regarding the separation of sites, run them as separate sites / projects. You can have a separate settings file for each project, which allows you to run two different databases. This contrasts with the fact that the two sites are separate applications within the same project. If they are completely separate, they probably should not be in the same project unless you need to use common code.

+1
source

Source: https://habr.com/ru/post/1726282/


All Articles