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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:12:49+00:00 2026-06-13T15:12:49+00:00

I have some base initial data that I want to include in a Django

  • 0

I have some base initial data that I want to include in a Django project. It fits perfectly as a fixture except that I might want to reject duplicates. This would mean that I could re-load the data in to an existing installation and it would only add the objects that don’t already exist.

I have used natural keys and foreign keying on the same field, so there are no questions of id clashes etc.

Possible? I don’t want to write a JSON importer when one already exists, and my data is already in a fixture.

  • 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-13T15:12:50+00:00Added an answer on June 13, 2026 at 3:12 pm

    Usually fixture contains all the information of a model, which includes the primary key. Here is an example of a fixture from Django site:

    [
      {
        "model": "myapp.person",
        "pk": 1,
        "fields": {
          "first_name": "John",
          "last_name": "Lennon"
        }
      },
      {
        "model": "myapp.person",
        "pk": 2,
        "fields": {
          "first_name": "Paul",
          "last_name": "McCartney"
        }
      }
    ]
    

    As you can see it has a primary key. So even if you have duplicate fixtures, as long as primary keys are the same, whatever is the latest fixture to be imported, that one will overwrite the entries in the db, so you should not have any duplicate data in db.

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

Sidebar

Related Questions

I have a Base Router where i define some functions that need to be
Assume some domain and view objects (that have no common base class) public class
I have a simple C++ project that is structured as following: -A base project
When I declare some base styles for my site I have used to do
I have a base and derived class. The base class constructors have some static
Lets say we have some basic AR model. class User < ActiveRecord::Base attr_accessible :firstname,
I have written some general functions to convert between decimal and any other base-n
i have template base.html and some children templates. I don't know how to set
I have a base class called Panel, where some information about a window is
I am writing some unit test and I have a unit testing base class

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.