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

  • Home
  • SEARCH
  • 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 7919731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:57:43+00:00 2026-06-03T15:57:43+00:00

I am writing an app in Django which has a few sitewide fixed objects

  • 0

I am writing an app in Django which has a few sitewide fixed objects I need to instantiate which, for one reason or another, can’t be fixtures.

For example, some (e.g. Permissions) I can’t hardcode a PK for because I can’t be sure that they’ll be loaded in a certain order (and if I use pk=null then I get an IntegrityError if they exist already.)

Others (e.g. Sites) depend on values in settings.py. Edit: These need to run each time the project is deployed, otherwise I could use South’s data migrations as per super9’s suggestion below.

Since these are Django models, they’re not directly related to any of the apps in my project. It would make the most sense to load them in settings.py but that results in a circular import. It works in urls.py but putting the loading code there seems hackish and out-of-place.

I looked into hooking a receiver into post_syncdb as follows:

@receiver(post_syncdb)
def create_groups_and_permissions(sender, **kwargs):
    print "Creating groups and permissions"
    u_ct = ContentType.objects.get(model="user")
    Group.objects.get_or_create(name='Group 1')
    Permission.objects.get_or_create(name="Perm 1", codename="perm_1", content_type=u_ct)

However, since I’m using South, per the documentation it only sends post_syncdb when the table is first created. I could call syncdb manually after each time I migrate but would prefer not to.

I am nearly resolved to put them in urls.py or the most closely related app’s models.py but thought I’d check here to see if there’s an accepted way of loading fixed objects which can’t be loaded as fixtures.

  • 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-03T15:57:46+00:00Added an answer on June 3, 2026 at 3:57 pm

    Have you checked out data migrations in south yet? http://south.aeracode.org/docs/tutorial/part3.html

    Sounds like it might be what you need.

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

Sidebar

Related Questions

I am writing a django app that keeps track of which email addresses are
I'm writing a Django app (although parts can be Bash) that stores the cron
I am writing a web app using Django 1.4.I want one of my view
I'm writing a small Django app that displays a few simple values from an
I am writing forum app on Django using custom session/auth/users/acl system. One of goals
In writing a django app, I am returning the following json on a jQuery
I'm currently writing an app in Python and need to provide localization for it.
I'm writing an app for gnome which will support plugins. Each plugin will contain
I'm writing an app for Java ME, and I need a class for holding
I am writing an app. There are plugins which DL resource from the net.

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.