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 608187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:26:12+00:00 2026-05-13T17:26:12+00:00

Sorry if this is a dumb way to ask this… I have a generic

  • 0

Sorry if this is a dumb way to ask this…
I have a generic list view for the homepage of a site, and would like to use a “homepage” model for informative text on that same page…is it possible? Thanks for your help.

models.py

from django.db import models


class School(models.Model):
    school_name = models.CharField(max_length=250, help_text='Maximum 250 characters.')
    slug = models.SlugField(unique=True)

    def __unicode__(self):
        return self.school_name

def get_absolute_url(self):
        return "/schools/%s/" % self.slug

class Student(models.Model):
    name = models.CharField(max_length=250, help_text='Maximum 250 characters.')
    slug = models.SlugField(unique=True)
    mugshot = models.ImageField(upload_to='mugshots')
    school = models.ForeignKey(School)  
    honor = models.TextField()

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return "/student/%s/" % self.slug

class Homepage(models.Model):
    title = models.CharField(max_length=250, help_text='Maximum 250 characters.')
    content = models.TextField() 

    def __unicode__(self):
        return self.title

urls.py

from django.conf.urls.defaults import *
from achievers.apps.students.models import School, Student
from achievers.apps.students.views import hello

from django.contrib import admin
admin.autodiscover()

info_dict = {
    'queryset': School.objects.all(),
    'extra_context': {'school_list': School.objects.all,}    
}

info_dict2 = {
    'queryset': Student.objects.all(),
    'template_name': 'students/student_detail.html',
    'extra_context': {'student_detail': Student.objects.all}    
}

urlpatterns = patterns('',
    (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'static'}),
    (r'^student/(?P<slug>[-\w]+)/$', 'django.views.generic.list_detail.object_detail', info_dict2), 
    (r'^students/(?P<slug>[-\w]+)/$', 'django.views.generic.list_detail.object_detail', info_dict),
    (r'^$', 'django.views.generic.list_detail.object_list', info_dict),
    (r'^admin/', include(admin.site.urls)),
    (r'^hello/', hello),
)
  • 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-05-13T17:26:12+00:00Added an answer on May 13, 2026 at 5:26 pm

    I’m not sure what you mean when you say you would like to “use” the homepage model with the generic list view. If you simply want access to all instances of Homepage, you can add the following to info_dict in your urls.py:

    info_dict = {
        'queryset' : School.objects.all(),
        'extra_context' : {'school_list' : School.objects.all(), 'homepage_list' : Homepage.objects.all()}
    }
    

    You can use a similar technique if you want to pass a specific instance of Homepage to the generic view:

    ...
    'extra_context' : {'school_list' : School.objects.all(), 'homepage' : Homepage.objects.filter(id = 1).get()}
    

    Finally, if you want something more complex (like a dynamic id to be used on the filter), you can always define a custom view, and then call object_list from within that view, like:

    def my_view(request, dynamic_id):
        info_dict = {..., 'extra_context' : {..., 'homepage' : Homepage.objects.filter(id = dynamic_id).get()}}
        return django.views.generic.list_detail.object_list(**info_dict)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Must be really dumb today - sorry in advance; anyhow have this unordered list
Sorry if this seems like a dumb question but I am just learning bash
I am sorry if this question sounds dumb. Why does inverse document frequency use
Sorry if this is a dumb question. I don't ever have to write anything
Ok sorry this might seem like a dumb question but I cannot figure this
I'm sorry if this question is a dumb one, but I must ask. In
Sorry if this is dumb but I was just thinking I should give a
sorry for asking this dumb question i will try to explain as good as
Sorry if this is a dumb question but im creating a filter class that
Sorry if this is a dumb question. I'm using .each to loop through a

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.