# Images are not appearing

**URL:** <https://forum.djangoproject.com/t/images-are-not-appearing/27670>\
**Category:** Forms & APIs\
**Created:** [February 1, 2024, 8:35pm UTC](https://forum.djangoproject.com/t/images-are-not-appearing/27670 "2024-02-01T20:35:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdelhai95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/abdelhai95/32/18900_2.png) [@abdelhai95](https://forum.djangoproject.com/u/abdelhai95)\
**Post date:** [February 1, 2024, 8:35pm UTC](https://forum.djangoproject.com/t/images-are-not-appearing/27670/1 "2024-02-01T20:35:14Z")

</div>

I have this structure  
 ![structure](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/6/8/68dd9d288f5aa4b5bcdc7c2b4271b26de1630456.png)

my models

```auto
class Post(models.Model):
    title = SummernoteTextField()
    title_ar = SummernoteTextField()
    image = models.ImageField(upload_to='blog/static/blog/images',blank=True, null=True)
    body = models.TextField(null=False)
    body_ar = models.TextField(null=False)
    author = SummernoteTextField(max_length=30, null=True)
    author_ar = SummernoteTextField(max_length=30, null=True)
    created_on = models.DateTimeField(auto_now_add=True)
    categories = models.ManyToManyField("Category", related_name="posts")

    def __str__ (self):
        return self.title

```

these are my urls

```auto
urlpatterns = [
    path('i18n/', include('django.conf.urls.i18n')),
    path('admin/', admin.site.urls),
]

urlpatterns += i18n_patterns(
    path('blog/', include("blog.urls")),
    path('summernote/', include('django_summernote.urls'))
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

```

these are my media and static settings

```auto
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

```

I upload images via admin panel.

I get this error in terminal:

> Not Found: /blog/static/blog/images/maket2.png  
> GET /blog/static/blog/images/maket2.png HTTP/1.1" 404 2514

The path shown when I inspect images in developer tools  
/blog/static/blog/images/maket1.png

How I added images

```auto
<img src="/{{post.image}}">

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 1, 2024, 9:00pm UTC](https://forum.djangoproject.com/t/images-are-not-appearing/27670/2 "2024-02-01T21:00:24Z")

</div>

Don’t confuse the purpose and usage of static files vs media files.

Static files are files that are part of the project itself. Media files are files uploaded while the system is running.

You manage the two sets of files differently, they are _not_ handled the same.

It also matters whether you’re talking about your development environment or your production environment.

In a production-quality deployment, neither of those directories (`STATIC_ROOT` and `MEDIA_ROOT`) should be in your project. They should refer to directories outside your project directory, in locations that your web server will have access to.

With that information, see:

- [How to manage static files (e.g. images, JavaScript, CSS) | Django documentation | Django](https://docs.djangoproject.com/en/5.0/howto/static-files/)
- [How to deploy static files | Django documentation | Django](https://docs.djangoproject.com/en/5.0/howto/static-files/deployment/)
- [Managing files | Django documentation | Django](https://docs.djangoproject.com/en/5.0/topics/files/)

Some of the items I see:

- Your `upload_to` appears to be referencing your static file directory.
- You don’t display images by referencing the “image” attribute. You use the `url` attribute to have Django create the url for a media file.

Also, for full diagnostics here, we’d need to know what web server you’re using and how _it_ is configured for your static and media files.

---

<div class="post-metadata">

**Author:** ![abdelhai95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/abdelhai95/32/18900_2.png) [@abdelhai95](https://forum.djangoproject.com/u/abdelhai95)\
**Post date:** [February 2, 2024, 7:53am UTC](https://forum.djangoproject.com/t/images-are-not-appearing/27670/3 "2024-02-02T07:53:39Z")

</div>

Thanks, @KenWhitesell, I’m in the development phase, using Django server.  
Can you recommend resources to read more about the difference between media and static files?

what I did and make my photos appear is :

- changed the `upload_to` path to a new folder that isn’t for the static files.
- used the `url` attribute with the `src`.
- `MEDIA_ROOT` and `MEDIA_URL` are the same.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 2, 2024, 12:51pm UTC](https://forum.djangoproject.com/t/images-are-not-appearing/27670/4 "2024-02-02T12:51:06Z")

</div>

> [@abdelhai95](#):
>
> Can you recommend resources to read more about the difference between media and static files?

> [@KenWhitesell](#):
>
> Static files are files that are part of the project itself. Media files are files uploaded or created while the system is running.

That’s really all there is to it as far as the difference between them.

> [@abdelhai95](#):
>
> I’m in the development phase …

When you are moving this into production, you are going to want MEDIA\_ROOT and STATIC\_ROOT pointing to directories outside your project directory.
