I want to create two models something like this:
class LogActions(models.Model):
name = models.CharField(default='-')
text = models.TextField()
class Logs(models.Model):
user = models.ForeignKey(User)
log_message = models.ForeignKey(LogActions)
date = models.DateField(auto_now_add=True)
price = models.CharField(default='-', max_length=20)
In LogActions there will be stored user actions. Example:
Action one:
name = 'USER_POINT_ADDED'
text = 'User {user} added point to bla bla bla (long text...)'
There will be like 20 actions, names of this actions will be short, but texts are very long.
I don't know where to store all the initial data for migration... This data should be available through all project life.
I want to create dict like:
log_actions = {
'USER_POINT_ADDED': 'User {user} added... <verylongtexthere>',
'USER_POINT_EDITED': '<verylongtexthere>',
'USER_POINT_DELETED': '<verylongtexthere>',
'USER_GROUP_ADDED': '<verylongtexthere>',
}
All dicts like this above I hold in django settings.py file, but there are small and adding such a unclear hardcoded code to settings.py seems to be bad... but i need it for initial migration.
I'm Junior Dev are there any good habits in Django to store big hardcoded data that is needed to initial migration on new pc/server?
Did you met this kind of problem? How did you solve it?
The answer is in the FineManual: use fixtures.