#django

/

      • __love__
        ¯\_(ツ)_/¯ seems equivalent to me but, sure, whatever
      • if it works, it works
      • Koterpillar
        pjs: that would be my preferred approach
      • cnk joined the channel
      • mandeep
        Koterpillar: if i take out abspath i get an error saying Resume has no len()
      • pjs
        __love__ My method just saves a query or two. I can't shake habits from the 90's apparently
      • Koterpillar
        mandeep: looks like you're passing wrong objects to everything
      • rns2 joined the channel
      • mandeep
        hmm
      • Koterpillar
        mandeep: what do you *want* to do at that line?
      • __love__
        pjs: it does? doesn't the article view and the category view both perform queries?
      • mandeep
        Koterpillar: pass the uploaded file into another uplod box
      • Koterpillar
        mandeep: well, 'cv' is not an uploaded file
      • pjs
        __love__ Yes, but now you're talking about adding additional queries to the router view
      • lejedi76 has quit
      • mandeep
        Koterpillar: what can i change to have cv become an uploaded file?
      • kkuj joined the channel
      • __love__
        pjs: hmm, yeah, i guess. or just pass the actual collected object into the final view
      • pjs: seems like that final view would never need to actually perform a query itself
      • Koterpillar
        mandeep: I can't see the code around that
      • pjs
        __love__ That's true.
      • mandeep
        Koterpillar: i dont think anything in the script needs to be changed since it's django independent, right?
      • __love__
        pjs: you just gotta know what kind of object you have. easy enough
      • Koterpillar
        mandeep: how would I know if it is if I can't see it?
      • __love__: what advantage would making a query first give?
      • mandeep
        Koterpillar: the script works if i use request.POST.get('cv')
      • __love__
        Koterpillar: it's more about controlling where the queries are done. do them early and don't do them again
      • pjs
        __love__ Right, that's no issue. Just don't see advantage to change the logic of 2 working views for no real performance gain, or code logic gain.. But who knows, maybe once I write this stupid router view it'll make more sense. I'll keep you posted
      • mandeep
        Koterpillar: here's the script: https://dpaste.de/ZxtJ
      • Koterpillar
        __love__: looks like in pjs' case, the queries in the views are early enough
      • newjersey joined the channel
      • newjersey has quit
      • __love__
        pjs: ¯\_(ツ)_/¯ this is what 2 minutes of contemplation gets you
      • pjs
        hah!
      • fair enough
      • newjersey joined the channel
      • newjersey has quit
      • newjersey joined the channel
      • newjersey has quit
      • Koterpillar
        mandeep: where is django_view() called? I can't deduce what 'cv' and 'resume' are here
      • newjersey joined the channel
      • __love__
        Koterpillar: sure but there's a query in each view and you have to check for the 404s. w/ my method, there's one "query" (yes, it's two queries but a single queryset in the end) and you don't have to catch 404s. all of the logic is encapsulated in the router view
      • kkuj has quit
      • mandeep
        Koterpillar: in the views.py. cv is the argument name in line 58 of the script. resume is from the views.py
      • Koterpillar
        __love__: disagree, the logic leaks from the article/category views: what if get_object_or_404 has more parameters that control how the object is found?
      • __love__
        Koterpillar: ¯\_(ツ)_/¯ i don't know that as it hasn't been shared and that should probably be addressed in a model manager, not a view
      • Koterpillar
        mandeep: ok, so instead of the uploaded file you are creating a Resume object from it
      • killvenom has quit
      • cyphase joined the channel
      • __love__: issue still stands, the article view should know how to find the article, not the router view
      • eluus joined the channel
      • cyphase joined the channel
      • eluus has quit
      • eluus joined the channel
      • __love__
        Koterpillar: not really. the view should be thin and dumb. the model should know how to find an article, the view should just handle the logic of getting the instance to the template. which it would still do.
      • mandeep
        Koterpillar: isn't filefield what i need to use?
      • Koterpillar
        mandeep: you are not using a filefield
      • __love__
        (model, model manager, querysets, etc)
      • DevilTiger_ has quit
      • Koterpillar
        __love__: the article view will at least call the right manager method
      • __love__: that part of logic should stay there
      • __love__
        sure. but _any_ view can call that
      • mandeep
        Koterpillar: i have a filefield in my models.py
      • __love__
        if the router depends on a valid record being found, that logic belongs in the router
      • s/router/router view/
      • mandeep
        and it's being called in the views.py
      • Koterpillar
        __love__: in fact, the router view can be made generic, it should just call several views until one succeeds
      • __love__: why should _router_ know about the right Article methods to call?
      • __love__
        yeah, that won't get out of hand any time soon
      • Koterpillar
        well, we're just fixing a limitation of the stock router
      • mandeep: what does this line do? resume = Resume(request.FILES['resume_upload'].read())
      • dlam` has quit
      • mandeep
        Koterpillar: reads the uploaded file
      • Koterpillar
        mandeep: and then?
      • mandeep: here's the part that "reads the uploaded file": request.FILES['resume_upload'].read()
      • mandeep
        Koterpillar: and then passes it to the model?
      • johnmilton joined the channel
      • Koterpillar
        mandeep: OK, so why do you pass the model to django_view() and ultimately to abspath() then?
      • __love__
        Koterpillar: really, i think it's a wash. both approaches are fine and it just depends on how you want the logic fractured.
      • for now, though, it's time to go have a beer and play a game
      • Koterpillar
        __love__: ++
      • Nemus has left the channel
      • mandeep
        Koterpillar: im not sure how to pass the file from the model to django_view() and abspath is a carryover from a prior implementation of request.POST.get('resume')
      • Genitrust joined the channel
      • Koterpillar
        mandeep: why do you pass the file to the model?
      • mandeep
        Koterpillar: i was having memory issues
      • Koterpillar
        in what sense?
      • kingarmadillo joined the channel
      • mandeep
        Koterpillar: i cant remember the error, but it was something about file not able to be saved in to memory
      • delgiudices joined the channel
      • zos_ joined the channel
      • Koterpillar: InMemoryUploadedfile does not support indexing
      • Koterpillar
        so you decided putting it into Resume() will solve it. However, django_view() expects a file name, not a Resume object, so you have to figure out how to get your file back
      • mandeep
        Koterpillar: any suggestions in what to learn to accomplish this?
      • Mask777`Work joined the channel
      • Lisa1157 has quit
      • Koterpillar
        mandeep: ah, looked at the Resume model. Here's what you need to read: https://docs.djangoproject.com/en/1.9/ref/model...
      • mandeep
        Koterpillar: many thanks
      • jamesshijie joined the channel
      • Mask7777 joined the channel
      • johnmilton has quit
      • Mask777 has quit
      • Koterpillar
        mandeep: I would also suggest learning more about types in general - can't recommend anything, but any Python book would go into this
      • mandeep
        Koterpillar: im familiar with types just dont know much about django
      • Mask777`Work has quit
      • jwhitmore_ has quit
      • jamesshijie has quit
      • DjangoMan has quit
      • darkpixel1 has quit
      • dlam joined the channel
      • NomadJim has quit
      • bayman has quit
      • bayman joined the channel
      • NomadJim joined the channel
      • overallr_ joined the channel
      • johnmilton joined the channel
      • lorddaedra has quit
      • staticshock has quit
      • overallrhino has quit
      • Genitrust has quit
      • lorddaedra joined the channel
      • bayman
        when you extend User model by following the docs, should the new model be in its own app? https://docs.djangoproject.com/es/1.9/topics/au...
      • mattmcc
        Yes.
      • Quitta joined the channel
      • Koterpillar
        mattmcc: as opposed to being together with other models in your app?
      • mattmcc
        As opposed to being in the same app as User..
      • bayman
        I'm wondering if it should be in the same app as one of my project app
      • or should I startapp UserProfile
      • holler has quit
      • mattmcc
        Well, if you already have an app with other user-related stuff in it..
      • delgiudices has quit
      • surfnturf_ has quit
      • keimlink has quit
      • Quitta has quit
      • killvenom joined the channel
      • bsl10 joined the channel
      • chippie joined the channel
      • limbera joined the channel
      • bsl10 has quit
      • anth0ny joined the channel
      • bsl10 joined the channel
      • chippie has quit
      • bsl10 has quit
      • wuno has quit
      • Wrhector_ has quit
      • bsl10 joined the channel
      • tezro has quit
      • tezro joined the channel
      • rpkilby joined the channel