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

  • SEARCH
  • Home
  • 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 429093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:44:28+00:00 2026-05-12T19:44:28+00:00

So, Generic views are pretty cool, but what I’m interested in is something that’s

  • 0

So, Generic views are pretty cool, but what I’m interested in is something that’s a generic template.

so for example, I can give it an object and it’ll just tostring it for me.

or if I give it a list, it’ll just iterate over the objects and tostring them as a ul (or tr, or whatever else it deems necessary).

for most uses you wouldn’t need this. I just threw something together quickly for a friend (a bar stock app, if you must know), and I don’t feel like writing templates.

  • 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-12T19:44:29+00:00Added an answer on May 12, 2026 at 7:44 pm

    If there’s a django model for it, you can just stick to django.contrib.admin or django.contrib.databrowse. If not, then you might manage by skipping the django template altogether. example:

    from django.http import HttpResponse
    import datetime
    
    def current_datetime(request):
        now = datetime.datetime.now()
        html = "<html><body>It is now %s.</body></html>" % now
        return HttpResponse(html)
    

    But of course you wanted to avoid even writing that much, so instead of doing html, we can use plain text and the pprint module:

    from django.http import HttpResponse
    import datetime
    from pprint import pformat
    
    def current_datetime(request):
        now = datetime.datetime.now()
        return HttpResponse(pformat(now), mimetype="text/plain")
    

    edit: Hmm… this seems like something a view decorator should handle:

    from django.http import HttpResponse
    import datetime
    import pprint
    
    def prettyprint(fun):
        return lambda request:HttpResponse(
                pprint.pformat(fun(request)), mimetype="text/plain")
    
    @prettyprint
    def current_datetime(request):
        return datetime.datetime.now()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If some template requests from generic views I can get {{ user }} and
I'm using Class based generic views, can anybody suggest me how can i set
The first two paragraphs of this page explain that generic views are supposed to
In ASP.NET MVC there are generic master views ( ViewMaserPage<T> ). But what is
Can the object value be looked up and passed to the generic view? Would
Sorry for the semi-generic title, but I'm still pretty new at rails and couldn't
This is a pretty generic question, but I come from a few years with
Generic views exist to make our lifes easier, but the time spent on understanding
How we can implement CRUD functionality using generic views and django-mptt ?? I've searched
How to pass request variable in generic views to a queryset. For example i

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.