Answer the question
In order to leave comments, you need to log in
How to tag model in django instead of deleting it?
Hello, we have two models:
class Account(models.Model):
login = models.CharField(max_length=255)
password = models.CharField(max_length=255)
class Photo(models.Model):
account = models.ForeignKey(Account)
photo_name = models.CharField(max_length=255)
photo_url = models.CharField(max_length=255)
delete = models.IntegerField(choices=((0, 'no'), (1, 'yes')), default=0)
def delete(self, *args, **kwargs):
self.delete = 1
self.save()
Answer the question
In order to leave comments, you need to log in
class PhotoAdmin(admin.ModelAdmin):
def get_queryset(self, request):
queryset = super(PhotoAdmin, self).get_queryset(request)
return queryset.filter(delete=0)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question