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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:27:35+00:00 2026-05-31T06:27:35+00:00

When clicking on save (after creating a new instance) in the Django Admin Site

  • 0

When clicking on “save” (after creating a new instance) in the Django Admin Site I get an

AttributeError at /admin/bankaccount/bank_account/add/
'Bank_Account' object has no attribute 'id'

I did not create any IDs in the model. The tutorial says that IDs are auto-managed.
Any idea why I get this?

My Model:

class Bank_Account(models.Model):
   iban = models.CharField(max_length = 30)
   bic = models.CharField(max_length = 30)

def __init__(self):
    self.iban = 0
    self.bic = 0

My admin.py

from bankaccount.models import Bank_Account
from django.contrib import admin

admin.site.register(Bank_Account)
  • 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-31T06:27:36+00:00Added an answer on May 31, 2026 at 6:27 am

    I assume from your code sample that you’ve overridden the __init__ (constructor) in your Bank_Account model. However you haven’t called the super. Actually, the actions you take should be expressed as defaults in the model:

    class BankAccount(models.Model):
        iban = models.CharField(max_length = 30, default="0")
        bic = models.CharField(max_length = 30, default="0")
    

    which should work fine. However I’m not sure why you want those as defaults; I’d have thought that no default and null=False, blank=False is more appropriate in this case as a bank account will surely always have both IBAN and BIC. Perhaps I’m misunderstanding your domain problem there, though.

    The key thing is: don’t override constructors without ensuring you do all the work of the constructor in your superclass(es).

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

Sidebar

Related Questions

i have one form after clicking save button form redirecting to another page, but
Here is my fiddle: jsfiddle.net/XR8EZ I cannot get the save data to load after
In my gsp page, after clicking on an image, i want to save something
I am tired of clicking File and then Save Page As in Firefox when
After clicking on a UIView I want to take the user of my app
I have my canvas element and some div, which after clicking I wish open
Purpose is to have a small icon on my admin page. Clicking this icon
jqgrid edit and add forms coontain textareas which can edited and enter adds new
I have an editable Jqgrid(where when im clicking on a row, that row get
In inline editing mode, clicking on Save is throwing an error. var rowSave =

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.