Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Đặt Python classes ở đâu tốt nhất trong Django project?

Bạn có thể đặt class ở đâu tùy ý.

Ví dụ

project
  foo
    bar.py
    baz.py
    qux.py

Import module qux.py bằng:

from project.foo.qux import *

Tạo thư mục con tốt hơn khi nhiều file. Ví dụ:

project
  foo
    bar.py
    baz.py
    extras
      qux.py
      quux.py