no whts up only insta On Mon, 31 Aug 2020 at 14:22, sherry wilson <sherrywilson...@gmail.com> wrote:
> contact on whatsapp i will clear your issues +916238639239 if its not yet > cleared > > On Mon, Aug 31, 2020 at 11:45 AM Deepraj Devikar <deepraj.du...@gmail.com> > wrote: > >> yes you have to forgot upload_to in models.py imagefield >> >> you can refer my repository >> https://github.com/Deepraj-devikar/image-upload-react-django >> >> files are >> settings.py line number 135, 136 >> url.py line number 31 >> imagehadler/models.py line number 8 >> >> >> On Sun, Aug 30, 2020 at 10:40 AM MUGOYA DIHFAHSIH <dihfahs...@gmail.com> >> wrote: >> >>> On your imagefield you forgot to add >>> upload_to="folder_inside_your_media_folder" >>> >>> On Sat, Aug 29, 2020, 19:48 allaberdi...@gmail.com < >>> allaberdi16yazha...@gmail.com> wrote: >>> >>>> I can upload images from django admin panel but cannot to do same thing >>>> with django form , it saves any text but did not save images only, anyone >>>> help me please >>>> github <https://github.com/alyyazkhanov/my-firs-blog.git> >>>> this is my code: >>>> >>>> models.py: >>>> class Posts(models.Model): >>>> >>>> Ahal = 'Ahal' >>>> Balkan = 'Balkan' >>>> Dasoguz = 'Dasoguz' >>>> Lebap = 'Lebap' >>>> Mary = 'Mary' >>>> >>>> >>>> CHOOSE_REGION = { >>>> (Ahal,'Ahal'), >>>> (Balkan,'Balkan'), >>>> (Dasoguz,'Dasoguz'), >>>> (Lebap,'Lebap'), >>>> (Mary,'Mary') >>>> } >>>> >>>> >>>> name = models.CharField(max_length=30, blank=False, verbose_name='Ady') >>>> image = models.ImageField(blank=True, null=True, verbose_name='surat') >>>> text = models.TextField(verbose_name='gosmaça maglumat') >>>> price = models.FloatField(verbose_name='bahasy') >>>> region = models.CharField(max_length=30, choices=CHOOSE_REGION, >>>> blank=False, verbose_name='welaýat') >>>> district = models.CharField(max_length=30, blank=False, >>>> verbose_name='etrab') >>>> user = models.ForeignKey(User, on_delete=models.CASCADE, >>>> verbose_name='eýesi') >>>> phone = models.CharField(max_length=50, blank=False, >>>> verbose_name='telefon belgisi') >>>> published = models.DateTimeField(auto_now=True, verbose_name='satuwa >>>> çykan guni') >>>> >>>> >>>> >>>> forms.py: >>>> class PostForm(forms.ModelForm): >>>> class Meta: >>>> model = Posts >>>> fields = >>>> ['name','image','text','price','region','district','user','phone'] >>>> >>>> >>>> views.py: >>>> def add_post(request): >>>> form = PostForm(request.POST or None) >>>> if form.is_valid(): >>>> form.save() >>>> template = 'add_post.html' >>>> context = {'form':form} >>>> return render(request,template,context) >>>> >>>> settings.py: >>>> >>>> STATIC_URL = '/static/' >>>> STATICFILES_DIR = [Path(BASE_DIR,'static')] >>>> >>>> MEDIA_URL = '/media/' >>>> MEDIA_ROOT = Path(BASE_DIR,'media') >>>> >>>> >>>> urls.py: >>>> >>>> from django.conf.urls.static import static >>>> from django.conf import settings >>>> >>>> urlpatterns = [ >>>> path('admin/', admin.site.urls), >>>> path('', include('posts.urls')), >>>> ] >>>> >>>> urlpatterns += static(settings.MEDIA_URL, >>>> document_root=settings.MEDIA_ROOT) >>>> >>>> >>>> >>>> html form tag: >>>> {% extends 'index.html' %} >>>> >>>> {% load static %} >>>> >>>> {% block content %} >>>> >>>> <form method="post" enctype="multipart/form-data"> >>>> {% csrf_token %} >>>> {{form.media}} >>>> {{form.as_p}} >>>> <input type="submit" value="Save" name=""> >>>> </form> >>>> >>>> {% endblock %} >>>> >>>> -- >>>> 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+unsubscr...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-users/a403ac50-9dfb-4a48-8007-9a52579886d4n%40googlegroups.com >>>> <https://groups.google.com/d/msgid/django-users/a403ac50-9dfb-4a48-8007-9a52579886d4n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >>> 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+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/CAP%3DJD9yJCOHs4bTCkhLK1meriLREBD3z%3Dd%3D8y6h9KOMAj80_yQ%40mail.gmail.com >>> <https://groups.google.com/d/msgid/django-users/CAP%3DJD9yJCOHs4bTCkhLK1meriLREBD3z%3Dd%3D8y6h9KOMAj80_yQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> 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+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAL0P1EWhxziVQECJ-ZTc%2BDCXirCWjiOjoCWDP2OPCs75GH%2B1rw%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAL0P1EWhxziVQECJ-ZTc%2BDCXirCWjiOjoCWDP2OPCs75GH%2B1rw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAPaR5pRYY%2B%3Dkr2qM6z0if8cjohR8%3DSQfLB5hZ8Yaf9tW%3DV%3DO%3DA%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAPaR5pRYY%2B%3Dkr2qM6z0if8cjohR8%3DSQfLB5hZ8Yaf9tW%3DV%3DO%3DA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJhs3iOQK_AsXp3xhshRfarS-44eC1QKZ-WgJ0Y%3DaS4Jao7jUA%40mail.gmail.com.