1234567891011121314151617181920212223 |
- from django.contrib.auth.models import User
- from django.db import models
- #路由表
- from mptt.models import MPTTModel
- #路由表
- class Route(MPTTModel):
- name = models.CharField('name', max_length=80)
- path = models.CharField('name', max_length=80)
- url = models.CharField('name', max_length=80)
- parent = models.ForeignKey('self', verbose_name='上级', null=True, blank=True, related_name='pid', on_delete = models.CASCADE)
- class UserRoute(models.Model):
- route = models.ForeignKey('Route', verbose_name='菜单', null=False, blank=False, related_name='ur_route',
- on_delete=models.CASCADE)
- user = models.ForeignKey(User, verbose_name='用户', null=False, blank=False, related_name='ur_user',
- on_delete=models.CASCADE)
- class Meta:
- unique_together = ('user', 'route')
|