Reputation: 7910
I use models very frequently in forms.py
(obviously), and I now want to be able to get a form in models.py
. I can think of a convoluted way around this, but it seems like there should be a way to do this without recursive importing, but still relatively simply. Is there any way to access a form I define in forms.py
without importing it?
Upvotes: 0
Views: 24
Reputation: 45575
You can safely import forms.py
inside the function/method:
class MyModel(models.Model):
...
def my_method(self):
from my_app.forms import MyForm
...
Upvotes: 1