Limit admin fields to User/Reddit User, stopping odd error messages

This commit is contained in:
2010-03-03 14:07:10 +00:00
parent 5144863ddf
commit 2f3ea3f48b
2 changed files with 12 additions and 6 deletions

View File

@@ -5,4 +5,10 @@ class RedditAccountAdmin(admin.ModelAdmin):
list_display = ('username', 'user', 'date_created', 'link_karma', 'comment_karma', 'last_update')
search_fields = ['username', 'user']
fields = ('user', 'username')
def save_model(self, request, obj, form, change):
obj.api_update()
obj.save()
admin.site.register(RedditAccount, RedditAccountAdmin)

View File

@@ -11,15 +11,15 @@ class RedditAccount(models.Model):
user = models.ForeignKey(User, blank=True, null=True)
username = models.CharField("Username", max_length=32, blank=False)
reddit_id = models.CharField("Reddit ID", max_length=32, blank=True)
username = models.CharField("Reddit Username", max_length=32, blank=False)
reddit_id = models.CharField("Reddit ID", max_length=32)
date_created = models.DateTimeField("Date Created", blank=True)
date_created = models.DateTimeField("Date Created")
link_karma = models.IntegerField("Link Karma", blank=True, null=True)
comment_karma = models.IntegerField("Comment Karma", blank=True, null=True)
link_karma = models.IntegerField("Link Karma")
comment_karma = models.IntegerField("Comment Karma")
last_update = models.DateTimeField("Last Update from API", blank=False)
last_update = models.DateTimeField("Last Update from API")
def api_update(self):
try: