1

I have a problem in my code

from mailbox import Message
from django.db import models
from django.conf import settings
        

class MyMessage(Message):
    class Meta:
        Proxy = True

    def creattask(self):
        task = Task(title=self.subject)


class Task(models.Model):
    title = models.CharField(max_length=256)

I want to fill title attribute of Task model from subject Message model. for that, I use createtask function.

However, when I go to the admin page I found Task(title) model empty !! any help, please !!

Quba
  • 4,776
  • 7
  • 34
  • 60
ZouhairNj
  • 11
  • 2
  • You have save the instance you are creating. https://docs.djangoproject.com/en/3.0/ref/models/instances/#django.db.models.Model.save or use `create` method on the manager directly https://docs.djangoproject.com/en/3.0/ref/models/querysets/#django.db.models.query.QuerySet.create – Quba Jul 01 '20 at 10:10
  • i saved the instance , how can i create method for teste it !!? – ZouhairNj Jul 07 '20 at 11:01

1 Answers1

0

yes i saved the instance

 def save(self, **kwargs):
     # some business rules here
     super(Task, self).save()

but title field still empty

ZouhairNj
  • 11
  • 2