In settings.py I have:
BASE_DIR = Path(__file__).resolve().parent.parent
Then In some view:
from django.http import HttpResponse
from django.conf import settings
def test_view(request):
return HttpResponse( settings.BASE_DIR.replace("src", "") )
This gives error: replace() takes 2 positional arguments but 3 were given
It confuses me, how that error appears? also if do:
return HttpResponse( settings.BASE_DIR )
this returns full path, something like: /home/full/path/to/project/src
also this works
return HttpResponse( "/home/full/path/to/project/src".replace("src", "") )
Can you help me and tell what is wrong with this line:
return HttpResponse( settings.BASE_DIR.replace("src", "") )
?
Convert it to string
:
str(settings.BASE_DIR).replace("src", "")