adamsilver, hm, that file is full of numbers. I have an idea ...
adamsilver
yeah, not sure why
FunkyBob
srnagappan: yes, yes it's different... since $.ajax is jquery... fetch is a native API
dang`r`us
adamsilver, yeah, it looks like something is converting the bytes of your file to a decimal representation. at least it starts with the decimal number 31, which seems to indicate a gzip file when converted to binary
adamsilver, shot in the dark but try passing json_file instead of json_file.getvalue() to StreamingHttpResponse
bayman has quit
adamsilver
dang`r`us: same problem but now the file inside is empty
dang`r`us
adamsilver, probably need to seek it back to zero before streaming it out
stridebird has quit
I gotta say though, if you write the whole gzip beforehand anyway, a streaming response seems somewhat weird to me
is there a way to set attrs to all fields in a form in one fell swoop? Not one by one?
dang`r`us
adamsilver, hm ... my io knowledge is a bit rusty. what do you mean with outer file though?
wait ... file inside is empty means you got a working gzip?
let's take it from there.
adamsilver, can you go back one step and send me an empty but valid gzip file (if that's what your code did actually create?)
FunkyBob
rainierman: nope.. just iterate over self.fields.items() in form.__init__
adamsilver
dang`r`us: sorry, I meant the .cpgz inside is 0 bytes in size
rainierman
that works! Thank you FunkyBob
dang`r`us
adamsilver, what is a cpgz? and inside _what_?
jessamynsmith has quit
adamsilver
dang`r`us: I get it when I extract the downloaded file and keep getting a new one when I try to extract it
dang`r`us: I think the problem is here gzip_handler.write(json_string) ... if I leave it like the original code in SO, I get: memoryview: a bytes-like object is required, not 'str'
adamsilver, anyway, when you implement my first change, you get a working gzip file but its content is bananas/empty, yes? can you upload such a file somewhere please?
FunkyBob
what if you use a FileResponse instead?
adamsilver
dang`r`us: the file gets downloaded with my code and after your changes as well but when extracted I get "activities.json.gz.cpgz" and when I click activities.json.gz.cpgz I get another activities.json.gz.cpgz and so one
dang`r`us
adamsilver, I still want that file.also - like FunkyBob said and I hinted at earlier, a streaming response is not very useful here, try a FileResponse
or remove the .getvalue() at least
I think ...
also, where did that .cpgz come from? Not from your code snippet I take it
hamub joined the channel
FunkyBob
so you explicitly want to send a compressed file... not rely on transport encoding?
adamsilver
+FunkyBob: response = FileResponse(json_file) gives an empty response
dang`r`us
good point FunkyBob
adamsilver, the plus is not part of FunkyBob's nickname
it indicates a certain permission status with respect to the channel
brandonw joined the channel
adamsilver
Oh ok :)
FunkyBob: all I want is to send the gzipped file to the client without killing the server
I thought StreamingHttpResponse would help with that
FunkyBob
it would if oyu had a streaming encoder
miz- joined the channel
dang`r`us
adamsilver, if you create a huge blob before streaming it out (.getvalue()) it's not going to do much good
also what FunkyBob said
how huge are we talking here? is this an actual performance bottleneck or a guess?
FunkyBob
IME BytesIO etc tend to be either readable or writable... so... HttpResponse(json_file.getvalue()....) is the way to go
i just renamed an app (didnt have anything in my database yet so not worried about that) and renamed everything in settings and what not, but i am getting a ModuleNotFoundError on the apps file in the app i renamed
FunkyBob
wreed: did you update the name in the AppConfig ?
dang`r`us
wreed, any pyc files or similar around?
wreed
error: ModuleNotFoundError: No module named 'profile.apps'; 'profile' is not a package
i updated AppConfig
what are pyc files?
__pycache__?
FunkyBob
yes
what did you rename from and to?
Biwaa joined the channel
wreed
renamed from userprofile to just profile
there is a __pycache__ folder in my app
should i delete that file?
dang`r`us
wreed, hmm, seems the problem is you didn't rename it properly
wreed
yeah i am trying to fix it
CAPITANOOO has quit
i definately renamed my installed apps and the stuff in the apps file
dang`r`us
yeah maybe nuke __pycache__ then
busla joined the channel
there's a command for that I think
jtiai^ joined the channel
hm, not really.
wreed
nuked it
dang`r`us
wreed, go to your project root and type: find . -regex "\(.*__pycache__.*\|*.py[co]\)" -delete
ok so when doing that the console starts up fine but when importing it, it says: 'RuntimeError: Model class profile.models.Profile doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.'