我有一些问题在一个项目中,我需要与三个(可能更多)类型的用户一起工作,这些用户有不同的角色:医生患者管理员
我一直在考虑使用Django Model Users并扩展它创建一个userprofile模型......但是我忽略了如何管理不同的角色,因为userprofile模型将包含用户模型的字段,尽管我不知道如何解决角色主题.
1用户有多个用户配置文件?我不知道
或者我可能应该创建一个角色模型/表,在其中我指定角色类型并创建与用户模型的关系.这是一个很好的可能性.
另一种可能性(作为下面的评论)是检查Django权限系统,我可以在其中创建用户组,并为这些组分配权限,虽然在这里我只能编辑,创建和删除模型吗?
我对如何解决这个问题感到困惑
搜索我找到了这个应用程序. https://github.com/dabapps/django-user-roles
如果有人可以指导我,我将非常感谢最诚挚的问候
我有一个 github 操作工作流来构建一个 docker 镜像:
name: Backend-Demo Docker Image CI
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to Azure Container Registry
run: echo ${{ secrets.REGISTRY_PASSWORD }} | docker login ${{ secrets.LOGIN_SERVER_URL }} -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin
- name: Get the version
id: vars
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
- name: Build the tagged Docker image
run: docker build . --file backend/Dockerfile --tag backend-demo/spring-boot:v1.0
Run Code Online (Sandbox Code Playgroud)
Dockerfile 是:
FROM openjdk:14-alpine
MAINTAINER example.com …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用我在jenkins中安装的git插件创建从jenkins到我的bitbucket存储库的连接.
当我进入存储库URL时,我收到如下图所示的消息通知:
"无法连接到存储库:命令"ls-remote -h git@bitbucket.org:safe2school-ondemand/s2s-android-padres.git HEAD"返回状态码128:stdout:stderr:Permission denied(publickey).致命:远程端意外挂断"

