vendredi 14 mai 2021

ModuleNotFoundError: No module named 'models' and TypeError: argument of type 'PosixPath' is not iterable

I tried the previous fixes in other tutorials but they didn't work. Here's what I have:

...
from models import Tutorial #crashes
from backend.restApis.tutorials.serializers import TutorialSerializer


@api_view(['GET', 'POST', 'DELETE'])
def tutorial_list(request):
  # GET list of tutorials, POST a new tutorial, DELETE all tutorials
  if request.method == 'GET':
    tutorials = Tutorial.objects.all()
    title = request.GET.get('title', None)

    if title is not None:
      tutorials = tutorials.filter(title__icontains=title)

    tutorials_serializer = TutorialSerializer(tutorials, many=True)
    return JsonResponse(tutorials_serializer.data, safe=False)
...

I have tried renaming the reference but it doesn't work, here's the file structure Project File Structure

I am new to django and appreciate any help !




Aucun commentaire:

Enregistrer un commentaire