How to store ManyToManyField field in String?

I created a Document model to store content for a Case model. A case model can have multiple Document objects. But I also have to store these Document objects in Case model for using them in filters.

But when I want to see the converted_content in Django admin or print in the terminal or database it's stored as <memory at 0x13083c580>. How can I store them properly?

models

class Document(Model):
    file_path = models.CharField(max_length=250)
    converted_content = models.TextField()

class Case(Model):
    documents = models.ManyToManyField(Document, blank=True, related_name='document')

views

def upload(self, request, pk):
    obj = get_object_or_404(Case, id=pk)
    content = "done"
    document = Document.objects.create(file_path=upload.file.url, 
    converted_content=content)
    obj.documents.add(document)
    for checked_object in obj.documents.all():
        print(checked_object.converted_content) // <memory at 0x13083c580>
Back to Top