i have been majorly stuck trying to server the static admin files in production. based on the hours ive spent on this, my configuration (gunicorn, whitenoise) seems fine
but no matter what, i cant get the static files in production
furthermore, if i enable the whitenoise STATICFILES_STORAGE, i get server error 500 responses
im deploying to heroku and it seems like the issue might be that collectstatic is failing but i have had no luck fixing it
kanja joined the channel
maktm has left the channel
god joined the channel
Catatronic has quit
cybo_
badfilms, suggest saying what the actual error is. as in the traceback you get
badfilms
my logs show 404 errors for the /admin content
ie css/responive.css etc
cybo_
and all the other static files are working?
Catatronic joined the channel
badfilms
my static files are limited to admin for this project
NomadJim has quit
NomadJim joined the channel
amirpro joined the channel
cybo_
did you follow the django documentation for setting up static files in production?
badfilms
yes
backnforth joined the channel
whatcha has quit
cybo_
you have STATIC_ROOT in your settings?
god
what are some good uses for django's TIME_ZONE variable? i can't think of any
i basically have two situations right now. if i exclude STATICFILES_STORAGE, i can visit /admin with no styles. if i include STATICFILES_STORAGE, i get server error 500 when visiting .admin
s/.admin/\/admin/g
converse has quit
cybo_
surely if you have a 500, you'll get an exception in your logs?
also a crazy thought, is admin in your installed_apps?
InsigkneeUh joined the channel
gutierri has quit
badfilms
yeah
i can deploy locally no problem
amirpro joined the channel
cybo_
Oh, are you setting the storage to the manifest storage?
badfilms
if i run findstatic on core.js, it returns /usr/local/lib/python3.6/site-packages/django/contrib/admin/static/admin/js/core.js
I know it's daft, but is it possible you have DISABLE_COLLECTSTATIC set too?
badfilms
debug_collectstatic is 0
i'll need to make a few changes before i can ship with debbing enabled
1 sec
gutierri has quit
kutenai
Hi all.
I have a potential issue.. or discussion, lets assume i have 2 models M1 and M2, where M1 has a ForeignKey to M2. Lets also assume that half of M1 objects point to one instance of M2, and the other half point to the other M2.
So 100 M1's that use 2 different M2's
If I query all M1's and use .select_related('M2'), and then iterate over M1's.. and while accessing an M1, I perform an operation on the m1.m2, and save it...
Do the rest of my M1's in the queryset have a 'cached' copy of m1 before that save?
This appears to be the case in my situation..
If I'm correct, can I avoid that, or turn that off.. would it help to remove it from select related?
cybo_
do you mean cached copy or m2?
badfilms
cybo_: i broke something lol... now im getting bad request 400
kutenai
yes. say I do this: m1[20].m1.value = 'X' then m1[20].m1.save() then, later print(m1[21].m1.value)
Assuming m1[20] and m1[21] had a FK to the same m2
cybo_
kutenai, you should keep a reference to m1. I've had cases where it refetches in the past, so the value assignment never persists
kutenai
That's what I think is happening.. if I modify an m2 through one FK relationship, the other FK relationships don't appear to have that modification, and they attempt to modify this again
In my case, m2 is a "symbol" object, and it has a generated base64-image. I iterate over the main objects that use the image, and many of those use the same image.
If any of them find that the symbol image isn't set, they will calculate that, set it, and save the object, but I was seeting the same object saved repeatedly.. which should not have happened.. in theory.
cybo_
is this dj2.0?
kutenai
yes
oh..
sorry, no, 1.11
cybo_
yeah I think this is "fixed" in dj2
kutenai
ah......
cybo_
I vaguely remember something going in to better share objects. however I also remember it being an internal detail. so don't rely on it perhaps
amirpro has quit
amirpro joined the channel
badfilms
cybo_: so i can confirm that the issue is that collectstatic is not working. this is supposed to be handled by heroku automatically during deployment
cybo_
badfilms, and enabling staticfiles debug doesn't show any details?
badfilms
oh right i forgot about that step :p
amirpro has quit
amirpro joined the channel
cybo_
ah, kutenai, I think what I said only applies for prefetch. in a select related, the instances aren't associated
right. its getting on for 3am. g'night
tureba
kutenai: I think that's the use case for Model.refresh_from_db()
darkhanb joined the channel
kutenai
Hmm. I'll look at that
cybo_
kutenai, why not just iterate over M2 instead?
kutenai
That's what Im doing now. I added a new mgmt script to update all of the m2's first.
I guess I was surprised I had to do that.. but, after some thought, realized why that might be the case.
cybo_
kutenai, you could also mark locally the ids you're updating
kutenai
yeah.. that would kind of break some encapsulation. Or, it would require I write a new model..
didn't want to deal with all that.
cybo_
fair enough
hubot has quit
miz- has quit
optiz0r has quit
kutenai
Thanks for all of the help/advice. Much appreciated.
amirpro has quit
amirpro joined the channel
djapo has quit
Dunedan joined the channel
jaredrhine has quit
jaredrhine joined the channel
Dunedan_ has quit
badfilms
cybo_: DEBUG=True == no issue
the /admin static pages work fine
optiz0r joined the channel
brainpro1 has quit
lolidunno has quit
lolidunno joined the channel
jessamynsmith has quit
bradfordli123 has quit
theology joined the channel
theology
anyone hiring?
Leeds joined the channel
xall joined the channel
jalalsfs joined the channel
jalalsfs_ has quit
FunkyBob
theology: what can you do?
where are you located?
xall has quit
wow... so far through this entirely API driven django app... and haven't used nap at all, yet