Django Saving a form with Imagefield on shared host

55 views
Skip to first unread message

MUGOYA DIHFAHSIH

unread,
Jun 14, 2020, 9:46:39 AM6/14/20
to Django users
I am working on django project and now i have deployed it with Namecheap
When i submit a form that does not have an ImageField, the form submits successfully on the shared host
but when i submit a form with one of the fields ImageField, it raises 404 error.
but on the localhost, the forms work perfectly.
what can i do to submit such forms on a shared host.
Thanks.

Capture.JPG

Kelvin Sajere

unread,
Jun 15, 2020, 3:55:28 PM6/15/20
to django...@googlegroups.com
Did you specify a folder to use for media when you deployed your app? If so, then make sure it's where you are supposed to have your media folder. If it's a single hosting, then it should be in the public_html folder, but on multiple hosting, it should be in the domain-specific folder. I never really host my media on NameCheap or any other hosting for that matter though. I use either AWS or GOOGLE CLOUD SERVICES for that.

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b79bb9b5-46b4-43eb-9ea5-3eaab14336ddo%40googlegroups.com.


--
KeLLs

MUGOYA DIHFAHSIH

unread,
Jun 17, 2020, 1:55:44 AM6/17/20
to Django users
Hey Kelvin thanks for your esteemed reply, i specified the media folder but i think there is something to do with apache and mod_wsgi so as to serve the static urls and the media files

Vishesh Mangla

unread,
Jun 17, 2020, 3:06:25 AM6/17/20
to django...@googlegroups.com

One thing that can be done is to save the image as a base64 string in the database. https://stackoverflow.com/questions/3715493/encoding-an-image-file-with-base64

 

Sent from Mail for Windows 10

--

Kelvin Sajere

unread,
Jun 17, 2020, 5:33:03 AM6/17/20
to django...@googlegroups.com
If you indeed have your media folder where it’s supposed to be, then make sure in your settings file, you have specified that folder as your root folder for media. I don’t see your code, so this might be difficult to determine on my end.
--
KeLLs

MUGOYA DIHFAHSIH

unread,
Jun 18, 2020, 1:30:30 AM6/18/20
to django...@googlegroups.com
@Mangla, essentially what i want to do is to serve uploaded images on a shared host through the media directory in my project root. I have deployed the web app the static files such as css and images are working fine, but when i try to submit a form that has imagefield into the database, it throws 404 error. I know it has to deal with the Aoache web server and the mod_wsgi but how?

Mostaq mahmud

unread,
Jul 11, 2020, 2:59:01 PM7/11/20
to Django users
It's about Mod_Security issue. Contact to the hosting support and tell them to disable Mod_Security. 


On Thursday, June 18, 2020 at 11:30:30 AM UTC+6, MUGOYA DIHFAHSIH wrote:
@Mangla, essentially what i want to do is to serve uploaded images on a shared host through the media directory in my project root. I have deployed the web app the static files such as css and images are working fine, but when i try to submit a form that has imagefield into the database, it throws 404 error. I know it has to deal with the Aoache web server and the mod_wsgi but how?

On Wed, 17 Jun 2020 at 10:06, Vishesh Mangla <manglav...@gmail.com> wrote:

One thing that can be done is to save the image as a base64 string in the database. https://stackoverflow.com/questions/3715493/encoding-an-image-file-with-base64

 

Sent from Mail for Windows 10

 

From: MUGOYA DIHFAHSIH
Sent: 14 June 2020 19:15
To: Django users
Subject: Django Saving a form with Imagefield on shared host

 

I am working on django project and now i have deployed it with Namecheap

When i submit a form that does not have an ImageField, the form submits successfully on the shared host

but when i submit a form with one of the fields ImageField, it raises 404 error.

but on the localhost, the forms work perfectly.

what can i do to submit such forms on a shared host.

Thanks.

 

--
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...@googlegroups.com.

--
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...@googlegroups.com.

Stanley Valentin

unread,
Jul 12, 2020, 12:28:30 AM7/12/20
to django...@googlegroups.com
J'arrive pas à comprendre....! Tu parles français. Si ça marche pas il est possible que tu a fait une erreur

Le 15 juin 2020 14:55, "Kelvin Sajere" <kells...@gmail.com> a écrit :
Did you specify a folder to use for media when you deployed your app? If so, then make sure it's where you are supposed to have your media folder. If it's a single hosting, then it should be in the public_html folder, but on multiple hosting, it should be in the domain-specific folder. I never really host my media on NameCheap or any other hosting for that matter though. I use either AWS or GOOGLE CLOUD SERVICES for that.

On Sun, Jun 14, 2020 at 2:46 PM MUGOYA DIHFAHSIH <dihfa...@gmail.com> wrote:
I am working on django project and now i have deployed it with Namecheap
When i submit a form that does not have an ImageField, the form submits successfully on the shared host
but when i submit a form with one of the fields ImageField, it raises 404 error.
but on the localhost, the forms work perfectly.
what can i do to submit such forms on a shared host.
Thanks.

--
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.


--
KeLLs

--
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/CADYqDX2jnwmxOFs5Vz2fnezxs2KMPLh5uh6XVNrz1U36BuBN1g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages