I think that you have to indicate app_label in your separate model
file
According to:
https://docs.djangoproject.com/en/1.4/ref/models/options/

class MyTestModel(models.Model):
    field1=models.CharField(max_length=12)
    field2=models.CharField(max_length=12)
    class Meta:
        app_label = sql

regards.

On 5 jun, 09:43, Benedict Verheyen <benedict.verhe...@gmail.com>
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 django-users@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.

Reply via email to