小编gek*_*gek的帖子

将 Powershell 核心设置为 Windows/Linux 上的默认 GNU Make shell

在 Windows 上的 makefile 中。

使用以下 make 版本:

PS C:\projects> make --version
GNU Make 4.1
Built for i686-w64-mingw32
Copyright (C) 1988-2014 Free Software Foundation, Inc.
Run Code Online (Sandbox Code Playgroud)

我试图在没有明确指定 shell 的情况下设置SHELL := pwsh/COMSPEC := pwsh和运行命令:

# COMSPEC := pwsh -c
SHELL := pwsh -c

VAR=asdf/asdf

.PHONY: get_var

get_var:
    @Write-Output $(VAR)
Run Code Online (Sandbox Code Playgroud)

没有成功。我有一个错误:

PS C:\projects\makefile_factory> make -f .\fi.makefile get_var
process_begin: CreateProcess(NULL, Write-Output asdf/asdf, ...) failed.
make (e=2): ?? ??????  ????? ????????? ????.
.\fi.makefile:10: recipe for target 'get_var' failed
make: *** [get_var] …
Run Code Online (Sandbox Code Playgroud)

powershell makefile gnu-make

3
推荐指数
1
解决办法
1245
查看次数

如何根据用户权限和模型属性值限制对 DetailView 的访问?

我想限制对某些具有 attribute 的详细文章页面的访问is_private=True。它们可以显示在文章列表中,但只有具有权限的用户view_private_articles才能访问文章DetailView。

模型.py:

class Article(models.Model):
    title = models.CharField(
        max_length=150,
    )
    is_private = models.BooleanField(
    default=False,
    )
Run Code Online (Sandbox Code Playgroud)

视图.py:

class ArticleListView(LoginRequiredMixin,ListView):
    model = Article
    template_name = 'article_list.html'
    context_object_name = 'article_objects_list'
    login_url = 'login'

    class Meta:
        permissions = [
            ("view_private_articles", "Can view private articles"),
        ]

    def __str__(self):
        return self.value


class  ArticleDetailView(
        LoginRequiredMixin,
        PermissionRequiredMixin,
        DetailView):
    model = Article
    context_object_name = 'article_object'
    template_name = 'detail/article_detail.html'
    login_url = 'login'
    permission_required = 'view_private_articles'
Run Code Online (Sandbox Code Playgroud)

正如您可能注意到的,问题是,此处描述的方法只能限制无权view_private_articles查看所有文章(不仅具有is_private=True属性)的用户。

那么如何限制用户只能查看带有属性的文章is_private=True呢? …

django django-views

2
推荐指数
1
解决办法
1864
查看次数

标签 统计

django ×1

django-views ×1

gnu-make ×1

makefile ×1

powershell ×1