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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:19:25+00:00 2026-05-20T00:19:25+00:00

I have a Django database of books, with attached transactions. In the admin interface,

  • 0

I have a Django database of books, with attached transactions. In the admin interface, on each book page, I’d like to show the transactions attached to each book.

Ideally, this should be read-only, with no ability to add or delete transactions. I’d like to show only some of the model’s fields.

In models.py:

class Book(models.Model):
    title = models.CharField(max_length=400)
class Transaction(models.Model):
    id = models.IntegerField(primary_key=True)
    book = models.ForeignKey(Book)
    user = models.ForeignKey(User)
    transaction_type = models.IntegerField(choices=TRANSACTION_TYPES)
    ipaddress = models.IPAddressField(null=True, blank=True)
    transaction_date = models.DateTimeField()
    date_added = models.DateTimeField(auto_now_add=True) 
    class Meta:
        get_latest_by = 'transaction_date'
        ordering = ('-transaction_date',)

In admin.py:

class TransactionInline(admin.StackedInline):
    model = Transaction
    readonly_fields = ['user', 'transaction_type', 'transaction_date']
    verbose_name = 'Transaction'
    verbose_name_plural = 'Book history'
class BookAdmin(admin.ModelAdmin):
    fieldsets = [ (None, {'fields': ['title'}) ]
    inlines = [ TransactionInline, ]

I have several questions, all related to the fact that transactions are conceptually read-only.

  1. How can I disable the ‘add new’ link for transactions?
  2. How can I only show the fields I care about – user, transaction_type and transaction_date – and hide the others?

Also: the header is currently “Book History — Transaction: Transaction object”. How can I show something friendlier than ‘Transaction object’?

Please let me know if this should be split out into separate questions!

Thanks.

  • 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-20T00:19:26+00:00Added an answer on May 20, 2026 at 12:19 am

    1: set max_num to 0
    http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#model-formsets-max-num

    2: specify the fields attribute
    http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.fields

    Also: override the __unicode__ method in your model
    http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.unicode

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

Sidebar

Related Questions

Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
I have a Django my_forms.py like this: class CarSearchForm(forms.Form): # lots of fields like
I have a Django project that uses postgresql_psycopg2 as a database. I would like
I've got a nice database I've created in Django, and I'd like to interface
I have gone similar threads like Django persistent database connection and other stuff on
If you've got a database setup in Django, how can you have the TestRunner
I have a django project that uses a sqlite database that can be written
I have a Django application which edits a database table, which another application polls
I have used Django before (version 1.2) and generally I like it... it is
I'm learning django with this excellent book Practical Django Projects. I was able to

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.