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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:21:44+00:00 2026-06-07T15:21:44+00:00

When dealing whith model inheritance in django is it possible to remove a instance

  • 0

When dealing whith model inheritance in django is it possible to remove a instance of model subclass, without removing the superclass itself?

Using the Django example, can you remove just the Resturaunt object and retain the Place object?

  • 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-06-07T15:21:47+00:00Added an answer on June 7, 2026 at 3:21 pm

    Yesterday I was looking for an answer to this question and I came up with this solution, which was enough for my problem but could be scaled up as needed.

    Assuming you have a Restaurant and a Place django models, the way to delete a restaurant only without touching the row inside the Place’s table is creating a “fake” Restaurant model like this:

    class FakeRestaurant(models.Model):
        place_ptr = models.PositiveIntegerField(db_column="place_ptr_id", primary_key=True)
        serves_hot_dogs = models.BooleanField()
        serves_pizza = models.BooleanField()
    
        class Meta:
            app_label = Restaurant._meta.app_label
            db_table = Restaurant._meta.db_table
            managed = False
    

    Now, you can retrieve objects from that table as if it had no bound external relationship:

    place = Place.objects.get(pk=1)
    restaurant = Restaurant.objects.get(pk=1)
    fake_restaurant = FakeRestaurant.objects.get(pk=1)
    fake_restaurant.delete()
    

    fake_restaurant and restaurant won’t exist anymore, place will remain untouched.

    Cheers,
    Davide

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

Sidebar

Related Questions

I am using Rails single-table inheritance with a superclass Content and a number of
When dealing with a collection of key/value pairs is there any difference between using
I understand that everything dealing with database should be put inside a model class.
Hi Everyone I m dealing with some serious issue in django-admin.I have created models
I was woundering what is the best coding practice when dealing with the Model-View-Controller
I am battling with dealing with how best to break a domain model up
My understanding of the conventions I'm currently dealing with is as follows: Model names
I am dealing with a wierd problem. I have the Config model, together with
I'm using SlimDX, targeting DirectX 11 with shader model 4. I have a pixel
I want to extend the default model binding to be more smart when dealing

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.