Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7781897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:22:19+00:00 2026-06-01T19:22:19+00:00

i’m looking for a way to extend a django template/view. my first implementation consists

  • 0

i’m looking for a way to extend a django template/view.

my first implementation consists of two models (clients/models.py):

class Client(models.Model):
    ...

class Address(models.Model):
    client = models.ForeignKey(Client)
    ...

and its fairly simple template (clients/detail.html) :

{{client.name}}
Address: {{client.address.street}}, {{client.address.zipcode}} {{client.address.city}}

as my application grows, a new app was born: ‘invoices’.

it is again very simple (invoices/models.py):

class Invoice(models.Model):
    client = models.ForeignKey(clients.models.Client)
    ...

now my clients details-view needs to display invoices, so i create and override clients/detail.html in my ‘invoices’ app.

good for now.

later on i created a third app ‘quotes’.
again my clients details-view needs to display quotes.

if i create clients/detail.html in my ‘clients’ i will loose the ability to display invoices.

because the ‘invoices’ and ‘quotes’ app are indipendent.

my first idea was to create something like a SubView-class
which ‘invoices’ and ‘quotes’ can extend and then register their implementation somewhere.

a template should look like this:

{{client.name}}
Address: {{client.address.street}}, {{client.address.zipcode}} {{client.address.city}}

{% for view in views %}
    <h1>{{view.title}}</h1>
    {{view.get_html}}
{% endfor %}

is this a good way to go and should i use a admin.site-like implementation for registering my sub-views?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:22:22+00:00Added an answer on June 1, 2026 at 7:22 pm

    In Django one url in urls.py should ideally use one view, just to keep things simple.

    I would therefore adopt the approach of putting all the required context in your one view for this screen (I think you already have this via foreign keys in your model). Then, rather than doing what you call “SubView-class” I would go for the Django template include tag.

    Example:

    {% for invoice in client.invoices %}
        {% include "invoice-detail.html" with invoice=invoice %}
    {% endfor %}
    

    This renders each invoice’s detail for all the invoices of the client. Notice how this is in line with the DRY principle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm making a simple page using Google Maps API 3. My first. One marker
I would like to count the length of a string with PHP. The string
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.