Question

I'm stuck with a little problem, at the moment i'm developing template tags for an app, and I have to import a form, .forms import MyModelForm doesn't work because is not in the same directory ...

I did a trick for the model with the get_model('app', 'Model'), but I didn't find anything like that for forms.

My structure is really classic :

app
|-templates
|-templatestags
| |-__init__
| |-app_tags.py
|-forms.py
|-models.py
|-views.py

I want to keep my app independent from the project.

Cheers

Était-ce utile?

La solution

Try this

from ..forms import MyModelForm

For more info on imports, please read PEP 328.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top