Fixtures are geared towards unit testing; I'm wondering if they are considered a good way to populate the database with some initial default values.
For example, say we have a model TicketState, and the applications must be guaranteed to have two TicketStates representing the states "Open" and "Closed", and we want to make it so the user can add more TicketStates as needed. Is this something that would best be addressed by using fixtures? In particular, there doesn't seem to be a way to create fixtures programmaticly (rather than importing JSON or YAML data), which means that somewhere in the code you would need to have magic values to refer to the default models that were loaded (a magic value is some arbitrary string or number, rather than using constants or some other more controlled approach that is less likely to break later in mysterious ways). For example: # if no state, assign the default state if not ticket.status: # Below is bad practice, uses a magic value ticket.status = TicketStatus.objects.get(name='Open') Would a different approach be better, such as a having a get_or_create method that creates the default instance if it doesn't exist already (rather than using fixtures)? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---