you just gotta compare prices/features really and get what works for your project
vdboor joined the channel
or roll your own if you want to deal with the headache
pokmo
but cloudinary seems a bit an overkill. it allows for effects, face detection, etc.
l0rd_Qu4s has quit
Knyght
I imagine you can disable the stuff you don't need
szicari has quit
pokmo
but they start at $90/m
szicari joined the channel
that probably includes the r&d costs
zeus1 joined the channel
for face detection!
i probably just roll my own with boto
mun joined the channel
mun
is it a good idea to use django for the backend server of a mobile app?
but django provides so much front end stuff, like templates, etc. is it designed to be used as a backend server?
jgadelange joined the channel
jrabbit
You can use whatever frontends you want
mun: the only downside maybe is django needs a third party lib to do json-y api-y stuff better
pete___
pokmo: You could have a look at libpixel.com, they do resizing and some basic filtering
pokmo
pete___ thanks for the pointer
sunil_bansal joined the channel
pete___ looks like libpixel taps into your image store
so image storage needs to be done separately
pete___
pokmo: yeap, we use django-storages / boto to get the stuff into s3, then make calls via a template tag to get django to call the url of the image we need
synProgrammer joined the channel
jalalsfs joined the channel
pokmo
pete___ they're definitely more economical though :)
sunil_bansal has quit
jpg joined the channel
pete___
pokmo: yea, the service is pretty good as well, we don't use them for much more than responsive images of products but they do a pretty decent job of that
since we use heroku we use s3 from media content anyways so it was a bit of a no-brainer
adsworth has quit
lolidunno joined the channel
ovalseven8 joined the channel
ovalseven8
Hey, I have a critical section in my code that could be lead to a problem if two people do something "in parallel". While that probably won't be the case for my web application (it's low traffic), I want to do it the right way nonetheless.
However, first of all I'd like to test this before and get the error, then fix, and run the test again
Is there something to say to Django "please run THIS code in parallel"
asimon is now known as EJ_FC
jtiai
ovalseven8: No. But it all depends what are you trying to do.
pete___
pokmo: I think I found that after using libpixel for a while
pokmo
but you'll have to host it yourself
EJ_FC is now known as asimon
gypsymauro
I can't find the way to render the app root in template, I've declared this: path('', TemplateView.as_view(template_name="gda/dashboard.html")),
pete___
pokmo: honestly for the time involved I didn't think it was worth the switch
ovalseven8
jtiai, I have an event where people can register for. But when someone register AT THE SAME TIME, it could lead that they register 4 tickets in total although only 2 available (both register 2)
gypsymauro
but I can't use {% url '' %}
jtiai
ovalseven8: select for update would be useful for you.
ovalseven8
jtiai, Mh but I cannot reproduce this potential failure?
jtiai
ovalseven8: Testing parallelism is quite difficult.
pokmo
pete___ but libpixel isn't cheap either. probably my use case is a bit different
ovalseven8: Nope. It just ties transaction to sequence.
pokmo
my app is like a time lapse camera, capturing images over intervals
nazarewk has quit
jtiai
...sequence? where I got that. I meant request. :)
pokmo
so most image requests are going to be unique :(
jtiai
ovalseven8: select_for_update locks select row from editing.
(called also as pessimistic locking)
ovalseven8
jtiai, Does the transaction not do locking by default?
pete___
pokmo: maybe, like I said, we just use it for product images that don't change all that often. I guess you gotta consider the costs of running a server (including maintenance etc) vs the scaling up costs of something like libpixel
jtiai
ovalseven8: Nope. It doesn't have anything to do with locking.
ovalseven8
jtiai, But in normal DBMS when I start a transaction and write to a tupel, it sets a lock normally. So that's different to Django here?
jtiai
ovalseven8: No it doesn't do that.
pete___
pokmo: one alternative that we looked into was imgix (https://www.imgix.com/pricing) which is a similar system. The only issue was that they wanted $50 a month for SSL certificates and since we can use a few domains this was a deal breaker for us
ovalseven8
jtiai, You mean DBMS or Django? :D
jtiai
dbms
Django doesn't change how transactions in databases do work.
pokmo
pete___ oh i've looked them up too. $3/1000 image requests should be pretty good for you otherwise
greg_f joined the channel
pete___
pokmo: actually, I just dug out the email from them. $100 Annual + $50 a month for a regular cert, $600 annual + $50 a month for a wildcard!
jtiai
ovalseven8: transactions doesn't protect from race conditions. To handle it you need to do it yourself.
converge
Is there a way to retrieve one row per day using Django ? I tried DISTINCT but Im using SQLite
jtiai
And for that django provides you way to lock rows from editing.
converge: one row per day?
pete___
they don't mention any of this up front and have the cheek to say it's costs passed on from their CDN (which is just cloudfront!)
jpg has quit
ovalseven8
jtiai, Does not it depend on the isolation level? E.g. serializable
pokmo
pete___ gosh
converge
jtiai, yes, I have (id, followers, last_update) -> (1, 100, '2018-05-30') (2, 200, '2018-05-30') (3, 300, '2018-05-31') (4, 350, '2018-05-31') , I want to retrieve the first or last record of the day
tneva82 has quit
jtiai
ovalseven8: A bit. but read committed is usual isolation level.
pokmo
pete___ maybe that's how users make up for the cheap request rates
ovalseven8: Well sqlite locks the whole database. But sqlite is not a "real" rdbms engine. Real ones like postgres do much more sophisticated locking.
Diplomat joined the channel
phiofx joined the channel
phiofx has quit
um87 joined the channel
phiofx joined the channel
um87
Having trouble binding data to a filefield when validation fails. The input type file widget just shows “no file selected”. I make sure to pass in request.FILES into the form’s data in the view
converge
jtiai, could I do that using custom manager ?
greg_f joined the channel
jtiai
converge: There isn't actally single query that would fetch the data.
rpkilby joined the channel
converge
jtiai, right, could I add some logic to a custom manager method to do it ?
I mean, is it a good idea ?
jtiai
That's one possibilty. Not sure is that a good idea.
joshbright joined the channel
ovalseven8
jtiai, So when I understand correctly, I have to use select_for_update() WITHIN an atomic function? So @transaction.atomic
audioburn joined the channel
jtiai
ovalseven8: No you don't.
ovalseven8: select_for_update() tells database to lock selected rows exclusively. That way two (even separate) processes can't modify same rows. Now if two concurrent access happens - latter one needs to wait for lock to be released.
zub1n joined the channel
..or you can define that exception is raised when rows are locked to avoid waiting for long periods.
knbk
select_for_update() doesn't work outside of a transaction
ovalseven8
jtiai, Yeah, but in the docs it says "Returns a queryset that will lock rows until the end of the transaction"
knbk
table/row locks are always held until the end of the transaction, they don't work in autocommit mode
jtiai
don't they?
ovalseven8
knbk, But Django does autocommit by default
jtiai
Well I never run my code in autocommit mode.
ovalseven8
That's why I asked if I have to use @transaction.atomic
jtiai
For that view which may modify that data you want to have an exlusive lock.
ovalseven8
Mh, in Django a transcation only begins when I do queries like "Model.objects.get(pk=1)". But when I have select_for_update() there is no transaction yet
knbk
unless you disable autocommit (django enables it by default), you need to use transaction.atomic to start a transaction
ovalseven8
knbk, Yeah, that what I wrote. :)
knbk, Do you know if there's a way to simulate parallel changes? I have a view that could lead to probelsm when executed in parallel. I want to fix it with select_for_update() but test it before and after.
rasb has quit
To see if my code change really does what I except it to do :D
jezeniel joined the channel
knbk
testing locks/race conditions is hard, there's no clean way to test it since you can't control the order of operations
ovalseven8
knbk, So when I understand correctly THE FIRST example is completely without effect?