Python application for django web application

I wrote python code to complete the task. There are currently 4-5 classes that I keep in separate files. Now I would like to change all this to a database-enabled web application. I read Django tutorials, and so far I have the impression that I need to manually specify the fields and their types for each model I use. This is a bit surprising for me, since I was expecting some ORM features that would just take the existing classes that I already defined, and somehow map them to the database, distracting from me.

Is that not so? Am I missing something? It looks like I need to specify all the fields and types in the file 'models.py'.

Well, now, besides those features, does anyone have any general tips on the best way to port an object-oriented desktop application to a web application?

Thank!

+3
source share
3 answers

This is Django ORM: it maps classes to tables. What else did you expect? However, you must somehow indicate which fields are there before you can use them, and which are managed through the class models.Modeland various subclasses models.Field. You can use your classes as mixins to use existing business logic on top of field definitions.

+1
source

- , , .

, db django models.py. , introspects python db. ? ?

0

, Django .

, settings.py,

python manage.py inspectdb

models models.py . ,

python manage.py inspectdb > models.py

. :

http://docs.djangoproject.com/en/dev/howto/legacy-databases/?from=olddocs#auto-generate-the-models

0

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


All Articles