Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorporating existing Python program into Django website [closed]

Tags:

python

django

I need to convert an existing desktop python application into a Django powered website. To do this I will likely have several Django apps each performing certain things.

What im not sure about is where to put all the existing python files for each app. Each app will require several existing python files. For a basic Django app most of the program logic would be in views.py. However the desktop application that I will be converting is large with several python files. In other words, I can't just dump the entire application into the views.py file of a Django app.

My thinking is that inside views.py I would make calls to the various existing python files stored in a sub-directory. Im just not sure what is best practice in terms of where to put all those files? Can I just create a new folder in an app for example called 'program' which will contain all the python files.

I presume the files shouldn't go into static, because that should be used for pdf's, css, etc? Should it possibly go into templates?

Just trying to find out this is typically done. Let me know if I haven't explained myself clearly enough. Thanks.

like image 714
darkpool Avatar asked Oct 20 '22 23:10

darkpool


1 Answers

First of all, you can make views.py, models.py, etc. modules instead of single files. You can also add other modules such as core, helpers, you name it, to contain business logic code that is not necessarily a view.

For example, my relatively large django app has roughly the following structure:

my_app
  views
    __init__.py
    example_view_1.py
    example_view_2.py
    some_module
      __init__.py
      another_view.py
    ...
  models
    (all my app's models)
  helpers
    (helper modules)
  backends
    (authentication backends)
  forms
    (django forms)

third_party
  (all third party packages - I use GAE so I must upload them)
like image 93
Tzach Avatar answered Oct 22 '22 14:10

Tzach