Вопрос

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

Это было полезно?

Решение

Try this

from ..forms import MyModelForm

For more info on imports, please read PEP 328.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top