I have these (simplified) models:
class User(models.Model):
email = models.EmailField(unique=True)
class Invitation(models.Model):
user = models.ForeignKey(User)
path = models.CharField(max_length=40, unique=True)
The path field in the Invitation table will contain a SHA1 hash that is going to be used as part of the URL to access the user's data.
I have this admin code:
class InvitationInline(admin.TabularInline):
model = models.Invitation
class UserAdmin(admin.ModelAdmin):
inlines = (InvitationInline,)
admin.site.register(models.User, UserAdmin)
this displays the user and adds a list of invitations at the bottom.
Since my path values in the Invitation table are going to be generated by SHA1 algorithm from the user's email and the current timestamp, I need to:
- have no empty 'Invitations' rows displayed by default in the
Useradmin - remove the edit field for
pathcolumn from the admin, and have thepathfield automatically generated when the "add another invitation" button is clicked.
I have no idea how to achieve this, could someone help me?