我在apache tomcat容器上安装了jenkins,它位于路径/ srv/apache-tomcat中
在系统中我有一个root ssh-key,我把这个键添加到bitbucket.我感谢您的支持 :)
我有一个具有特定业务逻辑的 python Azure 函数。在 中Dockerfile,我想以非 root 用户身份运行容器,因此我执行了以下操作:
FROM mcr.microsoft.com/azure-functions/python:3.0-python3.8
.
.
.
RUN useradd -u 1001 -m fem-downloader
RUN chown -R 1001:1001 /home/
# I Changed the AzureWebJobsScriptRoot value to this new user path
ENV AzureWebJobsScriptRoot=/home/fem-downloader/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
USER fem-downloader
COPY --chown=fem-downloader:fem-downloader requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY --chown=fem-downloader:fem-downloader . /home/fem-downloader/wwwroot
WORKDIR /home/fem-downloader/wwwroot/HttpTrigger/
ENV PATH="/home/fem-downloader/.local/bin:/home/.local/bin:${PATH}"
RUN pip install pytest && python3 -m pytest --verbose
Run Code Online (Sandbox Code Playgroud)
当我在本地运行 Azure 函数时,它可以工作:
docker run -ti -p 8001:80 --name my-azure-function my-azure-function:nonroot
info: …Run Code Online (Sandbox Code Playgroud) 当我根据这个答案尝试渲染django-bootstrap-datepicker-plus小部件时,我有些不便.一切正常,但Datepicker没有出现.
我的Django版本是1.10.7,我使用的第三方应用程序是:
pip install django-bootstrap3)pip install django-bootstrap-datepicker-plus)这是我的forms.py,我DateInput根据我的需要覆盖类来定制它.
from django import forms
from bootstrap_datepicker.widgets import DatePicker
class DateInput(DatePicker):
def __init__(self):
DatePicker.__init__(self,format="%Y-%m-%d")
class UserUpdateForm(forms.ModelForm):
class Meta:
widgets = {
'date_of_birth': DateInput(), # datepicker
'creation_date': DateInput(), # datepicker
}
fields = ("other fields", "date_of_birth", "creation_date", "other fields",)
model = get_user_model()
Run Code Online (Sandbox Code Playgroud)
然后在我的模板表单中,我有一些名为layout.htmlMy template的基本主模板,我user_form.html希望在其中呈现前面提到的表单字段.所有这个模板都有一些div和html结构,你可以在这里看到user_form.html文件.
在我的settings.py的bootstrap设置中,我必须include_jquery …
javascript django datepicker django-forms bootstrap-datepicker
当我想序列化我的模型以获得它们的对象/记录列表时,我会遇到关于何时使用 APIView 和何时使用 ModelViewSet 的差异?
例如,在APIView 文档中,我们使用 ListUser 类及其 get 方法可以获得用户列表
class ListUsers(APIView):
"""
View to list all users in the system.
* Requires token authentication.
* Only admin users are able to access this view.
"""
authentication_classes = (authentication.TokenAuthentication,)
permission_classes = (permissions.IsAdminUser,)
def get(self, request, format=None):
"""
Return a list of all users.
"""
usernames = [user.username for user in User.objects.all()]
return Response(usernames)
Run Code Online (Sandbox Code Playgroud)
我已经通过这种方式使用 ModelViewSet 获得了相同的用户列表:
class UserViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed …Run Code Online (Sandbox Code Playgroud) 我有这个多阶段构建:
\nFROM mcr.microsoft.com/azure-functions/python:3.0-python3.8 as intermediate\n\nRUN apt-get update && \\\n apt-get install -y apt-utils && apt-get install -y git && \\\n wget https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \\\n dpkg -i packages-microsoft-prod.deb && \\\n apt-get update; \\\n apt-get install -y apt-transport-https && \\\n apt-get update && \\\n apt-get install -y dotnet-sdk-5.0\n\nARG SPECKLE_ENFORCE_SSL\nENV SPECKLE_ENFORCE_SSL=false\nARG ARTIFACTS_KEYRING_NONINTERACTIVE_MODE\nENV ARTIFACTS_KEYRING_NONINTERACTIVE_MODE=true\n\nARG AZ_DEVOPS_TOKEN\nENV AZ_DEVOPS_TOKEN=$AZ_DEVOPS_TOKEN\nENV PYTHONUNBUFFERED 1\n\n\nRUN pip install --upgrade pip --no-cache-dir && \\\n pip install pyyaml numpy lxml artifacts-keyring pytest --no-cache-dir && \\\n pip install -i https://$AZ_DEVOPS_TOKEN@pkgs.dev.azure.com/<org>/<project>/_packaging/<feed>/pypi/simple/ --no-cache-dir <package-name>\n\n# …Run Code Online (Sandbox Code Playgroud) 我最近设置并部署了一个Amazon EC2实例来部署我的django项目.
当我在浏览器中收到此错误时,我正通过浏览器与我的应用程序进行交互:
errno 5 input/output error django
Run Code Online (Sandbox Code Playgroud)
此错误确实引用了我的应用程序的某些功能
Environment:
Request Method: GET
Request URL: http://localhost:8000/accounts/profile/
Django Version: 1.9
Python Version: 3.4.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
'django_extensions',
'storages',
'userprofile']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/ubuntu/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
149. response = self.process_exception_by_middleware(e, request)
File "/home/ubuntu/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
147. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ubuntu/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/home/ubuntu/.virtualenvs/nrb_dev/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, …Run Code Online (Sandbox Code Playgroud) 我正在尝试传递到Django中从视图到模板的列表.
在我的文件wiew.py中,我定义了名为hour的视图
# This Python file uses the following encoding: utf-8
from django.shortcuts import render
from django.http import HttpResponse
from datetime import datetime
from django.shortcuts import render_to_response
# Create your views here.
def hour(request):
now = datetime.now()
list = ['Bern','Bob','Eufronio','Epifanio','El pug']
return render_to_response('hour.html',list)
Run Code Online (Sandbox Code Playgroud)
在我看来,我正在使用shorcuts.
我有一个名为hour.html的模板,所以这样:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
<title>Date</title>
</head>
<body>
The names are:
{%for item in list%}
<li>{{item}}</li>
{% endfor %}
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但我的模板hour.html在浏览器中显示为空.如何将列表从我的视图发送到模板.感谢旅游关注
一个伟大的问候社区
我的问题与Django中的管理用户和架构用户的类型有关,一开始我请你道歉,以防万一我的问题可能太"新手"或没有意义,我开始把我与Django联系起来用户模式及其在项目中的不同工作可能性.
我有以下情况.
我正在构建一个应用程序,其中我将有三个不同的用户类型:
我使用默认的Django身份验证方案(django.contrib.auth).
最初,我确实在这个实体方案中思考,其中User表是auth_userDjango保存用户创建的表:
我有is_patient,is_medical和is_physiotherapist用户表中的布尔属性字段.
像特定细节一样,我理解在Django默认模型中,用户无法修改或添加属性或字段.
这是一个重要而有力的理由我不能添加的 is_patient,is_medical并且is_physiotherapist在用户表布尔字段.
经典建议是使用Userprofile表扩展User模型,在该表中我通过OneToOne关系向User Model添加字段或属性.基本样本如下:
就是这样,我得到了我在Django的用户可以拥有现场照片并在特定时刻上传一个...
利用前面的方案,以下模式可以适用于管理用户角色(和用户类型)patient,也可以作为替代方案?medicalphysiotherapist
我会在以下方面建立关系:
用户医疗和用户患者
用户物理治疗师和用户患者
他们和其他桌子之间......
通过这种方法,这些关系不会受到影响吗?
将在Users和UserProfile表之间保存不同的用户.这是可扩展性意义上的一个好习惯吗?我的表可能是崩溃还是我的数据库?
此外,我还看到了其他替代方案,例如:
我将有一个独立或独立的角色表/模型,这可以与Django用户模型相关(一个用户可以通过示例拥有许多角色)当我想要存储有关特定角色的角色的独家信息时,这种方法非常有用?
我忽略或不知道让我工作的粒度等级.我只看到权限和授权系统允许我使用创建,编辑和删除操作....
在这里,我可以看到创建群组吗?例如,医疗组并为其分配权限并将此权限链接到组成该组的用户?这是另一个好的选择吗?这个选项似乎更单一,虽然我不知道用户是否可以根据具有的组权限进行一些操作...我不知道这个想法是否正确/正确
我对患者,医疗和物理治疗师用户的要求需要构建自定义用户模型吗?
django ×6
python ×6
docker ×3
django-users ×2
user-roles ×2
amazon-ec2 ×1
azure ×1
bitbucket ×1
datepicker ×1
django-forms ×1
django-views ×1
dockerfile ×1
git ×1
input ×1
javascript ×1
jenkins ×1
output ×1
ssh ×1