#django

/

      • __love__
        Kedgen: you're doing a few things wrong :) for one thing, your CBVs, which is what django-braces works on, need to be classes. So they'd be defined with `class` not `def.
      • Kedgen: secondly, if you want a list of model objects, why not use a ListView instead of a TemplateViewL
      • s/L/?
      • SuperDMP has quit
      • dannib has quit
      • Kedgen
        __love__: Ah yes, that all makes sense :) Thanks!
      • dray3 has quit
      • jayfk has quit
      • jeroengerits__ joined the channel
      • __love__
        Kedgen: if you're still learning views, in general, i'd suggest sticking with function-based views and using the @login_required decorator
      • nedbat joined the channel
      • FunkyBob
        __love__: +1e6
      • jeroengerits__ has quit
      • __love__
        ?
      • dannib joined the channel
      • FunkyBob
        __love__: am conveying my support for your statement
      • jeroengerits_ has quit
      • gp joined the channel
      • __love__
        haha
      • velcrow
        what do i get if I try request.user in a view and there is no user logged in? Is it just blank? Basically, before I execute commands in a view, I want to make sure the user is logged in.
      • FunkyBob
        __love__: it's troubling to me that people new to Django are somehow getting the impression "You should try to use CBVs for everything" ... or, at the very least , "You should use CBVs by preference"
      • __love__
        velcrow: it'll be an AnonymousUser
      • tm8522010 has quit
      • FunkyBob
        __love__: for a short time there, we even got people who were convinced that function-based views were going away, totally supplanted by CBV
      • __love__
        FunkyBob: well, you SHOULD use CBVs by preference ;) they're better in most cases (at least IMO). but, yeah, it's funny that so many are jumping straight to them
      • velcrow
        so I can just do something like user = request.user ... if user == AnonymousUser ...
      • __love__
        FunkyBob: the FBVs-are-going-away was from badly written press about the generic views
      • velcrow: why not just `if request.user.is_authenticated`?
      • FunkyBob
        __love__: yeah, I got that... and it was fixed...
      • gp
        How do I use F() object with queryset annotate? I was thinking qs.annotate(value=F("numerator")), but I get 'F' object has no attribute 'lookup'
      • __love__
        velcrow: you should read the authentication docs
      • FunkyBob
        __love__: I disagree... you should use CBV where they fit
      • __love__
        FunkyBob: which is most places ;)
      • FunkyBob
        far too often I see people doing strange contortions to their code to make them fit in a CBV
      • __love__
        FunkyBob: we'll likely have to agree to disagree.
      • velcrow
        __love__, Oh that looks good. Yes I have read them many times but since I am new, I can't remember all the functions. Soon I'll get the hang of it.
      • __love__
        velcrow: think of a problem, read the docs, write the code. lather, rinse, repeat :)
      • mrhanky has quit
      • velcrow
        lol ok, thanks
      • FunkyBob
        velcrow: what __love__ said.. then do it again :)
      • moneydouble joined the channel
      • __love__
        FunkyBob: i'm also probably partly to blame on the "let's all use CBVs" approach, since i strongly push them in GSWD
      • velcrow
        alright :)
      • __love__
        FunkyBob: and pydanny pushed them in 2scoops
      • mrhanky joined the channel
      • FunkyBob
        __love__: again, I'm not _against_ their use [unlike some people]... I just think that, like all tools, they should be used where appropriate
      • gp
        Are F() objects usable with annotate at all? Couldn't find documentation for either way
      • err either way == yes or no
      • FunkyBob
        gp: suck it and see :)
      • mattmcc
        The annotation has a field name, so yeah.
      • Kingino has quit
      • gp
        Well I get 'F' object has no attribute 'lookup', but am I doing it wrong?
      • velcrow
        __love__, The docs say that is_authenticated always returns true. I can't understand that.
      • is_authenticated()
      • Always returns True. This is a way to tell if the user has been authenticated. This does not imply any permissions, and doesn’t check if the user is active - it only indicates that the user has provided a valid username and password.
      • mindlace joined the channel
      • What's the point if it always returns true?
      • subleq
        velcrow: unathenticated users are implemented by a different class
      • mattmcc
        velcrow: AnonymousUser is a separate object.
      • jayfk joined the channel
      • mindlace
        how do I get the max/min possible value for a FloatField?
      • subleq
        subleq: its is_authenticated always returns False
      • mattmcc
        A User is a model, tied to a database record. So if you have a User, you automatically have an authenticated user.
      • stack has quit
      • velcrow
        I see
      • __love__
        velcrow: read the last section of that sentence
      • velcrow
        So if I try is_authenticated on AnonymousUser, it would be false?
      • __love__
        yes
      • FunkyBob
        correct
      • this is all covered in the auth docs
      • Stierlitz has quit
      • introspectr3
        Ticket.objects.filter(pk=objid).update(flagged=objvalue)# If objvalue is "1" and flagged field is boolean, do I have to do any casting?
      • FunkyBob
        apollo13: hey, remember my django-rated app? finally made a release yday... as it's now being used in k3 :P
      • velcrow
        Thanks
      • FunkyBob
        introspectr3: almost certainly not
      • ben174 joined the channel
      • mattmcc
        mindlace: That'd depend on your database. Though since FloatField is inexact, it may not be the field you want.
      • gp
        I am trying to use F() objects two divide two fields and then use Sum to sum the results for all matched objects. Are you saying that I should be able to do qs.annotate(value=F("numerator") / F("denominator"))? If so, what does the error about "lookup" mean?
      • velcrow will read docs more carefully before asking questions
      • CalebBrown joined the channel
      • sgambino has quit
      • mindlace
        eh, i think it's more a geodjango question since what I really am trying to do is represent a 3d coordinate space in geodjango
      • FunkyBob
        gp: sadly, I think not
      • mindlace
        er, just represent a cartesian 3d coordinate space
      • FunkyBob
        gp: but it's worth trying
      • kenbolton has quit
      • introspectr3
        FunkBob: http://pastie.org/7981756 objid exists, objvalue is correct value, im getting the httpresponse, but why isn't it updating the field?
      • Left_Turn joined the channel
      • Turn_Left has quit
      • dvl` joined the channel
      • FunkyBob
        introspectr3: oh.. mysql? all bets are off :P
      • charas has quit
      • __love__
        lol
      • introspectr3
        lol i know, switching to mongo or maria will be easy enough, its just what was on there already
      • __love__
        MySQLOL
      • gp
        FunkyBob: alright thanks. I was just confused about whether the "lookup" error meant my syntax was incorrect or that the functionality is not supported
      • __love__
        you think mongo will solve problems?
      • mrap joined the channel
      • FunkyBob
        introspectr3: probably worth using a form there... would save some effort
      • gp: lookup error?
      • __love__: that depends on what your problems are
      • __love__
        FunkyBob: immediate consistency is such a downer ;)
      • gp
        FunkyBob: 'F' object has no attribute 'lookup'... but it makes sense now that you said I can't do that
      • katylava has quit
      • FunkyBob
        gp: ah, right... no, there's no Aggregate in that expression
      • [sorry, am being distracted by my daughter]
      • gp
        FunkyBob: np, thanks
      • So if you were going to track view counts on objects that can be both partially viewed or completely viewed would you use a FloatField or a DecimalField?
      • MaTachi has quit
      • __love__
        depends on the level of granularity you need
      • mattmcc
        gp: If decimal accuracy is important, DecimalField.
      • erik_river has quit
      • nielsle has quit
      • oal has quit
      • Although if you're only dealing in, say, 1's and 0.5's, the float would probably do fine.
      • GrahamDumpleton_ joined the channel
      • gp
        Well among other things it will track partial video views by byte ranges requested so the decimals could be odd. That is why I was just going to store the numerator and denominator and make the decision later with a South migration
      • GrahamDumpleton has quit
      • GrahamDumpleton_ is now known as GrahamDumpleton
      • scottyob
        I'm going to take a massive step back, I've never been able to get this right. formats.date_format(value, "SHORT_DATE_FORMAT")… it's always in the US format for me mm/dd/yyyy. I can't figure out for the life of me how to get it to dd/mm/yyyy
      • ryannielson has quit
      • jarshwah has quit
      • DarkSector_ has quit
      • FunkyBob
        scottyob: have you played with the l10n flag?
      • marciocg has quit
      • jarshwah joined the channel
      • timothyshaw joined the channel
      • scottyob
        FunkyBob: yeah, I've turned it both on and off in my settings.py file
      • hwrd|work has quit
      • I've tried setting DATE_FORMAT, DATE_INPUT_FORMATS, DATETIME_FORMAT and I can't for the life of me get it to show the proper format
      • bloody humans, why can't we just decide on standardising? :P
      • introspectr3
        sigh: Ticket.objects.filter(pk=objid).update(flagged=objvalue) doesn't work when objvalue=="0", Ticket.objects.filter(pk=objid).update(flagged=0). What am I missing?
      • passy joined the channel
      • FunkyBob
        scottyob: everyone except the Yanks can choose a sensible date format ... :P
      • introspectr3
        Err, it does work if I specify 0
      • sjlehtin1 has quit
      • FunkyBob
        introspectr3: well, "0" is True
      • sjlehtin1 joined the channel
      • introspectr3
        you said almost certainly not!
      • ok, so I do have to cast from string to int?
      • timothyshaw
        howdy yall
      • having a bit of trouble with unit tests, I keep running into this issue and it's probably due to a fundamental misunderstanding somewhere. http://pastebin.com/xPgw9n9i. Receivable with id=1 is in the fixture i'm loading. The change is reflected by the ajax response, but when I test the attribute on line 8, it hasn't changed.
      • FunkyBob
        introspectr3: I would probably use a form with a TypedChoiceField
      • PoliticsII
        If "flagged" is boolean, you really ought to use actual boolean values in there.
      • jarshwah has quit
      • FunkyBob
        but, yes, since the value is coming from a HTML form, you will need to do some work on it
      • xcbt has quit
      • introspectr3
        hmm ok ty
      • timothyshaw
        any thoughts?
      • andym has quit