I think I just found a report generation trigger.... that uses GET
bigblind has quit
listenmore joined the channel
Ikoru1 has quit
zeus1 has quit
chasonchaffin joined the channel
thiras has quit
veduardo has quit
Diemuzi has quit
chasonchaffin has quit
chasonchaffin joined the channel
bradfordli123 joined the channel
lavalamp joined the channel
chasonchaffin has quit
bradfordli123 has quit
bigblind joined the channel
bigblind has quit
milardovich joined the channel
sol1x has quit
bigblind joined the channel
chasonchaffin joined the channel
bigblind has quit
de_spajic joined the channel
bigblind joined the channel
awagink joined the channel
chasonchaffin has quit
fikka joined the channel
chasonchaffin joined the channel
aossama has quit
bigblind has quit
jadajada has quit
lolidunno has quit
chasonchaffin
morning
aossama joined the channel
bigblind joined the channel
joshbright
morning!
Leeds has quit
doc|work joined the channel
octofox has quit
doc|work
I'm creating an admin interface and I'd like to have it so in the admin interface the value for a ManyToManyField is "related_field.__str__() - self.name" without actually changing the __str__() in the model. The rest of the m2m functionality is fine. Anyone know what to look for in the documentation? I couldn't see anything on the admin page's documentation that seemed to fit
bigblind has quit
mo` has quit
lobo_d_b has quit
awagink
morning!
doc|work
morning
bigblind joined the channel
hackedhead joined the channel
hackedhead
what's the best practice for a situation where I have a number of views that check if a valid instance of a model exists, and does thing A if it does and thing B if not?
Exception? return None and detect it as a sentinel? How do I avoid replicating that "try/except" in every single view?
milardovich has quit
joshbright
doc|work: are you wanting to specify a different method other than __str__ to represent the related fields value?
hackedhead
(in this case, the view is dated: url /yyyy/mm/dd/ and either there's an instance of model A appropriate for that date, or there isn't)
doc|work
joshbright, essentially, yes.
joshbright, at the moment I'm trying to override __str__ in the admin but I'm really not sure that's the best way to go
joshbright
hackedhead: so, I use a django shortcut called get_object_or_404, which, either gets an object by its primary key, or, raises a 404 error
bigblind has quit
aossama has quit
EFaden joined the channel
hackedhead
joshbright: similar idea, but I don't want to raise a 404
joshbright
doc|work: it seems like you could do something with ModelAdmin to accomplish this, but, i havent had to do anything like that from what I can remember
doc|work
yeah
joshbright
hackedhead: in that instanced, I usually use a try / except thing where I check for django.model.DoesNotExist, something like that (id have to check again)
mattmcc
doc|work: The only admin-specific use of __str__ is on listing pages, and you can bypass that by specifying other fields (or methods) in list_display.
joshbright
but, if you were to try to get an object from a django model, and, it doesn’t exist, it raises some sort of exception, so, you can check for that exception and just return false or wahtever
EFaden
I have a quick question. I have a website with an editable table on it. The table is 6 x 6. I don't really need a database or anything like that, but I was trying to use django channels. My goal is to have real time updating editable table that is 6x6.... I was thinking about having a simple HTML/JS page open a websocket and fire off a "getall" request to get the current state.... then on each edit send a "edit x y value" json objec
subscribers.
Suggestions on how to do this?,... I was just going to store the table values in an array in python
mattmcc
EFaden: It's gotta be stored somewhere to be persistent after the Python process stops.
fikka has quit
EFaden
I don't need persistence.
hackedhead
joshbright: yeah, that's what I'm doing now, I just find myself writing the same try/except in several views, which seems like an antipattern
EFaden
If it gets wiped out on reboot thats fine.
kupi has quit
mattmcc
It wouldn't take a reboot. Worker processes are often recycled just as a matter of course.
joshbright
hackedhead: so, you could write a util type of function that acts like get_object_or_404, but, acts more like, get_object_or_none
mattmcc
And of course if you had more than one process, then your state would vary based on which one handled the request.
hackedhead
EFaden: HTTP is stateless though, so the next time the client calls for an update, the original process from the earlier request is gone. you need persistence
doc|work
so what do people do if a model's __str__ value isn't specific enough but they don't want to modify the model's __str__ to add the related data's __str__() which is otherwise always a bit redundant for the usual use
joshbright
you pass it in the model and the pk, if it can’t find it, it returns none
doc|work
?
EFaden
Ah.... so what would be the easiest way to set tihs up then?
Setup a model for the table ?
hackedhead
joshbright: yeah, but then I'm just trading try/except for "if result is None:"... aren't i? is that better in any way?
joshbright
hackedhead: well, with the get_object_or_404 function works well because, after getting that object, if your next line is ran, you have the object, you dont need to check for anything. if there wasn’t something there, a 404 was raised earlier and it doesn’t matter
so, you could look at how get_object_or_404 works, and raise something similar that bails you out of your function
mattmcc
doc|work: You can include related fields in list_display. As for things like form dropdowns, that label can also be customized so that it doesn't necessarily use __str__
sunil_bansal joined the channel
joshbright
i’d have to sorta see what your doing
doc|work
mattmcc, yep, have done that. it's not so much for list_display but fields = (,)
how can it be modified? What should I look for in the docs? I still want to keep the manytomany functionality otherwise
EFaden
Or I suppose what would be a simple setup for a model to hold a 6x6 table?....
EFaden: A JSONField could hold a serialized array.
EFaden
JSONField?
mattmcc
Postgres also supports arrays natively with ArrayField.
fikka joined the channel
sunil_bansal has quit
maks25 joined the channel
bigblind joined the channel
aossama joined the channel
bigblind has quit
EFaden has quit
newdimension joined the channel
CAPITANOOO joined the channel
bigblind joined the channel
Guddu joined the channel
FD91224 joined the channel
Guddu has quit
Guddu joined the channel
bigblind has quit
samsagaz joined the channel
theology
my admin site is not loading, it just loads my homepage. why?
urlpatterns = [
url(r'^', home, name="home"),
url(r'^admin/', admin.site.urls),
]
am i missing something?
the $
milardovich joined the channel
yep it was the $
thanks me
mattmcc
Yeah, '^' catches everything.
bigblind joined the channel
maks25
Hi guys, I’m trying to figure out how rest_framework.permissions.DjangoModelPermissions works in order to customize it to my requirements. Has anyone worked with it before?
FunkyBob
theology: quack :)
theology
lol
bigblind has quit
bigblind joined the channel
dtrudg joined the channel
sunil_bansal joined the channel
bigblind has quit
bigblind joined the channel
Back2Basics joined the channel
sunil_bansal has quit
bigblind has quit
lobo_d_b joined the channel
NomadJim has quit
NomadJim joined the channel
miz- has quit
notnull has quit
CAPITANOOO has quit
hackedhead
FunkyBob: the numbers of times I have said to my boss "Thanks for being a duck" hahaha