Answer the question
In order to leave comments, you need to log in
How to resolve django url conflict?
Ku
Is urls.py
urlpatterns = [
path('', EquipPage.as_view(), name = 'EquipPage'),
path('helmets/',UserInventoryHelmet.as_view(),name='InvHelmet'),
path('<str:inv_helmet_unique_id>',SetNewHelm.as_view(),name='equipHelmet'),
path('gloves/',UserInventoryGlove.as_view(),name='InventGlove'),
path('<str:inv_glove_unique_id>/',SetNewGlove.as_view(),name='EquipGlove'),
path('pants/', UserInventPants.as_view(), name='InvPants'),
path('<str:inv_torso_unique_id>/',SetNewPants.as_view(),name='EquipTorso'),
path('chests/',UserInventoryChest.as_view(),name='InvChest'),
path('<str:inv_armour_unique_id>/',SetNewChest.as_view(),name='EquipBodyArmour'),
]
class UserInventoryHelmet(UserInfo,View):
def get(self, request, *args, **kwargs):
uid = request.user.id
logic_data = super(UserInventoryHelmet, self)
context = {}
user_stat_list = logic_data.UserStat(uid)
context = user_stat_list
context['active_helmet'] = UserHelmet.objects.filter(user_helmet_id=uid)
context['invent_helmet'] = UserInvHelmet.objects.filter(inv_helmet_id=uid)
return render(request,'equip/helmets.html',context)
class SetNewHelm(EqHelmet,UserInfo,View):
def post(self,request,inv_helmet_unique_id,*args,**kwargs):
uid = request.user.id
if request.method == "POST":
logic_data = super(SetNewHelm, self)
is_h_eq = logic_data.set_new_helm(uid,inv_helmet_unique_id)
if is_h_eq:
messages.add_message(request, messages.INFO, "Надели шлем")
return redirect('EquipPage')
else:
messages.add_message(request, messages.INFO, "Этого предмета не существует")
return redirect('EquipPage')
Answer the question
In order to leave comments, you need to log in
Remove extra routes in urls.py, perhaps after that the request will still get into your UserInvertoryHelmet. So far, it seems that it falls into one of the SetXXX.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question