[Answered ]-Extending Django templates with a form

2👍

I think you can have both form and notes on a same page by combining your views. ie something like –

@login_required
def notes_view(request):
    all_notes = Notes.objects.all().order_by('-date')
    paginate = paginated_stories(request, all_notes)
    # form processing and other code
    # -------------------------------
    # return both form and notes to your template context
    return render_to_response("report/notes.html",{
        'notes': paginate,
        'form': notes_form,
    },context_instance=RequestContext(request))

Or you can create a custom templatetag either for rendering notes or notes_form

0👍

Try this:

{% extends 'report/write_note.html' %}

{% block content %}
    {{ block.super }}

    <div class="span4 offset8">
            {% if notes %}
            {% for note in user.notes.all reversed %}
             <h3>{{ note.title }}</h3>
             <p>{{ note.date }}</p>
             <p>{{ note.copy }}</p>
            {% endfor %}

            {% else %}
            <p>You have no notes stored.</p>

           {% endif %}
     </div>
 {% endblock %}

When you’re overriding a block you just override the block, you don’t add “extends” to it.
And, {{ block.super }} can be used to get the content from the parent version of the block.

Leave a comment