Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Block(models.Model):
- STATUS = (
- (1, 'normal'),
- (0, 'deleted'),
- )
- name = models.CharField("block name", max_length=100)
- desc = models.CharField("block description", max_length=100)
- admin = models.CharField("block admin", max_length=100)
- status = models.IntegerField(choices=STATUS)
- class Article(models.Model):
- STATUS = (
- (1, 'normal'),
- (0, 'deleted'),
- )
- tags = models.ManyToManyField(Tag, blank=True)
- owner = models.ForeignKey(User, on_delete=models.CASCADE)
- block = models.ForeignKey(Block, on_delete=models.CASCADE)
- title = models.CharField(max_length=100)
- In [40]: [b.name for b in Block.objects.all()]
- Out[40]: ['Concepts', 'Reading', 'Coding', 'Action']
- def article_detail(request, pk):
- article = get_object_or_404(Article, pk=pk)
- # sections and current_section
- if article.block.name == "Action" and request.user.username not in administors:
- raise Http404("You are not authorized to read Section Action,I prefert to communicate on the topic action in persion.")
Add Comment
Please, Sign In to add comment