Friday, March 24, 2023

Re: Help in django. I want to upload files

yeah, Ryan's comment definitely makes sense

On Thursday, 23 March 2023 at 20:22:17 UTC+5:30 Ryan Nowakowski wrote:
Your field is called e_resource with an underscore but you're trying to reference it using a dash.

On March 22, 2023 11:40:00 PM CDT, Shubhi Pandey <> wrote:
the error is:
django.core.exceptions.FieldError: Unknown field(s) (e-resource) specified for Post
class Post(models.Model):
    e_resource = models.FileField(null=True,
                           validators=[FileExtensionValidator( ['pdf'] ) ],upload_to='')
def uploadResource_details(request,shop):
     shop = workshop_details.objects.get(w_id=shop)
     if request.method == 'POST':
        form = PostForm(request.POST, request.FILES)
        if form.is_valid():
            cdform = form.cleaned_data
            return HttpResponse("File Uploaded successfully")
        form = PostForm()
     return render(request, 'uploadAttendance.html', {'form': form,'shop' : shop})
class PostForm(forms.ModelForm):
    class Meta:
        model = Post
        fields = ['e-resource']

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

No comments:

Post a Comment