publish

rest-framework 视图

与世无争的帅哥 提交于 2020-01-19 19:58:34
一 基本视图:    写一个出版社的增删查改resful接口 路由: url(r'^publish/$', views.PublishView.as_view()), url(r'^publish/(?P<pk>\d+)/$', views.PublishDetailView.as_view()), 视图: class PublishSerializers(serializers.ModelSerializer): class Meta: model=models.Publish fields='__all__' class PublishView(APIView): def get(self, request): publish_list = models.Publish.objects.all() bs = PublishSerializers(publish_list, many=True) # 序列化数据 return Response(bs.data) def post(self, request): # 添加一条数据 print(request.data) bs=PublishSerializers(data=request.data) if bs.is_valid(): bs.save() # 生成记录 return Response(bs.data) else:

DRF 认证 权限 视图 频率

本小妞迷上赌 提交于 2020-01-19 19:18:10
认证组件 使用:写一个认证类,继承BaseAuthentication   在类中写authenticate方法,把request对象传入   能从request对象中取出用户携带的token根据token判断是否登录过   如果登录过,返回两个值 user对象 ,token对象(或者其他自定义的对象)   如果没有登录过抛异常 from rest_framework.authentication import BaseAuthentication from app01 import models from rest_framework.exceptions import AuthenticationFailed class MyAuth(BaseAuthentication): def authenticate(self,request): # print('我是认证类中的方法,只要配置了,一定会执行') token = request.GET.get('token') token_obj=models.Token.objects.filter(token=token).first() if token_obj: #有值表示登录 # return #可以没有返回值它就直接接续掉这一次循环了 继续下一次循环 如果有值就解压赋值给self.user, self.auth

Windows系统下使用Jenkins 自动发布 .NET core到Linux平台下Docker

爱⌒轻易说出口 提交于 2020-01-16 17:01:23
准备工作(安装过程可以百度,已安装的可以跳过) a) 安装Jenkins,安装包下载地址: http://mirrors.tuna.tsinghua.edu.cn/jenkins/windows-stable/jenkins-2.73.1.zip b) 安装 .NET core SDK,官网地址: https://www.microsoft.com/net/core#windowscmd c) Linux 服务器一台并且安装好 Docker d) 好压软件,下载地址: http://sw.bos.baidu.com/sw-search-sp/software/027b0d91ba34c/haozip_5.9.4.10795.exe 。注意这不是广告,我们用他来压缩我们本地发布好的源码,因为他支持cmd命令,当然你也可以用其他的代替。为了让它支持cmd命令我们还需要修改一下本地环境变量,右键【我的电脑】->【高级系统设置】->【高级】->【环境变量设置】->选择系统变量【Path】->点击【编辑】->点击【新建】,把好压的安装目录放进去。我好压的安装目录是:C:\Program Files\2345Soft\HaoZip 图例: 检查环境是否就绪 a) Jenkins浏览器打开是否正常,默认打开地址: http://localhost:8080/ 。 b) 检查.NET core

文件与文件夹

江枫思渺然 提交于 2020-01-16 16:38:13
一、文件的基本操作 文件的增删改查 文件的新建:touch filename 文件的改名:mv 文件的查看:ls 文件内容的查看:cat 文件的删除:rm [-r -f] 文件的拷贝:cp [-r -f -p] 文件的移动:mv touch命令 #touch命令 新建文件和修改文件或者文件的时间戳 #命令语法: touch 【选项】 【文件名或者目录名】 #命令选项: -a 只修改文件的access(访问)时间. -c 或—no-create  不创建不存在的文件。 -d 使用指定的日期时间,而非现在的时间 -m 指修改Modify(修改)时间,而不修改access(访问)时间 -r file 使用指定file文件的时间戳(access,modify)更新文件的时间戳(access,modify) -t 将时间修改为参数指定的日期,如:10011150代表10月8号11点55分 #拓展:linux文件的三time stat命令:打印信息节点(inode)内容 atime:(access time)显示的是文件中的数据最后被访问的时间,比如系统的进程直接使用或通过一些命令和脚本间接使用。 mtime: (modify time)显示的是文件内容被修改的最后时间。 ctime: (change time)显示的是文件的权限、拥有者、所属的组、链接数发生改变时的时间

