# Update staticfiles

**URL:** <https://forum.djangoproject.com/t/update-staticfiles/15823>\
**Category:** Deployment\
**Created:** [September 5, 2022, 7:51am UTC](https://forum.djangoproject.com/t/update-staticfiles/15823 "2022-09-05T07:51:16Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyperswiss](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hyperswiss/32/5814_2.png) [@hyperswiss](https://forum.djangoproject.com/u/hyperswiss)\
**Post date:** [September 5, 2022, 7:51am UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/1 "2022-09-05T07:51:16Z")

</div>

Just looking for a confirmation here.

I have a website in a prod phase and need to update the css (sass). Just want to be sure that collectstatic will look only at the modified files with their timestamp, and not the whole thing (css, img, media) as it did once when I probably forgot to activate the virtual env

Thank you for your feedback.

---

<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:** [September 5, 2022, 1:56pm UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/2 "2022-09-05T13:56:34Z")

</div>

Yes, as documented at [The staticfiles app | Django documentation | Django](https://docs.djangoproject.com/en/4.1/ref/contrib/staticfiles/#collectstatic).

However, keep in mind that depending upon your deployment process, the dates for _all_ files might be changed to the date of the deployment, leading to all files being collected.

---

<div class="post-metadata">

**Author:** ![hyperswiss](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hyperswiss/32/5814_2.png) [@hyperswiss](https://forum.djangoproject.com/u/hyperswiss)\
**Post date:** [September 5, 2022, 2:18pm UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/3 "2022-09-05T14:18:59Z")

</div>

Thank you for confirming it. I’ll check that timestamp then before processing.

---

<div class="post-metadata">

**Author:** ![hyperswiss](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hyperswiss/32/5814_2.png) [@hyperswiss](https://forum.djangoproject.com/u/hyperswiss)\
**Post date:** [September 7, 2022, 9:00am UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/4 "2022-09-07T09:00:35Z")

</div>

It didn’t work the way I thought. After running a collectstatic, I ended up with a recursive additional staticfiles folder, inside the previous one, with the same files in it than in its parent folder.

---

<div class="post-metadata">

**Author:** ![Spha](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/spha/32/9509_2.png) [@Spha](https://forum.djangoproject.com/u/Spha)\
**Post date:** [September 7, 2022, 11:07am UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/5 "2022-09-07T11:07:12Z")

</div>

Examine “STATIC\_ROOT” and/or “STATICFILES\_DIRS” in settings.py, how have you configured them?

---

<div class="post-metadata">

**Author:** ![hyperswiss](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hyperswiss/32/5814_2.png) [@hyperswiss](https://forum.djangoproject.com/u/hyperswiss)\
**Post date:** [September 8, 2022, 8:54am UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/6 "2022-09-08T08:54:52Z")

</div>

Hello, yes I did. As per below :

```auto
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles/')
STATICFILES_DIRS = [
    BASE_DIR, 'static',
]

```

See any mistake in there ?

Thanks

---

<div class="post-metadata">

**Author:** ![Spha](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/spha/32/9509_2.png) [@Spha](https://forum.djangoproject.com/u/Spha)\
**Post date:** [September 8, 2022, 1:22pm UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/7 "2022-09-08T13:22:34Z")

</div>

It’s basically configured the same way in my settings.py although I defined STATICFILES\_DIRS the old way:  
`STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static/'),)`  
It probably shouldn’t make any difference though.

You could probably try removing (or commenting out) this `STATICFILES_DIRS` option entirely, and see if it makes a difference.

---

<div class="post-metadata">

**Author:** ![hyperswiss](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hyperswiss/32/5814_2.png) [@hyperswiss](https://forum.djangoproject.com/u/hyperswiss)\
**Post date:** [September 9, 2022, 6:13am UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/8 "2022-09-09T06:13:37Z")

</div>

Didn’t change anything.

I forgot one detail, don’t know if it’s relevant or not, my static files, and the templates for that matter, are not located in the apps, but directly in the project/root folder. I don’t think it can have an influence on the collecstatic command though.

---

<div class="post-metadata">

**Author:** ![Spha](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/spha/32/9509_2.png) [@Spha](https://forum.djangoproject.com/u/Spha)\
**Post date:** [September 9, 2022, 9:12am UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/9 "2022-09-09T09:12:48Z")

</div>

My staticfiles folder is at the root of the project too. You could probably delete the staticfiles folder and anything inside it. It doesn’t seem like normal behaviour when running that command.

---

<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:** [September 9, 2022, 1:18pm UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/10 "2022-09-09T13:18:43Z")

</div>

Actually, this does appear to be a configuration issue.

You have:

> [@hyperswiss](#):
>
> ```auto
> STATICFILES_DIRS = [
> BASE_DIR, 'static',
> ]
> 
> ```

The collectstatic is going to search _each_ of those directories, in turn, and find the static files to copy. So what’s happening is that it’s finding the `static` directory inside `BASE_DIR` and the files in `static` directly causing two copies to be made.

---

<div class="post-metadata">

**Author:** ![Spha](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/spha/32/9509_2.png) [@Spha](https://forum.djangoproject.com/u/Spha)\
**Post date:** [September 9, 2022, 3:28pm UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/11 "2022-09-09T15:28:24Z")

</div>

Yes actually, good eye… I think it should look like this:

```auto
STATICFILES_DIRS = [
     BASE_DIR / "static",
 ]

```

---

<div class="post-metadata">

**Author:** ![hyperswiss](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hyperswiss/32/5814_2.png) [@hyperswiss](https://forum.djangoproject.com/u/hyperswiss)\
**Post date:** [September 10, 2022, 6:11am UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/12 "2022-09-10T06:11:17Z")

</div>

Holy, didn’t know this could be of importance except in the case you want escape some characters. I tend to use single or double quotes a little randomly I must say.

Thanks for your input, will give it a try

---

<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:** [September 10, 2022, 11:58am UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/13 "2022-09-10T11:58:27Z")

</div>

It’s not the quotes that’s the issue here - it’s the separator between the two strings.

`[BASE_DIR , 'static']` is a list of two strings.

`[BASE_DIR / 'static']` _or_ `[BASE_DIR / "static"]` is a list with one string, assuming BASE\_DIR is a pathlib object.

---

<div class="post-metadata">

**Author:** ![hyperswiss](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hyperswiss/32/5814_2.png) [@hyperswiss](https://forum.djangoproject.com/u/hyperswiss)\
**Post date:** [September 15, 2022, 1:16am UTC](https://forum.djangoproject.com/t/update-staticfiles/15823/14 "2022-09-15T01:16:35Z")

</div>

Thanks a lot, just had it done, only the modified files have been, well, modified, others are untouched.
