How to edit dict in views.py from django admin
<p>I'm working on a site to better learn the Django-framework. I've currently set up views and links to template files to display content on the main page. In my views.py file I've added a dictionary that is displays the dict value for each key in in the index.html page when it gets rendered:</p>

<p>views.py:</p>

<pre><code>def Index(request):
    projectmessage = {
    "projectMessage":"This is text from a dictionary value. written in views.py",
    "projectTitle":"Title from dict",
    "projectText": "Text from dict",
    }
return render(request,'wbdev/index.html', context=projectmessage)
</code></pre>

<p>Relevant lines in index.html:</p>

<pre><code> &lt;h3&gt;{{ projectTitle }}&lt;/h3&gt;
 &lt;p&gt;{{ projectMessage }}&lt;/p&gt;
</code></pre>

<p>I'm wondering if this could be made visible on the django admin page so that I can change the dict text directly from the GUI. Could this be done or am I way off in the sense that this is not the intended for the django admin page? From what I've red django admin parses the models.py file to set up text fields and buttons. I've followed the official django tutorial and some of the "How to tango with django" book but I cant wrap my head around how I should proceed in getting the functions that I want.</p>

<p>I'm sorry for the noob question. I will return to my books and I will probably understand how this works down the line. If anyone could help me with an explanation of how I can achieve this I will be most grateful.</p>

<p>Thank you.</p>

<p>You'll probably want to create a Model for Projects, so projects can be saved to a Database and easily displayed in the Admin. </p>

<p>Inside models.py include the following: </p>

<pre><code>class Project(models.Model):
    message = models.CharField(max_length=20)
    title = models.CharField(max_length=20)
    text = models.CharField(max_length=20)
</code></pre>

<p>Inside admin.py if you register the model it should then appear in the admin</p>

<pre><code>from dajngo.contrib import admin
from .models import Project

admin.site.register(Project)
</code></pre>

<p>Finally for your index in views.py you'll want to query the database for the project objects in question before rendering them to the template</p>

<pre><code>def index(request):
    projects = Project.objects.all()
    return render(request,'wbdev/index.html', context={'projects': projects})
</code></pre>

<p>Inside your template you can then iterate over all the projects in your database like</p>

<pre><code>{% for project in projects %}
    {{ project.message }}
    {{ project.title }}
    {{ project.text }}
{% endfor %}
</code></pre>

python django django-admin