Using the URLconf defined in Django tried these URL patterns in this order:

I have a django app. And some upload functionality teit.

The page with the upload function is loading correcttly.

But after I do a submit. I get this errror:

Page not found (404)
Request Method:     POST
Request URL:

Using the URLconf defined in schoolfruitnvwa.urls, Django tried these URL patterns, in this order:


The current path, main/, didn’t match any of these.

so this is the

from .forms import ProfileForm
from .models import UploadFile

# Create your views here.
""" def store_file(file):
    with open("temp/hello.png", "wb+") as dest:
        for chunk in file.chunks():
            dest.write(chunk) """

class CreateProfileView(View):
    def get(self, request):
        form = ProfileForm()
        return render(request, "main/create_profile.html", {
            "form": form

    def post(self, request):
        submitted_form = ProfileForm(request.POST, request.FILES)

        if submitted_form.is_valid():
            uploadfile = UploadFile(image=request.FILES["upload_file"])
            return HttpResponseRedirect("/")

        return render(request, "main/create_profile.html", {
            "form": submitted_form

from django.urls import path

from . import views

urlpatterns = [
    path("", views.CreateProfileView.as_view())

class ProfileForm(forms.Form):
    upload_file = forms.FileField()

So my question is: what I have to change?

I try it like this:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('main/', include('main.urls', namespace='main')),

But then I cant run the app:

    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.

You must check the url defined in the (this files is located near your of your project and add. Be careful Django got files i can't be a bit disturbing at the start

in (near :

path('main/', include('youappname.urls', namespace="app_namespace")),

in (of your app)

app_name = 'yourappname'

urlpatterns = [
    path(...your api function call...),

ohhh, in the html file there was standing: /main/

  <form action="/" method="post" enctype="multipart/form-data">
      {% csrf_token %} {{ form }}
      <button type="submit">Upload!</button>
Back to Top