I would like to know if there is a way to return a substring in django after retrieving a chunk of data from a column in the database. In this case, I'm trying to retrieve data from the 'contents' column to manipulate the text available and return it.
Retrieval of question list method
def prepare_questions(subject_id, scope, sort, topic, subtopic):
question_list = Question.objects.filter(subject=subject_id)
return question_list
Model that contains contents
class Question(models.Model):
subject = models.ForeignKey(Subject)
content = models.TextField(verbose_name=_('Content'))
What I hope to do is to take question_list's data from 'contents', pass it through a substring method in python. I'm unsure of the steps I should take from here. In addition I would like the method result to be returned as part of the question_list with a new key tagged to the method return value as I do not want to override the original 'contents' value retrieved.
Any pointers or references greatly appreciated! Thanks!