#django

/

      • sserrano44 has quit
      • renstrm has quit
      • oxum_ is now known as oxum
      • willingc has quit
      • k_sze[work] joined the channel
      • mstrcnvs has quit
      • loic84 has quit
      • loic84 joined the channel
      • ambar has quit
      • ska-fan_ joined the channel
      • unbit joined the channel
      • cardboard joined the channel
      • Zonedabone has quit
      • kushal joined the channel
      • hazzadous has quit
      • arietis has quit
      • renstrm joined the channel
      • georgeirwin joined the channel
      • hazzadous joined the channel
      • arietis joined the channel
      • rudedogg joined the channel
      • georgeirwin has quit
      • dustinfarris has quit
      • LordVan joined the channel
      • jrm2k6 joined the channel
      • djapo
        im overriding the User model in a test, would i have to patch calls to get_user_model from outside of the testcase? say that i'm importing a attribute from my app's utils.py who just return the name of the field set on the User model by USERNAME_FIELD, now since i have overriden the User model to one that uses the field name 'email' i try an assertEqual on 'email' and the value imported, the assertion fails and says that it is
      • zipp0 joined the channel
      • zipp0 has left the channel
      • dlogs has quit
      • dlogs joined the channel
      • also im supposed to be selectively adding a field to a form if this attribute is not 'email' but when i assert that the field is not in form.fields it fails, does the override setting not effect calls to get_user_model outside of the test method?
      • bkeating joined the channel
      • fllr joined the channel
      • JerryT joined the channel
      • fllr has quit
      • fllr joined the channel
      • wgITos joined the channel
      • helderco has quit
      • fllr has quit
      • waveclaw has quit
      • Mechanimal has quit
      • chr1stopher joined the channel
      • slav0nic joined the channel
      • Tyriss joined the channel
      • jtiai
        djapo: Provided that you have correct test config everything should just work.
      • webus joined the channel
      • bkeating has quit
      • rudedogg has quit
      • Manyman joined the channel
      • Manyman has quit
      • Tyris has quit
      • jezdez
        FunkyBob: not that I can remember, nope. why do you ask?
      • djapo
        jtiai: it's not right now im venturing into the world of mock.patch which makes me fear that i might be hidding a problem by doing so
      • frog3r joined the channel
      • jtiai
        djapo: Then you might be doing something wrong...
      • sivy joined the channel
      • FunkyBob
        jezdez: a project I've recently taken over... a cow-orker added it, and now tests are barfing in, it seems, creating test DB
      • frog3r has quit
      • sivy has quit
      • djapo
        jtiai: im just doing self.assertNotIn('username_field', test_form.fields) in the method that is supposed to have the user overriden, the test_form is a form that selectively sets a field named username_field if the USERNAME_FIELD is not email ... and the user model that overrides just happens to have that set to 'email' which means that the field should not be there, but it fails
      • wgITos has quit
      • dustinfarris joined the channel
      • jtiai
        djapo: How do you construct that form?
      • Gixxa joined the channel
      • masterhumper is now known as sejo
      • epicowl joined the channel
      • djapo
        jtiai: just a regular form with one field in the block of an if statement, if _username_field is not 'email':,
      • Gixxa
        Good morning. I'm having a little problem adapting the polls tutorial to my needs :( Could maybe someone take a look at this: https://gist.github.com/Gixxa/9885946 and tell me how I can write a view so that I can vote? It should be placed into the "lernbaustein" view if possible, or will that not work?
      • epopt37 joined the channel
      • jtiai
        djapo: Have you checked at which point that if-clause is executed?
      • FunkyBob
        Gixxa: you're really passing the titles in the URL pattern?
      • keepguessing joined the channel
      • djapo
        jtiai: _username_field should be getattr of get_user_model USERNAME_FIELD, which since i have overriden in the test i would expect to be 'email' but the fact that my assertion fails tells me that the if statement must be evaluating true, and the if statement should be evaluated after the form is instantiated
      • Gixxa
        FunkyBob: yes
      • dustinfarris has quit
      • adambrenecki has quit
      • FunkyBob
        sounds ... hazardous, at best...
      • what will you do about url unfriendly characters?
      • you might want to spend some time reading up about Slugs
      • Gixxa
        FunkyBob: It's always the same
      • the only difference are numbers
      • djapo
        Gixxa: urlquote the titles
      • pzero joined the channel
      • jtiai
        djapo: Can you show the actual code?
      • Gixxa
        djapo: ?
      • phaer has quit
      • djapo
        jtiai: ill try dpaste, gimme a minute
      • FunkyBob
        Gixxa: so which part of the process has you stumped?
      • Gixxa
        FunkyBob: the actual casting of the vote
      • Manyman joined the channel
      • I see ma data and the form but when I press the "Lernbaustein Bewerten" nothing happens since I don't have a vote view
      • ma = my*
      • gremly joined the channel
      • chr1stopher has left the channel
      • djapo
        jtiai: http://dpaste.com/1765605/ here it is
      • Itkovian joined the channel
      • jtiai
        djapo: well does "User" point to correct model in your test?
      • djapo: Ah. It doesn't. :)
      • djapo: problem is that your form is imported _before_ swapped usermodel takes in place.
      • djapo: I bet your .utils does pick things on first import as well.
      • djapo
        jtiai: should i imported inside the test method, would you like to see utils?
      • jtiai
        djapo: Yes please share utils as well.
      • djapo
        jtiai: here it is http://dpaste.com/1765617/
      • jtiai
        Though I guess that doing import inside test method would get around the problem. And apparently answer is "yes", your _username_field is resolved only on initial import. So dynamic swap what you do in your test just doesn't work.
      • djapo: It could work if you would do runtime get_user_model().
      • Nemus has left the channel
      • _Cody
        absolutely deplorable noob question:
      • i come from php
      • there every site was automatically displayed under the server root
      • and i could define an index
      • djapo
        jtiai: i figure it would work at runtie but why isin't it working in my tests, why django?
      • _Cody
        how do i achieve that 127.0.0.1/foo.html will match my foo.html template?
      • jtiai
        _Cody: Bascially you don't.
      • _Cody: All urls in Django are resolved to views. Which in turn may use templates to render something.
      • _Cody: I suppose you did tutorial?
      • _Cody
        yep, with views
      • djapo
        _Cody: jtiai what about a sitemap
      • _Cody
        yet didnt get the transition to the template engine
      • i know a simple static/template setup from flask
      • jtiai
        djapo: Because you're resolving usermode one that is in effect when you import .utils file very very first time.
      • _Cody: So you did Django tutorial?
      • djapo
        jtiai: is there a lazy way to resolve the user model?
      • jtiai
        djapo: Only by using function that calls get_user_model() everytime it's called.
      • treyhunner joined the channel
      • djapo
        will try that
      • xoip has quit
      • phaer joined the channel
      • dlogs has quit
      • BinkyTheClown has quit
      • jtiai
        djapo: Same goes for your "User=..." usage in forms file. It will take whatever you had effective in your settings when that file is first time imported.
      • _Cody
        jtiai: i do the django book
      • jtiai
        _Cody: What book?
      • Gifgroen has quit
      • _Cody
      • FunkyBob
        _Cody: don't go near that
      • fllr joined the channel
      • it's old, it's very out-dated -- the front page even carries a warning -- and it has some questionable content
      • jtiai
        _Cody: Do django tutorial from django documentation first.
      • minim joined the channel
      • FunkyBob
        _Cody: but the idea of request paths mapping directly to templates is very limiting...
      • rxdazn joined the channel
      • _Cody
      • jtiai
        _Cody: Of course you should pick one for your version of framework. 1.6 suggested.
      • webus has left the channel
      • FunkyBob
        _Cody: surely you're not using django 1.4? [oh, let me guess- you're using the version packaged with your OS?]
      • _Cody: otherwise, yes, that tutorial
      • codeitloadit joined the channel
      • rxdazn
        hello! I'm trying to run my test suite but it says 'Ran 0 tests'. My app is inside INSTALLED_APP, my app dir does have an __init__.py, a models.py and a tests.py
      • jtiai
        _Cody: virtualenv and virtualenvwrapper will make your life much easier in the long run. Pays off to learn how to use them.
      • FunkyBob
        _Cody: takes about 1 minute to learn how to use virtualenv [bit longer for virtualenvwrapper... I've not bothered yet]