How to make a string visible on a webpage using Django form fields
<p>I have a django page I've created and managed to pass values to it.
I am trying to make a text box which would contain some string.
this string can be edited and saved by the user if needed.</p>

<p>views.py</p>

<pre><code>form = EditProjectForm(project_name = project_name,store_id=store_id, `enter code here`start_date=start_date,end_date=end_date,data = request.POST or None)
context = {'someList': someList ,'form':form}
return render(request, 'editview.html', context)
</code></pre>

<p>forms.py</p>

<pre><code>class EditProjectForm(forms.Form):
    def __init__(self, *args, **kwargs):
    self.project_name = kwargs.pop('project_name')
    super(EditProjectForm, self).__init__(*args, **kwargs)
    self.fields['project_name'] = forms.CharField(self.project_name)
</code></pre>

<p>I tried using </p>

<pre><code>forms.CharField(widget=forms.TextInput(attrs={'placeholder': self.project_name }))
</code></pre>

<p>But that does not show up as editable text.</p>

<p>I would like self.project_name to be visible on my page in a text box and be editable.</p>

<p>this is what I would want the output to look like</p>

<p><a href="https://i.stack.imgur.com/Zy3yE.png" rel="nofollow"><img src="https://i.stack.imgur.com/Zy3yE.png" alt="desired output"></a></p>

<p>EDIT 1 :
I used itzmeontv tip to use 'initial'
Thanks for the 'initial'<br>
However, it seems to work only when I am not passing arguments when creating the form </p>

<p>For example. 
form = EditProjectForm() in my views.py seems to work, 
but 
form = EditProjectForm(project_name = project_name) 
and then setting 
initial = self.project_name , does not work.</p>

<p>EDIT 2  :
USing form = EditProjectForm(initial={'project_name': project_name})
seemd to work.
Thank you !!</p>

<p>Try this with <code>initial</code></p>

<pre><code>forms.CharField(widget=forms.TextInput(attrs={'placeholder': self.project_name }), initial=self.project_name)
</code></pre>

<p><strong>OR</strong></p>

<pre><code>form = EditProjectForm(#your arguments, initial={'project_name': self.project_name})
</code></pre>

python django django-forms django-views