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 <shubhipan...@gmail.com> wrote:the error is:django.core.exceptions.FieldError: Unknown field(s) (e-resource) specified for Postmodels.pyclass Post(models.Model):e_resource = models.FileField(null=True,blank=True,validators=[FileExtensionValidator( ['pdf'] ) ],upload_to='')views.pydef 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_datacdform.save()return HttpResponse("File Uploaded successfully")else:form = PostForm()return render(request, 'uploadAttendance.html', {'form': form,'shop' : shop})forms.pyclass PostForm(forms.ModelForm):class Meta:model = Postfields = ['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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4d3c352d-cb02-467f-b8df-82ba098ebde6n%40googlegroups.com.
No comments:
Post a Comment