I want to solve my problem, I was looking for answer but I can't find any solution.
Let's say I have a Model:
class AccessCode(models.Model):
access_code = models.CharField(max_length=100, verbose_name='Access code',
unique=True, default=key_generator)
def __str__(self):
return self.access_code
def __unicode__(self):
return self.access_code
There is only one field. What I like to do is to create additional button in admin panel and use this button to automatically create 100 AccessCodes in my database. So there are 2 questions:
- How to create custom button in admin panel to perform some action with it?
- How to automatically create 100 objects of some model with one step?
The key_generator is my custom function to generate random string as a default value.