5

Often times applications will need some database code tables (aka reference tables or domain tables or lookup tables). Suppose I have a model class called Status with a field called name that could hold values like:

Canceled
Pending
InProgress
Complete

Where and at what point would I setup these values in Django? Its like a one time operation to setup these values in the database. Infrequently, these values could be added to.

And I guess more generically, how do you initialize models with data? For example, say I had a model for holding the make of a car and I want to initialize this list with a set of known values. How would I do this?

2
  • Could you use choices for this or it really needs to be in the database so you can add status names through admin? Commented May 16, 2010 at 22:16
  • For this particular application I'm debating using choices, but for a flexible design I wanted to know how to use db tables. And in general I'd like to know how to do this. Commented May 16, 2010 at 22:26

1 Answer 1

3

You'll want to use a fixture for that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.