Frage

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

War es hilfreich?

Lösung

Try this

from ..forms import MyModelForm

For more info on imports, please read PEP 328.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top