我希望用户能够创建一个新博客,并且在他创建博客后,应将其重定向到该博客的详细视图,但是@EnableAsync
@Endpoint
public class ServiceController {
@PayloadRoot(namespace = "services/mobility", localPart = "evaluateIMSRule")
@ResponsePayload
public String getRuleEngineResponse(@RequestPayload EvaluateIMSRuleRequest request) {
....
....
return response;
}
@PayloadRoot(namespace = "services/mobility", localPart = "itemNOSService")
@ResponsePayload()
public CreateItemNOSRecordResponse getItemNOSServiceResponse(@RequestPayload CreateItemNOSRecordRequest request) {
....
....
return nosRecordResponse;
}
}
和在{ export type Spread<L extends object, R extends object> = Id<
// Merge the properties of L and R into a partial (preserving order).
Partial<{ [P in keyof (L & R)]: SpreadProp<L, R, P> }> &
// Restore any required L-exclusive properties.
Pick<L, Exclude<keyof L, keyof R>> &
// Restore any required R properties.
Pick<R, RequiredProps<R>>
>
/** Merge a property from `R` to `L` like the spread operator. */
type SpreadProp<
L extends object,
R extends object,
P extends keyof (L & R)
> = P extends keyof R
? (undefined extends R[P] ? L[Extract<P, keyof L>] | R[P] : R[P])
: L[Extract<P, keyof L>]
/** Property names that are always defined */
type RequiredProps<T extends object> = {
[P in keyof T]-?: undefined extends T[P] ? never : P
}[keyof T]
/** Eliminate intersections */
type Id<T> = { [P in keyof T]: T[P] }
代码在下面给出
urls.py
get_absolute_url
models.py
urls
views.py(缩短)
from django.urls import path
from . import views
from .views import PostCreateView
urlpatterns=[
path('',views.BlogsList.as_view(),name='blog-home'),
path('<int:blog_id>/like/', views.like_post, name='like_post'),
path('post/<int:id>/', views.post_detail, name='post-detail'),
path('post/new/',PostCreateView.as_view(),name='post-create'),
]
答案 0 :(得分:0)
get_absolute_url
方法采用单个参数。您使用过blog_id
,但是通常在Python中我们使用self
。
在方法中,self
是您要返回其ID的博客实例。您可以使用self.id
或self.pk
来获得。
def get_absolute_url(self):
return reverse('post-detail', args=[self.pk])