My Django app models.py has the following class:
class Project(models.Model):
name = models.CharField(max_length=100)
...
I am using class-based views so my views.py file has the following class:
from django.views import generic
from django.views.generic.edit import CreateView
class ProjectCreate(CreateView):
model = Project
fields = ['name']
The HTTP form works perfectly and creates a new element in the database, but I need to call a function from an external python file upon the creation of a new instance of the class Project, the code I'm trying to run is:
import script
script.foo(self.object.name)
I'm trying to run the function foo inside the class ProjectCreate but I'm clueless, I tried using get and dispatch methods but it didn't work, I have read the documentation of CreateView but I couldn't find my answer.
Should I use function-based views? or is there a solution for class-based views?
Thank you very much.