Don't publish particular folder in ASP.NET

▼魔方 西西 提交于 2020-01-15 05:46:27
问题 Is it possible to exclude a folder in a web project from being published? We've got some documentation and scripts that included in a particular project folder, and are added to the project, but when I do a VS publish, I don't want them to go up to the production server. I know they shouldn't be in the project, but I thought I'd find a workaround before I try to convince the owner to modify the way he's doing things. 回答1: This doesn't answer your question, exactly, but my feeling is that

rest-framework框架的基本组件

做~自己de王妃 提交于 2020-01-15 02:33:05
rest-framework框架的基本组件 快速实例 Quickstart 序列化 创建一个序列化类 简单使用 开发我们的Web API的第一件事是为我们的Web API提供一种将代码片段实例序列化和反序列化为诸如 json 之类的表示形式的方式。我们可以通过声明与Django forms非常相似的序列化器(serializers)来实现。 models部分: from django.db import models # Create your models here. class Book(models.Model): title=models.CharField(max_length=32) price=models.IntegerField() pub_date=models.DateField() publish=models.ForeignKey("Publish") authors=models.ManyToManyField("Author") def __str__(self): return self.title class Publish(models.Model): name=models.CharField(max_length=32) email=models.EmailField() def __str__(self): return self.name

RESTful源码笔记之RESTful Framework的基本组件

喜夏-厌秋 提交于 2020-01-15 00:28:45
快速实例 Quickstart 序列化 创建一个序列化类 简单使用 开发我们的Web API的第一件事是为我们的Web API提供一种将代码片段实例序列化和反序列化为诸如 json 之类的表示形式的方式。我们可以通过声明与Django forms非常相似的序列化器(serializers)来实现。 models部分: from django.db import models # Create your models here. class Book(models.Model): title=models.CharField(max_length=32) price=models.IntegerField() pub_date=models.DateField() publish=models.ForeignKey("Publish") authors=models.ManyToManyField("Author") def __str__(self): return self.title class Publish(models.Model): name=models.CharField(max_length=32) email=models.EmailField() def __str__(self): return self.name class Author(models

TFS build - deployment/package target does not run

本小妞迷上赌 提交于 2020-01-13 18:05:39
问题 We have a TFS build definition set up where we pass the following extra MSBuild arguments in: /p:DeployOnBuild=true;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;_PackageTempDir="\\server\build";AutoParameterizationWebConfigConnectionStrings=false This has been detailed elsewhere as a way to have the published files copied to a specific location instead of generating a deploy package. This unfortunately does not work on our build server, however if I run the exact same msbuild command

Why is my app not showing on Google Play? Just now published

◇◆丶佛笑我妖孽 提交于 2020-01-13 10:37:09
问题 I just tried to publish my app for the first time - I went through the steps on Developer Console and it says "published" now with a green check mark (after I hit "activate" and "publish", with no errors) However, I tried searching by name on the Google Play store ( it's called "Urbanary Challenge" ) on my phone, tablet, and chrome browser but nothing shows up. (same with company name search). Then, I tried by direct URL: https://play.google.com/store/apps/details?id=com.shameless.studios

WebAPI : 403 Forbidden after publish website

£可爱£侵袭症+ 提交于 2020-01-13 10:13:09
问题 Alright, I'm having a tough time locating the problem since it works locally but after doing a publish the results are simply: Error Code: 403 Forbidden. The server denied the specified Uniform Resource Locator (URL). Contact the server administrator. (12202) The code: [RoutePrefix("api/v1/project")] public class ProjectController : BaseApiController { [HttpGet] public HttpResponseMessage GetProjects() { HttpResponseMessage resp = new HttpResponseMessage(HttpStatusCode.OK); if(User.Identity