#django

/

      • ThomasC joined the channel
      • vishaldeep joined the channel
      • shruubi has quit
      • xterm
        what's the word on the streets for 1.7 final :-)
      • FunkyBob
        RSN
      • RRRSN
      • m8 joined the channel
      • xterm
        YEY!
      • schinckel
        If only freakboy3742 and those other lazy core devs wouldn't galavant off to conferences instead of slaving over releases.
      • kezabelle
        scandalous of them
      • xterm
        seriously, we pay them so much!
      • shruubi joined the channel
      • Unifox joined the channel
      • gkap joined the channel
      • trustyhank
        anyone know if they're recording the talks at djangocon this year?
      • vishaldeep has quit
      • FunkyBob
        don't they most years?
      • they did at Django/Py-ConAU
      • trustyhank
        oh, right on
      • vishaldeep joined the channel
      • xterm
        pyvideo.org good way to find stuff related to python!
      • trustyhank
        xterm: thanks!
      • owais joined the channel
      • prohobo joined the channel
      • prohobo
        hey, is there a way to filter a queryset on model?
      • kezabelle
        pardon?
      • prohobo
        because i have a model which inherits from another model, but it's shown in the same change_list
      • i want to filter out the inheriting model
      • FunkyBob
        ...
      • MTI? or abstract inheritance?
      • kezabelle
        Find the PKs of the child model, and exclude those from the QuerySet of the parent model, assuming concrete inheritance
      • prohobo
        the class def for the inheriting model is: "class ModelName(BaseModel):"
      • so i think it's concrete inheritance
      • FunkyBob
        only if BaseModel doesn't have Meta.abstract = True
      • prohobo
        doesn't
      • bhitov has quit
      • owais
        I'm facing a weird issue in django 1.7. I'm using a custom module to host migrations for the `auth` app. I'm adding 0002 custom migration to add some fields to the auth.Groups table. Here is my 0002 migration for auth app https://gist.github.com/owais/cabc53a79e7b092457cc
      • When I run `migrate auth 0001`, it also creates the fields that are specified in 0002.
      • tomchristie joined the channel
      • esauro joined the channel
      • FunkyBob
        prohobo: so it's multi-table inheritance
      • ASUchander1 joined the channel
      • and thus almost certainly not what you think
      • owais
        it does not make 0002 as migrated which if correct but it creates those fields when running 0001. So while running 0002, django always complains that the fields already exist
      • this is django 1.7. Looks like a bug to me.. or am I missing something?
      • FunkyBob
        owais: are you using the latest 1.7 from git? or rc3 ?
      • owais
        FunkyBob, latest from 1.7 stable branch
      • encod3 joined the channel
      • ASUChander has quit
      • Sir_Narwhal has quit
      • timfernando joined the channel
      • bikeshedder joined the channel
      • ASUChander joined the channel
      • jjmarin_ is now known as jjmarin
      • argoneus
        Is it a good idea to make views as classes? e.g. TemplateView etc
      • or is it preferable to use render(...)
      • ASUchander1 has quit
      • FunkyBob
        argoneus: when it helps
      • timfernando has quit
      • argoneus
        FunkyBob: but if it's a simple case
      • owais has quit
      • xnaveira joined the channel
      • is there any difference between def bla(TemplateView): template_name = "bla.html", versus def bla(request): render(request, "bla.html")
      • Sir_Narwhal joined the channel
      • FunkyBob
        sure
      • render is probably faster,
      • and is a view itself, instead of requiring you to call the "as_view()" view factory
      • argoneus
        hmm
      • so the classes should be used if it's more robust?
      • kezabelle
        time to bench render() vs TemplateResponse :o)
      • FunkyBob
        argoneus: I never said that
      • jtiai
        Stupid question - When I do have FileField in my model how I can get original name of file uploaded, not the mangled one that get's saved?
      • amit_usual has quit
      • argoneus
        FunkyBob: but I can't think of an example "when it helps"
      • FunkyBob
        jtiai: you can't unless you choose to save that name elsewhere
      • argoneus: then don't use them
      • argoneus
        my view just gets information from models if needed, fills the context with values and returns a template
      • why would someone need a class?
      • Zeograd joined the channel
      • I mean, I'm sure there's a use for it since everyone seems to use classes
      • swi joined the channel
      • I just can't put my finger on it right now
      • FunkyBob
        the CBV replaced the old function based GENERIC views
      • they provided a more flexible, cleaner framework to let people hook into the interfaces and customise how these GENERIC views behaved
      • by using class method overides through inheritance, instead of bodgy callback hacks
      • argoneus
        oh
      • a7p has quit
      • trustyhank has quit
      • amit_usual joined the channel
      • FunkyBob
        there's a grat talk by freakboy3742 at PyConAU about this
      • argoneus
        FunkyBob: so as_view is more "modern" than render()?
      • FunkyBob
        no
      • as_view() is a part of the Class-Based View design
      • you must call it on your CBV in order to get the view function that will be invoked
      • or were you talking about creating your own class-based view design?
      • xterm
        If you use CBVs, it's nice to read the source of as_view()!
      • FunkyBob
      • kezabelle
        it's not :o)
      • a7p joined the channel
      • argoneus
        well
      • I'm a wee bit confused right now
      • bahamas joined the channel
      • FunkyBob
        argoneus: about?
      • argoneus
        so there's 3 ways? render(), return HttpRequest, and generic templates (TemplateView...)?
      • FunkyBob
        render() is just a shortcut
      • kezabelle
        here's a question, why do *render* and CBVs have different return types? (TemplateResponse vs render_to_string())
      • FunkyBob
        it does get_template(), creates a RequestContext, and then return HttpResponse(template.render(context)) ... more or less
      • argoneus
        oh, I see
      • FunkyBob
        kezabelle: yeah, I was thinking of submitting a patch to make render use TemplateResponse :)
      • argoneus
        so I can use either the function based approach, or the generic templates, or CBV?
      • FunkyBob
        argoneus: generic templates?
      • Lauxley joined the channel
      • kezabelle
        FunkyBob: please do.
      • FunkyBob
        CBV are the Class-Based Generic Views
      • (well, mostly)
      • argoneus
        wait
      • kezabelle
        makes little sense, and the API is different from a testing perspective, which is quirky
      • argoneus
        what did you say
      • "old function based GENERIC views"
      • what does that mean?
      • kezabelle
        so, there were "generic" views -- "list", "add", "edit", etc
      • FunkyBob
        before Django 1.4, all the generic views were function views... not class based
      • kezabelle
        they were function based views.
      • argoneus
        ohhhh
      • FunkyBob
        they were replaced with the Class Based Generic Views
      • argoneus
        so whenever I use a class with a generic view
      • it's already CBV?
      • kezabelle
        as of … 1.3? 1.4? CBVs came in, and alongside them came Generic CBVs to replace the old FBVs.
      • argoneus
        class based view, right
      • FunkyBob
        "from django.views.generic" <--- all CBV now
      • so when you talk about TemplateView... that's a CBGV
      • argoneus
        I see
      • Ariel_Calzada joined the channel
      • is it preferable to use CBV or render()? I want a page that uses a template and shows data based on GET requests
      • I guess using a CBV will be easier?
      • FunkyBob
        will it?
      • not from what you've described
      • argoneus
        I just specify template_name and def get(...)?
      • no?
      • FunkyBob
        you mean template_name and get_context_data()
      • telex has quit
      • shruubi has quit
      • argoneus
        I'm even more confused now
      • isn't this what get() and post() are for?
      • at least that's what the doc seems to imply
      • telex joined the channel
      • xterm
        I think you're better off just using a function based view and forget the rest of the stuff exist. (Atleast for now)
      • FunkyBob
      • get() and post() are for handling how to react to those HTTP actions