这里的用户我想要用户和用户配置文件。使用排除。当我添加用户配置文件错误“ WSGIRequest”对象没有属性“用户配置文件”
时public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
// Configure database connection
services.Configure<Settings>(options =>
{
options.ConnectionString = Configuration.GetSection("database:ConnectionString").Value;
options.Database = Configuration.GetSection("Db:Database").Value;
});
//register the RecordedMediaContext dependency here
services.AddTransient<ITestService, TestService>();
// Register the Swagger generator, defining 1 or more Swagger documents
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
// Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
// Max file upload sixe 5gb =5,368,709,120 bytes
services.Configure<FormOptions>(x => x.MultipartBodyLengthLimit = 5368709120);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
string baseApiUrl = Configuration.GetSection("BaseApiUrl").Value;
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
#if DEBUG
// For Debug in Kestrel
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Web API V1");
#else
// To deploy on IIS
c.SwaggerEndpoint(""+baseApiUrl+"/swagger/v1/swagger.json", "My API V1");
#endif
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
//Accept All HTTP Request Methods from all origins
//app.UseCors(builder => builder.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod());
app.UseHttpsRedirection();
#if !DEBUG
app.UseDefaultFiles();
app.UseStaticFiles();
#endif
app.UseMvc();
}
class ProductForm(forms.ModelForm):
class Meta:
model = Product
fields = ('categories', 'title', 'description', 'image', 'price')
exclude = ('user','userprofile')