0

in django 1.6, I have a commands for make analysis over the database, with a set of functions.

├── management
│   ├── __init__.py
│   └── commands
│       ├── __init__.py
│       ├── analysis.py

I like break the analysis.py in a set of files (maybe a module ...). what is the correct directory structure for a module use for a django command ?

maybe like this ... ?

├── management
│   ├── __init__.py
│   ├── analysis_module
│   └── commands
│       ├── __init__.py
│       ├── analysis.py

and the test for the analysis_module, what is the correct ubication for the test of analysis_module ?

JuanPablo
  • 23,792
  • 39
  • 118
  • 164
  • Seems reasonable to me. [This answer](http://stackoverflow.com/questions/5836075/are-there-any-purposes-for-the-management-folder-in-django-other-than-commands) implies that the `management` directory is not much used, so I doubt there's any risk to putting your common code there. – Kevin Christopher Henry Apr 19 '14 at 19:23
  • If the analysis module is potentially reusable I would move it out of your app altogether and just import it in your `analysis.py` command. I like to keep django apps/modules and non-django/python modules separate where possible – Timmy O'Mahony Apr 24 '14 at 09:18
  • @TimmyO'Mahony yes, I'm thinking in a solution like you comment, and I added this as answer. but I not sure if is the correct way to import ... – JuanPablo Apr 24 '14 at 12:31

1 Answers1

0

a option, put the code modude out of django project

├── analysis_module
├── test
├── django_project
│   ├── app
│   │   ├── __init__.py
│   │   ├── admin.py
│   │   ├── management
│   │   │   ├── __init__.py
│   │   │   └── commands
│   │   │       ├── __init__.py
│   │   │       └── analysis.py
│   │   ├── models.py
│   │   ├── tests.py
│   │   ├── urls.pyc
│   │   └── views.py
│   └── django_proyect
│       ├── __init__.py
│       ├── settings.py
│       ├── urls.py
│       └── wsgi.py

but for this, I need add the module to path to the sys.path maybe in manage.py

# manage.py
sys.path.append(os.path.abspath(__file__ + '/../../'))

and import from the analysis command

# analysis.py
import analysis_module

with this I can put the test for analysis_module separately.

JuanPablo
  • 23,792
  • 39
  • 118
  • 164