简体   繁体   中英

Allowing user/users to only view one table of DB with Django?

I am very new with Django and trying to learn from various sources on internet. My project folder structure goes like 在此处输入图片说明

I am using sqlite.db and made 6 models that are linked to backend DB. One of the table i have is Execution_Results.

class Execution_Results(models.Model):
    class Meta:
        permissions = (
            ('view_results', 'User can view results'),
        )
        verbose_name_plural = "Execution_Results"
    config_id = models.ForeignKey(Config_Details, on_delete=models.CASCADE)
    exec_time = models.DateTimeField()
    path = models.CharField(max_length=100)

With Admin login i can only provide access to add, edit and delete for that particular or group of users. For my case i just want view access for users. And based on whatever config_id they choose i want to read data from other tables based on mapping and present it for user.

I gave permissions = ( ('view_results', 'User can view results'), ) but i am not getting what next shall be done so that user can just view this table data.

I got this resolved without any setting or coding by just adding view permission module from git. Please refer answer at Permission to view, but not to change! - Django

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM