I'm pretty sure you can't have a folder named models and that your models file needs to be called models.py -- unless you use some sort of a 'hack' to work around it. I remember seeing a bug posted about this issue which was pretty easily google-able. I just don't remember the bug number off hand, sorry. Basically, it's just the way that Django finds your models when running syncdb and the ORM.
On Tue, Jun 5, 2012 at 3:43 AM, Benedict Verheyen < [email protected]> wrote: > Hi, > > > as the title says, in a new project (django trunk), my model isn't found > by syncdb. > However, when I run a shell_plus (I use django extensions), then I can > import it without a problem. > So from sql.models.mytestmodel import MyTestModel works. > syncdb doens't produce any errors, it just doesn't find the model. > > I usually split my models in seperate files and import them in the > __init__.py file in the same > directory as the models. The command is the same as described above. > > from sql.models.mytestmodel import MyTestModel > > It's also the first time I am laying out my project in a different way. My > project layout looks like this. > In the project directory, I have a directory apps where the apps of the > project are placed. > Then inside the sql app, I have a forms, models and views directory. > In the models directory I have the __init__.py with the aformetioned > import line. > > adminsql > ├── adminsql > │ ├── apps > │ │ └── sql > │ │ ├── forms > │ │ ├── models > │ │ │ ├── __init__.py > │ │ │ ├── mytestmodel.py > │ │ ├── tests.py > │ │ ├── urls.py > │ │ └── views > │ │ ├── __init__.py > │ │ ├── views_test.py > │ ├── __init__.py > │ ├── settings_dev.py > │ ├── settings.py > │ ├── templates > │ │ ├── adminsql > │ │ └── sql > │ │ └── test.html > │ ├── urls.py > │ ├── wsgi.py > ├── deploy > ├── docs > ├── logs > ├── manage.py > ├── media > ├── README > ├── static > > The models is nothing special as this project is a test app to port my > multiprocess program to Django > with celery. > > from django.db import models > class MyTestModel(models.Model): > field1=models.CharField(max_length=12) > field2=models.CharField(max_length=12) > > In my settings.py: > ... > # Add apps to the path, so the sql app is found > project_path = os.path.dirname(os.path.abspath(__file__)) > app_path = os.path.abspath(os.path.join(project_path,"apps")) > sys.path.append(app_path) > ... > INSTALLED_APPS = ( > ... > 'sql', > ) > > All works, I can run the code in a browser, only the part fails where a > result is written to the db > because of course the model related table doesn't exist. > > Any ideas? > > Regards, > Benedict > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to [email protected]. > 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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. 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.

