Hello i can't upload the file, i'm in a debug mode:
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('', include('polls.urls')),
path('admin/', admin.site.urls),
]
if settings.DEBUG is True:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
The model is:
class Disegni(models.Model):
iddisegni = models.AutoField(primary_key=True)
descrizione = models.CharField(max_length=45, blank=True, null=True)
revisione = models.CharField(max_length=45, blank=True, null=True)
file = models.FileField(upload_to='disegni/', blank=True, null=True)
class Meta:
managed = False
db_table = 'disegni'
the forms is:
class DisegniForm(forms.ModelForm):
class Meta:
model = Disegni
fields = ('iddisegni', 'descrizione', 'revisione', 'file')
labels = {'descrizione':'Descrizione', 'revisione':'Revisione', 'file':'File'}
The settings.py is:
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
STATIC_ROOT = "E:/dngo/mysite/polls/static"
MEDIA_ROOT = "E:/dngo/mysite/polls/media"
the template is generated
The template is just :
{% load static %}
<head>
<link rel="stylesheet" href="{%static "regole.css" %}">
</head>
<form form action="salvo_nuovo" method="post">{% csrf_token %}
{{ form.as_p }}
<button type="submit">Salva</button>
</form>
I never get errors but the file is not uploaded
Where is my mistake?