On Fri, 2008-07-04 at 11:08 +0200, Alex Rades wrote: > Hi, > I have a project with 3 application which could (should) share their > models. Morover, I'd like to put models into a separate directory, > splitted into multiple files. Something like: > > myproject/ > models/ > box.py > firmware.py > component.py > myapp1/ > myapp2/ > myapp3/ > > Is it possible to organize the project in this way?
Not really. Each model "belongs to" ("is defined in") a single application. All that means (and exactly what it means) is that the model's "app_name" is that application's name and there are a few cases (e.g. default database table) where we use <app_name> + <model_name> to generate identifiers. However, you might be approaching this the wrong way. Any application can import models from any other application. So if you want to split out certain pieces of business logic or presentation logic into other applications -- which isn't necessarily a bad thing -- then put those items into one app and they can import the models from the models' originating app. Now, as for putting the models into separate files: that's possible and it has to be under the models/ directory in one of your apps. The only thing to know here is that you must then set the "app_name" attribute on the inner Meta class for each model to be the name of the app directory. For example, with this structure: myapp1/ models/ component.py ... any model in component.py will have to say something like class Component(models.Model): ... class Meta: app_name = 'myapp1' So "app_name" is just the application's directory name (*just* that directory name, nothing with dots in it or anything like that). Hope that gives you some ideas. Regards, Malcolm > > Thank you > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---