第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

DoesNotExist at /profiles/user-profile/

DoesNotExist at /profiles/user-profile/

有只小跳蛙 2023-10-25 10:54:48
我正在嘗試添加跟隨切換,但在我看來,我在匹配查詢集時遇到錯誤。用戶配置文件存在于數(shù)據(jù)庫中,但我仍然不知道為什么會發(fā)生這種情況。我希望你能找出我的錯誤并告訴我如何解決它。我正在學(xué)習(xí) Django,如果你能幫助我,那意義重大。我將感謝你。如果需要更多代碼來幫助我,我會分享。class UserProfileFollowToggle(View):    def post(self, request, *args, **kwargs):        print(request.POST)        user_to_toggle = request.POST.get('username')        print(user_to_toggle)        profile_ = UserProfile.objects.get(user__username__iexact=user_to_toggle)        user = request.user        if user in profile_.follower.all():            profile_.follower.remove(user)        else:            profile_.follower.add(user)        return redirect("/posts/list/") follow_toggle.html:<form class='form' method='POST' action={% url 'profiles:toggle' %}>{% csrf_token %}<input type='hidden' name='username' value="{% if username %}{{ username }} {% else %}{{ testuser }}{% endif %}"><button class='btn {% if is_following %}btn-default {% else %}btn-primary{% endif %}'>{% if is_following %}Unfollow {% else %}Follow{% endif %}</button></form>
查看完整描述

1 回答

?
阿波羅的戰(zhàn)車

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超6個贊

它將在末尾呈現(xiàn)一個空格。因此,模板應(yīng)如下所示:


#                                                                 no space ↓

<input type='hidden' name='username' value="{% if username %}{{ username }}{% else %}{{ testuser }}{% endif %}">



查看完整回答
反對 回復(fù) 2023-10-25
  • 1 回答
  • 0 關(guān)注
  • 147 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號