我得到的解码器jpeg不可用.我使用brew安装libjpeg但是当我安装枕头时,得到***JPEG支持不可用
我有这个工作,突然间它停止工作.我已经取消了链接和链接libjpeg,就像在其他一些SO答案中建议的那样.我也卸下了枕头和libjpeg,然后重新安装,没有快乐.
我有一个这样的模型
class Job(models.Model):
description = models.CharField(max_length=255)
user = models.ForeignKey(User)
date = models.DateField()
slot = models.CharField(max_length=10, choices=SLOT_CHOICES)
location = models.ForeignKey(Location)
objects = JobManager()
searches = geomodels.GeoManager()
class Meta:
verbose_name_plural = "Job"
unique_together = ('date', 'slot', 'user')
def __str__(self):
return "{0}-{1}".format(self.user.first_name, self.date)
class Applied(models.Model):
user = models.ForeignKey(User)
job = models.ForeignKey(Job, null=True, blank=True)
action_taken = models.BooleanField(default=False)
is_declined = models.BooleanField(default=False)
class Meta:
verbose_name_plural = "Job Applications"
unique_together = ('user', 'job', )
Run Code Online (Sandbox Code Playgroud)
我想搜索日期范围之间的所有作业,并显示用户是否可以申请,已经申请或已被拒绝.应用程序信息在应用模型中.
jobs = Job.searches.filter(**kwargs)\
.filter(date__range=(date_from, date_to),
visibility=VisibilityStatus.PUBLIC,
status=JobStatus.AVAILABLE)\
.prefetch_related('applied_set')\
.select_related('user__surgeryprofile__location')\
.order_by('date')
Run Code Online (Sandbox Code Playgroud)
但我不能让它工作,它没有在数据库中的应用表上进行左连接.任何建议如何让它工作.
谢谢
我要求提供正常工作的建议,但我还需要通过文档中的其他字段过滤建议.
这有可能实现吗?只要我知道,Elasticsearch就无法做到这一点.还有其他想法吗?
public async Task<ISuggestResponse> Suggest(string index, string projectId, string field, string text)
{
var suggestResponse = await _client.SuggestAsync<TDocument>(s => s
.Index(index)
.Completion("suggest", c => c
.Text(text)
.Context(con => con.Add("projectId", projectId))
.Field(field)
.Size(20)
)
);
return suggestResponse;
}
Run Code Online (Sandbox Code Playgroud)
-----------更新--------------------
ElasticsearchConfig.cs
client.Map<Component>(d => d
.Properties(props => props
.String(s => s
.Name("name"))
.Completion(c => c
.Name("componentSuggestion")
.Analyzer("simple")
.SearchAnalyzer("simple")
.Context(context => context
.Category("projectId", cat => cat
.Field(field => field.ProjectId)))
.Payloads()))
.Properties(props => props.String(s => s.Name("id").NotAnalyzed()))
.Properties(props => props.String(s => s.Name("projectId").NotAnalyzed())));
Run Code Online (Sandbox Code Playgroud)
我无法从keycloak生成的访问令牌中提取用户信息.我有一个受保护的路由,我希望正确填充Principal或Authentication对象.
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
private final String SIGNING_KEY = "MIIBCgKCAQ...AB";
@Override
public void configure(HttpSecurity http) throws Exception {
http
.requestMatcher(new RequestHeaderRequestMatcher("Authorization"))
.authorizeRequests()
.antMatchers("/api/register").anonymous()
.antMatchers("/api/token").anonymous()
.anyRequest().authenticated();
}
@Override
public void configure(ResourceServerSecurityConfigurer config) {
config.tokenServices(createTokenServices());
}
@Bean
@Primary
public DefaultTokenServices createTokenServices() {
DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenStore(createTokenStore());
return defaultTokenServices;
}
@Bean
public TokenStore createTokenStore() {
return new JwtTokenStore(createJwtAccessTokenConverter());
}
@Bean
public JwtAccessTokenConverter createJwtAccessTokenConverter() {
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
converter.setAccessTokenConverter(new JwtConverter());
// converter.setSigningKey(SIGNING_KEY);
return converter;
} …Run Code Online (Sandbox Code Playgroud) 我在这里浏览了自定义文档https://django-taggit.readthedocs.io/en/latest/custom_tagging.html#genericuuidtaggeditembase
我正在使用以下代码,当我通过django admin保存产品时,表已正确填充,但是当我读取产品时,标签将显示为None
catalog / models.py
from django.db import models
from django.db.models import ImageField
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from taggit.managers import TaggableManager
from taggit.models import GenericUUIDTaggedItemBase, TaggedItemBase
from common.models import ModelBase
from customer.models import ApplicationUser
from order_quick.settings import APPLICATION_CURRENCY_SYMBOL
class TaggedItem(GenericUUIDTaggedItemBase, TaggedItemBase):
class Meta:
verbose_name = _("Tag")
verbose_name_plural = _("Tags")
class Product(ModelBase):
supplier = models.ForeignKey(ApplicationUser, on_delete=models.DO_NOTHING)
name = models.CharField(max_length=255)
description = models.CharField(max_length=255)
image = ImageField(upload_to='images/products/', blank=True, null=True)
cost_price = models.DecimalField(max_digits=9,
decimal_places=2,
verbose_name="Cost Price …Run Code Online (Sandbox Code Playgroud) 我有一些静态位置数据要加载,以便它在整个应用程序中都可用,就像内存缓存一样。
我试图覆盖 AppConfig 上的 ready() 但数据没有从数据库加载,而且 ready() 也被调用了两次。
from django.apps import AppConfig
class WebConfig(AppConfig):
name = 'useraccount'
verbose_name = 'User Accounts'
locations = []
def ready(self):
print("Initialising...")
location = self.get_model('Location')
all_locations = location.objects.all()
print(all_locations.count())
self.locations = list(all_locations)
Run Code Online (Sandbox Code Playgroud)
任何提示?
我想让Spring JPA审核与Spring Boot一起使用,我正在使用Spring Security的最新功能通过Keycloak进行身份验证。
springBootVersion = '2.1.0.RC1'
Run Code Online (Sandbox Code Playgroud)
我正在跟踪春季安全团队的示例https://github.com/jzheaux/messaging-app/tree/springone2018-demo/resource-server
ResourceServerConfig.kt
@EnableWebSecurity
class OAuth2ResourceServerSecurityConfiguration(val resourceServerProperties: OAuth2ResourceServerProperties) : WebSecurityConfigurerAdapter() {
@Throws(Exception::class)
override fun configure(http: HttpSecurity) {
http
.authorizeRequests()
.antMatchers("/api/**").authenticated()
.anyRequest().anonymous()
.and()
.oauth2ResourceServer()
.authenticationEntryPoint(MoreInformativeAuthenticationEntryPoint())
.jwt()
.jwtAuthenticationConverter(GrantedAuthoritiesExtractor())
.decoder(jwtDecoder())
}
private fun jwtDecoder(): JwtDecoder {
val issuerUri = this.resourceServerProperties.jwt.issuerUri
val jwtDecoder = JwtDecoders.fromOidcIssuerLocation(issuerUri) as NimbusJwtDecoderJwkSupport
val withIssuer = JwtValidators.createDefaultWithIssuer(issuerUri)
val withAudience = DelegatingOAuth2TokenValidator(withIssuer, AudienceValidator())
jwtDecoder.setJwtValidator(withAudience)
return jwtDecoder
}
}
class MoreInformativeAuthenticationEntryPoint : AuthenticationEntryPoint {
private val delegate = BearerTokenAuthenticationEntryPoint()
private val mapper = ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL)
@Throws(IOException::class, …Run Code Online (Sandbox Code Playgroud) 我有一个 django 模型,具有自引用多对多字段,如下所示。
class Product(ModelBase):
name = models.CharField(max_length=1000)
category = models.ForeignKey(Category, on_delete=models.DO_NOTHING)
company = models.ForeignKey(Company, on_delete=models.DO_NOTHING)
alternatives = models.ManyToManyField('self', symmetrical=False, blank=True)
Run Code Online (Sandbox Code Playgroud)
我对 django 管理表单不是特别满意,该表单将替代品的选项列为多选列表框,因为对于大量产品,选择一个或多个替代产品将变得乏味。
有没有一种方法可以丰富这种用户体验,我已经研究过 django-advanced-filters 但它不适用于 django 3。本质上,如果我可以进行预输入搜索来过滤列表中的项目并限制初始值基于所选类别的列表。
----更新---- admin.py
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
search_fields = ['name', ]
@admin.register(Company)
class CompanyAdmin(admin.ModelAdmin):
search_fields = ['name', ]
list_display = ['name', 'website', ]
@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
search_fields = ['name', ]
list_filter = ['category', ]
list_display = ['name', 'category', 'company', ]
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助。
我最近在Telerik RadPane中的View(xaml)上移动了ContentControl,如下所示:
<telerik:RadDocking.DocumentHost>
<telerik:RadSplitContainer Visibility="{Binding UserControlVisible}">
<telerik:RadPaneGroup>
<telerik:RadPane CanUserClose="False" Header="{Binding Operation}">
<ContentControl x:Name="ActiveItem" Margin="10" VerticalAlignment="Top" />
</telerik:RadPane>
</telerik:RadPaneGroup>
</telerik:RadSplitContainer>
</telerik:RadDocking.DocumentHost>
Run Code Online (Sandbox Code Playgroud)
因为,我已经这样做了,我的UserControls不是作为ContentControl中的内容注入的.我试图将ContentControl上的Content Property显式绑定到ActiveItem,但是说,无法找到关联的视图.
任何帮助都感激不尽.
我有一个简单的开箱即用VS2017 web api,我正在尝试在VSTS上构建Docker镜像并将图像发布到Azure容器注册表.但它不起作用,错误如下:
2018-05-21T16:49:45.8481201Z Step 7/17 : COPY WebApi/WebApi.csproj WebApi/
2018-05-21T16:49:45.8503445Z COPY failed: stat /var/lib/docker/tmp/docker-builder936381234/WebApi/WebApi.csproj: no such file or directory
2018-05-21T16:49:45.8644972Z ##[error]COPY failed: stat /var/lib/docker/tmp/docker-builder936381234/WebApi/WebApi.csproj: no such file or directory
2018-05-21T16:49:45.8732546Z ##[error]/usr/local/bin/docker failed with return code: 1
Run Code Online (Sandbox Code Playgroud)
它是标准的VS2017解决方案.
Dockerfile
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 63537
EXPOSE 44369
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY WebApi/WebApi.csproj WebApi/
RUN dotnet restore WebApi/WebApi.csproj
COPY . .
WORKDIR /src/WebApi
RUN dotnet build WebApi.csproj -c Release -o /app
FROM build AS publish
RUN …Run Code Online (Sandbox Code Playgroud) 我在Liferay 6.2中使用Spring 4.0.6.Spring无法将自动装配的组件注入到钩子中,对象变为null.我也尝试过带有liferay的spring 3.1版.相同的代码适用于portlet,但不适用于挂钩.
ActivityEventPublisher.java中的私有ApplicationEventPublisher发布者为null.
web.xml中
<?xml version="1.0"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web- app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.liferay.portal.kernel.servlet.SecurePluginContextListener</listener- class>
</listener>
<listener>
<listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>ViewRendererServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ViewRendererServlet</servlet-name>
<url-pattern>/WEB-INF/servlet/view</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
ActivityEventPublisher.java
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
import connect.activity.solr.document.ActivityData;
@Component
public class ActivityEventPublisher implements ApplicationEventPublisherAware {
private ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
public ApplicationEventPublisher getPublisher() {
return publisher;
}
public void setPublisher(ApplicationEventPublisher publisher) {
this.publisher …Run Code Online (Sandbox Code Playgroud) 我有一个简单的通用存储库,它采用类型T,T被约束为一个类.相当直接的东西,但.NET Core无法满足依赖性.不确定,我做错了什么.
错误:
System.ArgumentException: GenericArguments[0], 'Building.Manager.Domain.Society', on 'Building.Manager.Repository.GenericRepository`1[T]'
violates the constraint of type 'T'. ---> System.TypeLoadException: GenericArguments[0], 'Building.Manager.Domain.Society', on 'Building
.Manager.Repository.GenericRepository`1[T]' violates the constraint of type parameter 'T'.
public class Society : BaseEntity
{
public string Name { get; set; }
public string Phone { get; set; }
public Address Address { get; set; }
public IEnumerable<Flat> Flats { get; set; }
public Society() => this.Flats = new List<Flat>();
}
Run Code Online (Sandbox Code Playgroud)
BaseEntity是一个带有受保护构造函数的简单抽象类.
public interface IGenericRepository<T> where T : class
{}
public …Run Code Online (Sandbox Code Playgroud) django ×4
django-1.7 ×3
c# ×2
keycloak ×2
.net-core ×1
asp.net-core ×1
azure-devops ×1
django-admin ×1
docker ×1
java ×1
kotlin ×1
liferay-6 ×1
liferay-hook ×1
nest ×1
pillow ×1
python ×1
spring ×1
spring-boot ×1
telerik ×1
wpf ×1