title: How to return single object in a Django model and view
body: <p>I would like to return a very basic, single paragraph from a model but I don't know how or which is the best approach. It's a simple description textField (maindescription) that I would like to be able to change in the future instead of hard-coding it. It has to be simple way but I just could find a good example. Would appreciate any help on how to properly write the view and retrieve it in the template.</p>
  <p><strong>model.py</strong></p>
  <pre><code>from autoslug import AutoSlugField
  from model_utils.models import TimeStampedModel
  from time import strftime, gmtime
  # Receive the pre_delete signal and delete the file associated with the model instance.
  from django.db.models.signals import pre_delete
  from django.dispatch.dispatcher import receiver
  
  class Song(models.Model):
      author = models.CharField(&quot;Author&quot;, max_length=255) 
      song_name = models.CharField(&quot;Song Name&quot;, max_length=255)
      slug = AutoSlugField(&quot;Soundtrack&quot;, unique=True, always_update=False, populate_from=&quot;song_name&quot;)
      created_date = models.DateTimeField(auto_now_add=True)
      updated_date = models.DateTimeField(auto_now=True)
      audio_file = models.FileField(upload_to='mp3s/', blank=True)
  
      def __str__(self):
          return self.song_name
  
  class MainDescription(models.Model):    
      main_description = models.TextField()
      slug = AutoSlugField(&quot;Main Description&quot;, unique=True, always_update=False, populate_from=&quot;main_description&quot;)
      
      def __str__(self):
          return self.main_description
  </code></pre>
  <p><strong>view.py</strong></p>
  <pre><code>from django.views.generic import ListView, DetailView
  from .models import Song, MainDescription
  
  class SongListView(ListView):
      model = Song
  
  # Overwrite the default get_context_data function
  def get_context_data(self, **kwargs):
      # Call the base implementation first to get a context
      context = super().get_context_data(**kwargs)
      # Add extra information here, like the first MainDescription Object
      context['main_description'] = MainDescription.objects.first()
      return context
  </code></pre>
  <p><strong>admin.py</strong></p>
  <pre><code>from django.contrib import admin
  from .models import Song, MainDescription
  
  admin.site.register(Song)
  admin.site.register(MainDescription)
  </code></pre>
  <p><strong>urls.py</strong></p>
  <pre><code>from django.urls import path
  from . import views
  
  app_name = &quot;music&quot;
  urlpatterns = [
      path(
          route='',
          view=views.SongListView.as_view(),
          name='list'
      ),
  ]
  </code></pre>
  <p><strong>song_list.html</strong></p>
  <pre><code>{% extends 'base.html' %}
  
  {% block content %}
  &lt;div class=&quot;container&quot;&gt;
  &lt;p&gt;{{ main_description.main_description }}&lt;/p&gt;
  &lt;/div&gt;
  &lt;ul class=&quot;playlist show&quot; id=&quot;playlist&quot;&gt;
  {% for song in song_list %}
      &lt;li audioURL=&quot;{{ song.audio_file.url }}&quot; artist=&quot;{{ song.author }}&quot;&gt; {{ song.song_name }}&lt;/li&gt;  
  {% endfor %}
  &lt;/ul&gt; 
  {% endblock content %}
  &lt;/div&gt;
  </code></pre>