My view currently returns an error of
The view viajecenter.views.receive_payment didn't return an HttpResponse object. It returned None instead.
I tried some of the solutions from other related posts here but of no luck.
Here is my function in my views.py file:
def receive_payment(request, account_code):
template_name = 'receive-payment.html'
user = request.user
account = get_object_or_404(Account, account_code=account_code)
if user.is_assigned:
puv = Puv.objects.get(assignment_id=user.assignment_id)
locations = puv.route.locations.all().order_by('distance_from_base')
context = {
'account': account,
'puv': puv,
'locations': locations,
}
return render(request, template_name, context)
else:
return user
and the corresponding url in urls.py file:
from django.urls import path
from . views import ..., receive_payment
urlpatterns = [
...
path('receive-payment/<str:account_code>', receive_payment, name="receive-payment"),
]
and my Account model:
class Account(AbstractBaseUser, PermissionsMixin):
...
account_code = models.UUIDField(default=uuid.uuid4, editable=False)
is_assigned = models.BooleanField(default=False)
Thank you for lending me your time and answering my question :)
get_context_data
is only a thing for class-based views, not function-based views like yourreceive_payment
currently is. – AKX