我使用'xcopy'命令时遇到问题.
我正在用msbuild构建一个C#项目.在构建结束时,调用批处理文件将我的程序集从Debug/Release复制到其他一些文件夹.
这是问题,我的构建失败,错误日志是'xcopy不被识别为内部或外部命令,可操作程序或批处理文件'.
路径设置正确,xcopy可以从Windows命令行和visual studio命令行(使用项目环境设置的命令行)中运行.
我试图在批处理文件中设置路径,但它没有帮助.
有什么建议吗?
我正在使用Windows 7
干杯:)
我有按名称和位置定义的产品。每个产品都有一对唯一的名称/位置。
我正在编写一个能够创建产品的视图,我想首先检查它是否存在于数据库中。如果是,则将 ID 保留在某处以将其返回到我的前端应用程序。如果没有,则创建它并获取 ID。
根据我的研究,覆盖 perform_create 方法应该是解决方案,但我不知道如何去做。
任何帮助,将不胜感激。
网址.py
from django.conf.urls import url
from main.views import product_view
urlpatterns = [
url(r'^products/$', product_view.ProductCreate.as_view()),
url(r'^products/(?P<pk>[0-9]+)/$', product_view.ProductDetail.as_view()),
]
Run Code Online (Sandbox Code Playgroud)
产品视图.py
from rest_framework import generics
from rest_framework import permissions
from main.models import Product
from main.serializers import ProductSerializer
class ProductCreate(generics.CreateAPIView):
"""
Create a new product.
"""
permission_classes = (permissions.IsAuthenticated,)
serializer_class = ProductSerializer
queryset = Product.objects.all()
def perform_create(self, serializer):
if serializer.is_valid():
product_name = serializer.validated_data['product_name']
product_location = serializer.validated_data['product_location']
if product_name != '':
product_list = Product.objects.filter(
product_name=product_name, product_location=product_location) …Run Code Online (Sandbox Code Playgroud) 我的一个序列化程序有问题。我正在尝试返回 PriceUnit 对象的所有数据,但 DRF 拒绝提供该 ID。这个 id 是自动生成的,我没有修改它。
序列化程序.py
class PriceUnitSerializer(serializers.ModelSerializer):
product_id = serializers.SerializerMethodField()
def get_product_id(self, obj):
if obj.product is not None:
return obj.product.id
return None
class Meta:
model = PriceUnit
fields = ('id',
'name',
'formula',
'product_id')
Run Code Online (Sandbox Code Playgroud)
网址.py
url(r'^price_units/$', price_unit_view.PriceUnitCreateUpdate.as_view()),
url(r'^price_units/(?P<pk>[0-9]+)/$', price_unit_view.PriceUnitList.as_view()),
Run Code Online (Sandbox Code Playgroud)
模型.py
class PriceUnit(models.Model):
UNIT = 'Unit'
SQUAREMATER = 'm2'
CUBEMETER = 'm3'
LINEARMETER = 'ml'
KILOGRAM = 'kg'
PRICE_UNITS_CHOICES = (
(UNIT, 'Unit'),
(SQUAREMATER, 'm2'),
(CUBEMETER, 'm3'),
(LINEARMETER, 'ml'),
(KILOGRAM, 'kg'),
)
name = models.CharField(max_length=50, choices=PRICE_UNITS_CHOICES, default=UNIT,)
formula …Run Code Online (Sandbox Code Playgroud) 我无法使画廊与华丽的弹出窗口一起工作。当我单击图片时,我收到“无法加载图像”。
这是html文件列表图像:
<div class='container'>
<div class='picture'><img src='images/gallery/a.jpg'/></div>
<div class='picture'><img src='images/gallery/b.jpg'/></div>
<div class='picture'><img src='images/gallery/c.jpg'/></div>
<div class='picture'><img src='images/gallery/d.jpg'/></div>
<div class='picture'><img src='images/gallery/e.jpg'/></div>
</div>
Run Code Online (Sandbox Code Playgroud)
这里的jQuery代码:
$.get( 'html/gallery.html', function( data ) {
$('#page_content').append(data);
$('.container').magnificPopup({
type: 'image',
delegate: 'div',
gallery:{
enabled: true,
navigateByImgClick: true,
arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
tPrev: 'Previous (Left arrow key)',
tNext: 'Next (Right arrow key)',
tCounter: '<span class="mfp-counter">%curr% of %total%</span>'
}
});
Run Code Online (Sandbox Code Playgroud)
我试图将“ delegate”值更改为“ div”或“ img”,但没有结果。(我遵循了这个宏伟的弹出窗口:获取“无法加载图像”并且图像url未定义)
感谢帮助 :)