Это мой код, который может отправлять текстовый файл пользователю со всеми результатами набора запросов, но требуется выравнивание результатов путем удаления символов.
def save_search(request,q="deve"):
filename = "mytext.txt"
content =Buildkb.objects.values("text","knowledge","created_by_email").
filter(Q(knowledge__icontains=q)|Q(text__icontains=q))
response = HttpResponse(content, content_type='text/plain')
response['Content-Disposition'] = 'attachment; filename{0}'.format(filename)
return response
вывод: -
{'knowledge': 'Deve Category.', 'created_by_email': 'user1@gmail.com', 'text': 'Deve'}{'knowledge': 'Software development life cycle (SDLC) is a series of phases that provide a common understanding of the software building process. How the software will be realized and developed from the business understanding and requirements elicitation phase to convert these business ideas and requirements into functions and features until its usage and operation to achieve the business needs. The good software engineer should have enough knowledge on how to choose the SDLC model based on the project context and the business requirement.', 'created_by_email': 'user3@gmail.com', 'text': '1.1'}{'knowledge': 'Software development life cycle (SDLC) is a series of phases that provide a common understanding of the software building process. How the software will be realised and developed from the business understanding and requirements elicitation phase to convert these business ideas and requirements into functions and features until its usage and operation to achieve the business needs. The good software engineer should have enough knowledge on how to choose the SDLC model based on the project context and the business requirements.\n\n', 'created_by_email': 'user3@gmail.com', 'text': 'dev'}{'knowledge': ' the department develops applications http://192.168.1.200:2000/buildknowledge/', 'created_by_email': 'prakash.mutalik@gmail.com', 'text': 'development'}{'knowledge': 'Java is a general-purpose computer-programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA),meaning that compiled Java code can run on all platforms that support Java without the need for recompilation.\n\nJava applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. As of 2016, Java is one of the most popular programming languages in use, particularly for client-server web applications, with a reported 9 million developers.Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle Corporation) and released in 1995 as a core component of Sun Microsystems\' Java platform. The language derives much of its syntax from C and C , but it has fewer low-level facilities than either of them.', 'created_by_email': 'user3@gmail.com', 'text': 'java'}
Требование: -
knowledge: Deve Category.
created_by_email:'user1@gmail.com'
text: Deve
knowledge: Software development life cycle (SDLC) is a series of phases that
provide a common understanding of the software building process. How the
software will be realized and developed from the business understanding and
requirements elicitation phase to convert these business ideas and
requirements into functions and features until its usage and operation to
achieve the business needs. The good software engineer should have enough
knowledge on how to choose the SDLC model based on the project context and
the business requirement.
created_by_email: 'user3@gmail.com'
text: 1.1
knowledge: Software development life cycle (SDLC) is a series of phases
that provide a common understanding of the software building process. How
the software will be realised and developed from the business understanding
and requirements elicitation phase to convert these business ideas and
requirements into functions and features until its usage and operation to
achieve the business needs. The good software engineer should have enough
knowledge on how to choose the SDLC model based on the project context and
the business requirements.\n\n
created_by_email: 'user3@gmail.com'
text: dev
knowledge: the department develops applications
http://192.168.1.200:2000/buildknowledge/',
created_by_email: 'user4@gmail.com'
text: 'development'