1
Good morning guys:
Problem = add a new functionality via a mixin in Jango for a CBV.
reason = I want to create two records in two different records.
Trying =
class CreateUserMixin(object):
def post2 (self, request, *args, **kwargs):
form = self.form_class(request.POST)
if form.is_valid():
usuario = request.POST['usuario']
clave = request.POST['clave']
user = User.objects.create_user(
username=usuario,
password=clave)
user.save()
return True
class UserSystemCreateView(CreateUserMixin, CreateView):
model = UserSystem
template_name = 'new_user_system.html'
form_class = UserSystemForm
success_url = reverse_lazy('system:list_user_system')
I tried to add the post2 mthod in the Usersystemcreateview class using a mixin.... the truth I managed to do this over-writing the method post in the Usersystemcreateview class but this implies that at the time of making a ( update, delete ) I have to re-write the corresponding Methos and this is writing the same code but at once ...
Some will talk but this is only in this view but in the system I’m building I need to log in a db_table for each function so imagine always rewrite the method post....
if anyone has ever picked up this problem your help would be very well received... thank you very much for the help or guidance you can provide.