If the models are not related, I question why they are in one api endpoint
django_noob
outside the context of django, does a endpoint need to accommodate both post and get to be considered "restful"
They are related
I am using all of them to compute a value
and this endpoint returns that value
frans has quit
jtiai
django_noob: That is very normal and there is no magic involved.
You can even use standard Django function based view to do that.
jessamynsmith
sorry if I am repeating what others already said, but that sounds like an apiview since you don't need crud on it, you just need a single view
tyrion-mx
django_noob, don't worry about "restful" :)
django_noob
can a non apiview that does have all crud operations still be considered restful?
jtiai
django_noob: restulf is an architecture style.
tyrion-mx
django_noob, "rest" and restful are abused words that mean very little. If you want to understand what REST is, you could read roy fielding's dissertation
but that would take up some time
jtiai
REST in practice from O'Reilly is also pretty good book.
This is only a 1/2 django question... give an entity that would have a status (occupied/available) tied to a time frame (either start datetime + duration or startime/endtime), how would you query whether a device is available given a certain point in time?
I don't know if I'm tripping myself up by thinking about time as a continuum rather than thinking pragmatically - but I'm curious what kind of answers I'll get!
oxygene joined the channel
django_noob
Thank you to everyone that helped me design my api endpoint
newdimension
I have one template file that I want to use for different models. Anything wrong with defining get_delete_url() and get_edit_url() at the model level similar to get_absolute_url()?
firefox1337
call a query at a certain time and get the result?
django_noob
really really appreciate
gonna run with apiview
Alphare has quit
foxmask has quit
django_noob has quit
astarrh has quit
astarrh joined the channel
stahl has quit
jessamynsmith
masterrex: I would use start and end and then query based on current time
JordiGH has left the channel
knbk
masterrex: on postgres you can use DateTimeRangeField, which comes with some convenient lookups as well
jaddison has quit
ironi
anyone here familiar with the FieldTracker from django-model-utils?
totallyserious joined the channel
totallyserious
let say I have a table, Offers, but I want to make one of them special and have references to it programmatically
what is the best way to go about doing this?
ironi
I want to calculate and update some fields when a model is updated, so I'm adding a pre save signal - I need the exsiting db datas to be able to do the calculations, is there any better way to do this than just do a get?
idontneedanick has quit
jakogut_ has quit
masterrex has quit
jakogut joined the channel
masterrex joined the channel
ptx0 joined the channel
firefox1337 is now known as firefox
jaddison joined the channel
VikingHoarder has quit
masterrex has quit
jaddison
totallyserious you mean mark a given Offer instance as 'special'? A boolean field or some choices-based field. What do you mean by refer to it programatically? a ForeignKey field?
amirpro has quit
whatever_hi joined the channel
ironi doing a get in pre_save works, but you can also override the model's `__init__(...)` to copy the relevant data to a tmp instance variable for comparison in a pre_save signal (or overridden .save(...))
ironi
is instance._state.adding safe to use in a signal to check if a model instance is being updated
jaddison
At least, I think that would work
ironi
I have a model with a uuid pk so cant do if self.pk\
jtiai
ironi: Why not?
ironi
jaddison: interesting
jtiai: being a private property and I can't find it in the docs
jtiai
ironi: pk property should be documented somewhere...
amirpro joined the channel
beebot_ joined the channel
ironi
jtiai: oh you mean why not, because the uuid field has uuid.uuid4 as default and those are set before saving