User
Model.py
class techgroup(models.Model):
Technology=models.CharField(max_length=50)
def __str__(self):
return self.Technology
views.py
def technology(request,id,*args, **kwargs):
Technology = techgroup.objects.all()
print(Technology)
selected_item = get_object_or_404(techgroup,
pk=request.POST.get('Technology_id'))
# get the user you want (connect for example) in the var "user"
techgroup.Technology = selected_item
techgroup.save()
context = {'Technology': Technology}
return render(request, "analytics/radio.html", context)
url.py
path('technology/<int:pk>/', views.technology, name='technology'),
What is wrong in this code? I'm getting the following error
technology() missing 1 required positional argument: 'id'
User
This question doesn't have anything to do with your title.
Your view is expecting an argument called id
. But your URL is providing one called pk
. These need to match. Change the URL:
path('technology/<int:id>/', ...)
General Tech Technology & Software
1 Replies