you can add your attribute. your in case 'filename' as in context.
if you want to pass and use at templates side is help full when you use DetailView,ListView,CreateView,TemplateView etc generic-class-base view
there is two way
1. first way is pass argument in as_view function see here not need to pass at view side or view if you have model you can also pass at urls.py in another keyword arguments model=< Your model name >
urls.py
path('dialogs/', CodeResponseView.as_view(extra_context={'fileName':'Dialogs.py')),
Then you can access filename attribute at your template side like
Your Template file
<h1> My file name is : {{ filename }} </h1>
Output:
My file name is Dialogs.py
2. Second way assign extra_context dictionary in your view class where you define at view.py file
urls.py
path('dialogs/', CodeResponseView.as_view()),
views.py Here you not need to override a get_context_data method for pass filename
class CodeResponseView(DetailView):
extra_context={'filename':'Your File name'}
model=models.<model-name> # here your model name
Then you can access filename attribute at your template side like
Your Template file
<h1> My file name is : {{ filename }} </h1>
Output:
My file name is Your File name
This stuff may help you let me know it's answer is right or wrong .....