#django

/

      • NBhosting
        just to learn a bit i will try to make this view like it should
      • have a bit time left anyway :d
      • dseitz joined the channel
      • maxsong1002 joined the channel
      • maxsong1002
        Hello. Is anyone available to answer a simple Django question?
      • omglolnub has quit
      • FunkyBob
        maxsong1002: don't ask to ask... just ask :)
      • maxsong1002
        Thank you FunkyBob. I'm trying to import a module that I created to include some business logic.
      • FunkyBob
        ok
      • RootWeiller joined the channel
      • RootWeiller
        Hi
      • maxsong1002
        The file is located at my_project/my_app/fetch/fetch_data.py
      • I included an empty __init__.py file in my_project/my_app/fetch/
      • notleigh has quit
      • In my_proejct/my_app/views.py , I am trying to import the module.
      • FunkyBob
        maxsong1002: what have you written for the import line, and what error do you get?
      • maxsong1002
        `import fetch` works fine. No errors.
      • However, when I do fetch.fetch_data.some_method() I get 'module' object has no attribute 'fetch_data' error
      • FunkyBob
        but that won't give you anything that's in fetch_data
      • RootWeiller
        I have the following problem with django 1.5.4 SyntaxError 'return' outside function
      • FunkyBob
        because it only imports what's in __init__
      • maxsong1002
        Oh, I see.
      • FunkyBob
        RootWeiller: use dpaste to share the code
      • maxsong1002: from myapp.fetch import fetch_data
      • RootWeiller
        Ok FunkyBob, copy code
      • FunkyBob
        RootWeiller: my guess is it's an indenting issue
      • ArcTanSusan joined the channel
      • NBhosting
        Funky how can i avoid those 3 try/excepts ontop of my code, probaly not right
      • maxsong1002
        ... works like a charm
      • Thank you so much.
      • FunkyBob
        NBhosting: as I said, the Form would take care of that
      • RootWeiller
        This code generates the error me http://dpaste.com/1486739/
      • NBhosting
        also to get it in the template?
      • omglolnub joined the channel
      • FunkyBob
        NBhosting: pardon?
      • NBhosting
        those are mainly pushed trough my context to my template
      • omglolnub
        Hello all
      • FunkyBob
        RootWeiller: oh, wow... like NBhosting, you really NEED to learn to use ModelForms
      • NBhosting
        p
      • FunkyBob
        RootWeiller: what line does the error point at?
      • RootWeiller
        FunkyBob, it's 'return' outside function
      • twoolie
        NBhosting: please don't use naked excepts, it will bite you in the ass later.
      • always tell it what type of exception you're trying to catch
      • RootWeiller
        in line 46
      • NBhosting
        can it be done without a try at all
      • FunkyBob
        RootWeiller: and since line 46 of your paste isn't a return... which line of it is line 46?
      • omglolnub: hello
      • SmileyChris
        i wonder if it's a tab/space issue?
      • omglolnub
        Thanks for getting me started
      • FunkyBob
        SmileyChris: was considering that
      • NBhosting: what do you have a try for?
      • dirn has quit
      • twoolie
      • NBhosting
        to test if something fails and avoid code breaking?
      • [diecast] joined the channel
      • omglolnub
        So I started doing the tutorials here
      • FunkyBob
        twoolie: we're trying to get NBhosting to stop being silly, and use a ModelForm
      • RootWeiller
        FunkyBob, The idea is that once saved the profile to return to work /
      • twoolie
        FunkyBob: that too
      • NBhosting
        haha :D
      • SmileyChris
        RootWeiller: you have a syntax error, not a logic error
      • FunkyBob
        omglolnub: after you did the official django tutorials, yes?
      • NBhosting
        i still dont see how a model form is giving me data in the template side do
      • SmileyChris
        RootWeiller: somewhere in your code, there is a "return" at the wrong level of indentation
      • Narsilou has quit
      • RootWeiller: my first advice is to stop using tabs
      • omglolnub
        No I followed a link from another user yesterday the same time we talked
      • NBhosting
        i get that it makes forms, and u can validate with it, but am i missing something there
      • FunkyBob
        omglolnub: also, that doc refers to "Djangos MVC"... so it's clearly broken
      • omglolnub
        but I can go back
      • okay will do
      • twoolie
        FunkyBob: except that it looks like he has 2 submit buttons, and processes the data differently depending on which one is pressed
      • bradfordtoney joined the channel
      • Narsilou joined the channel
      • FunkyBob
        twoolie: he should still use a form
      • SmileyChris
        two forms!
      • FunkyBob
        SmileyChris: so... django-social-auth, or django-allauth ?
      • SmileyChris
        allauth
      • twoolie
        FunkyBob: and that he's saving data into 3 different models
      • FunkyBob
        twoolie: when validating user input, USE A FORM... ALWAYS
      • twoolie: then use 3 forms
      • SmileyChris: :)
      • omglolnub
        How many lines can you post in IRC before you upset people....I like this group I don't like upsetting others
      • twoolie
        omglolnub: 1 line
      • RootWeiller
        SmileyChris, I have reviewed the levels of indentation, I do not understand where this error could be
      • FunkyBob
        SmileyChris: might be ripping out social auth and and openid...
      • maxsong1002
        Hey FunkyBob, I have a couple more questions..
      • FunkyBob
        omglolnub: for more, use dpaste.org
      • SmileyChris
        RootWeiller: i'm leaning towards you having mixed tabs/spaces
      • FunkyBob
        RootWeiller: did you tell us which line is line 46 of your file?
      • maxsong1002: shoot
      • omglolnub
        FunkyBob: Can I send you a private I won't take to much of your time
      • SmileyChris
        no, waste all of our time
      • RootWeiller
        FunkyBob, yes
      • FunkyBob
        RootWeiller: which line of your paste is line 46 of the source file?
      • maxsong1002
        views.py is located in project/app already, so why is it necessary to do `import app.fetch` instead of just `import fetch`?
      • rafales joined the channel
      • SmileyChris
        off topic: bf4 for $25, nice.
      • RootWeiller
        it the line return HttpResponseRedirect('/')
      • FunkyBob
        maxsong1002: because you should use either explicit relative import ("import .fetch") or absolute imports
      • maxsong1002
        also to open a csv file inside static folder, I had to do `open('app/static/app/some_file.csv')`
      • twoolie
        SmileyChris: $25? not with the Fuck You Australia tax.
      • FunkyBob
        maxsong1002: that open() won't work in production, I'll wager
      • SmileyChris
        twoolie: amazon, any us address
      • JohanSJA joined the channel
      • maxsong1002
        That begs another question that how I should make it work ;)
      • twoolie
        does it work for the digital edition?
      • SmileyChris
        yep
      • twoolie
        :D
      • maxsong1002
        (you're very helpful)
      • FunkyBob
        maxsong1002: well, if that file isn't meant to be served to users directly, it shouldn't be in static/
      • maxsong1002: you can get the path to the current module using os.path.dirname(__file__)
      • NBhosting
        changing some stuff
      • FunkyBob
        then you can use os.path.join() to find things relative to it
      • koobs joined the channel
      • maxsong1002
        FunkyBob: The idea is I want to edit the csv file every 24hrs (using cronjobs) and draw a graph in javascript based on the csv file
      • hoot_ joined the channel
      • FunkyBob
        maxsong1002: then it _really_ doesn't belong in static
      • maxsong1002
        FunkyBob: where should it belong to?
      • FunkyBob
        mattmcc: hey... friend just linked me to this -- http://www.theregister.co.uk/2013/11/28/why_pla...
      • maxsong1002: is it to be served to users?
      • maxsong1002
        FunkyBob: and why cant it live in static/ ?
      • FunkyBob
        maxsong1002: because, as you just said, it's NOT static
      • SmileyChris
        maxsong1002: and also, static files get compiled to a different location
      • hoot has quit
      • maxsong1002
        I see
      • FunkyBob
        and static dirs in apps, etc, and the source for the collected static files that get published... published elsewhere
      • garet has quit
      • define in your settings a workspace dir for stuff like that to live
      • bradfordtoney has quit
      • SmileyChris
        or just define the file itself
      • FunkyBob
        again... is that CSV file supposed to be served to users?
      • SmileyChris
        MY_CSV = '/somewhere/something.csv'
      • maxsong1002
        FunkyBob: yes the user might want to download the csv file
      • FunkyBob: but as soon as the enter the website, they will be presented with a graph that's based on the csv file, which is updated everyday
      • FunkyBob: it is not that necessary to make the file downloadable though.
      • omglolnub
      • somniac joined the channel
      • SmileyChris
        omglolnub: sounds like you're having virtualenv issues
      • NBhosting
        cleaned it up a bit https://dpaste.de/BbRp now i got todo alot of forms
      • 3 forms
      • drterminal has quit
      • SmileyChris
        NBhosting: you could still get errors raised from that view
      • kbambz joined the channel
      • NBhosting: reqouest.POST.get('klant') will return None if it's not found
      • NBhosting: and that'll cause a Winkelwagen.DoesNotExist exception
      • NBhosting: please don't use TitleCase for functions, by the way
      • NBhosting
        diesnt trow a error here
      • pydanny joined the channel