make token and last seen date in backend readonly

This commit is contained in:
tkupek 2016-03-05 11:40:40 +01:00
parent 6c3aa0b7d5
commit 7c3bd62cbb
3 changed files with 6 additions and 1 deletions

Binary file not shown.

View file

@ -22,6 +22,11 @@ class UserAdmin(admin.ModelAdmin):
UserAnswerInline, UserAnswerInline,
] ]
def get_readonly_fields(self, request, obj=None):
return self.readonly_fields + ('token', 'last_seen')
admin.site.register(Question, QuestionAdmin) admin.site.register(Question, QuestionAdmin)
admin.site.register(Setting), admin.site.register(Setting),
admin.site.register(User, UserAdmin) admin.site.register(User, UserAdmin)

View file

@ -50,7 +50,7 @@ class User(models.Model):
token = models.CharField(max_length=40, null=True, default=gen_token) token = models.CharField(max_length=40, null=True, default=gen_token)
name = models.CharField(max_length=100, null=False) name = models.CharField(max_length=100, null=False)
last_seen = models.DateTimeField(null=True) last_seen = models.DateTimeField(null=True, blank=True)
def __unicode__(self): def __unicode__(self):
return self.name return self.name