I was looking to do something like this, but for a Django management command: Python argparse: How to insert newline in the help text?
            Asked
            
        
        
            Active
            
        
            Viewed 5,338 times
        
    2 Answers
28
            From the documentation
You can customize the instance by overriding this method and calling super() with kwargs of ArgumentParser parameters.
By overriding create_parser method
you can set the formatter_class of the ArgumentParser:
from argparse import RawTextHelpFormatter
from django.core.management.base import BaseCommand
class Command(BaseCommand):
    def create_parser(self, *args, **kwargs):
        parser = super(Command, self).create_parser(*args, **kwargs)
        parser.formatter_class = RawTextHelpFormatter
        return parser
 
    
    
        oglop
        
- 1,175
- 1
- 9
- 15
 
    
    
        Seán Hayes
        
- 4,060
- 4
- 33
- 48
- 
                    2Sure would be nice to have multiline help text be the default for management commands project wide. – shacker Sep 08 '17 at 21:32
- 
                    1How do you apply this to `help_text`? – alias51 May 31 '21 at 11:41
- 
                    Unclear or partial answer. How to use this with `help_text`. Can you please state the elaborated answer – ajinzrathod Sep 08 '21 at 08:34
4
            
            
        You can insert the new line in help_text by entering the HTML 
 tag
For e.g.
name=models.Charfield(max_length=10, help_text="Enter First name or <br/> Enter full name")
 
    
    
        OM Tiwari
        
- 75
- 2
- 
                    4This is not for a django management command, but Model field help text to be displayed in admin. – smido Mar 06 '20 at 09:42
