When you split things out into multiple files or directories you have to remember to import them into the models.py file or the __init__.py file (if using a directory).
So if i had some models in a new file "extraModels.py" for example # In extraModels.py class ExtraModel(models.Model): pass Then in the regular "models.py" # In models.py from extraModels import ExtraModel class RegularModels(model.Model): pass The key is that you ahve to import any models in your split files into your normal models.py file. This is because Django looks for models in the models.py file only. If you make a models directory, you have to import all models you want Django to recognize into your __init__.py file within the models directory. Hopefully this makes sense, if not I can try to be more clear. Dan Harris dih0...@gmail.com On Jun 10, 4:46 pm, rahul jain <jainwolver...@gmail.com> wrote: > anyone on this ?? > > --RJ > > > > On Thu, Jun 10, 2010 at 11:34 AM, rahul jain <jainwolver...@gmail.com> wrote: > > Hi Django, > > > In my app directory, I splitted my models and views.py into multiple > > files since they start becoming very long but django is not able to > > recognize those files . > > It only recognizes models.py, views.py, tests.py (default ones). > > > So In my other files If i do this > > > from <project_name>.<app name>.models import <class name> > > > I get this error > > > ImportError: cannot import name <class name> > > > If I do the same on views.py, it just works fine. > > > Even on Eclipse I can see Django default files with different symbol > > and python files with different symbols. > > > How to solve this problem ? > > > --RJ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.