1
我正在尋找從django模型的默認ID鍵把它變成十六進制,並顯示它在一個頁面上,當用戶sumbits帖子時,我已經嘗試了幾個方法沒有成功可以任何人都指向正確的方向?python django id到十六進制
views.py
def post_new(request):
if request.method == "POST":
form = PostForm(request.POST)
if form.is_valid():
post = form.save(commit=False)
post.author = request.user
post.published_date = timezone.now()
post.save()
return redirect('post_detail', pk=post.pk)
else:
form = PostForm()
return render(request, 'books_log/post_edit.html', {'form': form})
如果需要,可以提供更多的信息。
{{my_object.to_hex()}}刪除()從my_object.to_hex 這工作就像一個魅力!謝謝!! –
很高興有幫助。 – e4c5