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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:16:45+00:00 2026-05-30T19:16:45+00:00

I have two models, Client and PaymentOptions . class Client(models.Model): name = models.CharField(max_length=50, null=True,

  • 0

I have two models, Client and PaymentOptions.

class Client(models.Model):
    name = models.CharField(max_length=50, null=True, unique=False)
    contact = models.CharField(max_length=50, null=True, unique=False)
    address = models.CharField(max_length=300, null=True, unique=False)

class ClientPaymentOption(models.Model):
    name = models.CharField(max_length=30, null=True, unique=False, choices=CARD_TYPE)
    action = models.CharField(max_length=30, null=True, unique=False, choices=CLIENT_PAYMENT_OPTION)
    percent = models.FloatField(max_length=10, null=True, unique=False)
    fixamount = models.FloatField(max_length=20, null=True, unique=False)
    itemcharged = models.CharField(max_length=10, null=True, unique=False)

in my admin.py I have this :

admin.site.disable_action('delete_selected')
class ClientAdmin(admin.ModelAdmin):
    #display list
    list_display = ('name','contact','address')
    #display fields
    fields = ('name','contact','address')
    pass
admin.site.register(Client, ClientAdmin)

class PaymentOptionAdmin(admin.ModelAdmin):
    list_display = ('name', 'action', 'percent', 'fixamount', 'itemcharged', 'client')
    fields = ('name', 'action','percent', 'fixamount', 'itemcharged', 'client')
admin.site.register(ClientPaymentOption, ClientPaymentOptionAdmin)

is it possible that whenever I create a new Client in django admin it will also automatically create it’s ClientPaymentOption?

I try to do this in my admin.py:

class ClientAdmin(admin.ModelAdmin):
    #display list
    list_display = ('name','b_type','banner','logo',
                    'contact','address','account_type',
                    'status','currency','color','user',
                    )
    #display fields
    fields = ('name','b_type','banner','logo','contact',
              'address','account_type','status',
              'currency','color','user',
              )
    pass
    def save_model(self, request, obj, form, change):
        ClientPaymentOption.objects.create(name='MasterCard',action='% Charged', client=obj.id, percent=0.10)
        ClientPaymentOption.objects.create(name='Visa', action='% Charged',client=obj.id, percent=0.10)

but i got this error:

ValueError at /admin/client_app/client/add/
Cannot assign None: "ClientPaymentOption.client" does not allow null values.

when I try to print the parameters, i have noticed that the Client still not saved…

print obj.id
None

do anyone have an idea or suggestion about my case?

thanks in advance …

  • 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-30T19:16:47+00:00Added an answer on May 30, 2026 at 7:16 pm

    Call the parent’s method before attempting to create the new objects.

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

Sidebar

Related Questions

I have two models, Client and PaymentOptions . class Client(models.Model): name = models.CharField(max_length=50, null=True,
I have two tables: Client(id,name,...) Purchase(id,item,date,client_id,...) They have their respective Model, with their validations.
I have two models class Subscription < ActiveRecord::Base belongs_to :client end class Client <
I have two models, Article and Post that both inherit from a base model
I have two models, Room and Image . Image is a generic model that
I have two models, Reports(belongs to client) and Clients(has many reports). A Client has
I have two models Clients and Reports. A Client has_many Reports and a Report
I have two models. I am trying to query a model for how many
In my Rails app, I have two models, Estimate and Client , which both
I have three models: class Client < ActiveRecord::Base has_many :balancesheets has_many :investment_assets, :through =>

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.