#django

/

      • rideh joined the channel
      • les_sylvains joined the channel
      • anth0ny has quit
      • bojo joined the channel
      • rmarcus joined the channel
      • les_sylvains has quit
      • jezdez
        rmarcus: welcome!
      • tyfighter joined the channel
      • Bubo
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
      • anyone care to explain how this works?
      • I know what timezone.now() - datetime.timedelta(days=1) do
      • but >= ?
      • twikz joined the channel
      • twoface
        larger than or equal
      • tdelam
        greater than or equal
      • Lacrymology has quit
      • twoface
        its basic math
      • rmarcus
        hi jezdez great name for a german/usa keyboard
      • jezdez
        ;)
      • Bubo
        I know what that is ..
      • michaelfillier
        I have a view for a login form, how can I include that on my home page?
      • Bubo
        it returns self.pub_date if it's greater than or equal timezone.now() - datetime.timedetla(days=1) ?
      • rmarcus has quit
      • etcetera has quit
      • twoface
        no, it returns a boolean that indicates whether it is greater than or equal
      • Bubo
        ok, thank you
      • adamsilver joined the channel
      • m0rpho has quit
      • trbotime has quit
      • Deathvalley122 has quit
      • frequant has quit
      • adamsilver
        why having request.LANGUAGE_CODE = 'fr-ca' in my view has no effect?
      • twoface
        adamsilver, because that is not how you set your language?
      • twikz has quit
      • adamsilver
        ok.. the thing is i want to keep admin in english and change the frontend to french
      • aberrant
        yay
      • it's working
      • but: is there a way to split a form.as_table into two columns?
      • etcetera joined the channel
      • michaelfillier
        SO is there a django way to include the results of a view in another template?
      • twoface
        only by looping the form, instead of using .as_table
      • michaelfillier
        Or is the recommended approach to use an ajax call
      • twoface
        michaelfillier, views returns the result of a template - not the other way around :)
      • neataroni has quit
      • gpaci joined the channel
      • mgrouchy has quit
      • b3free has quit
      • aberrant
        twoface: cool. Need to figure out how to loop the form.
      • michaelfillier
        twoface: so if I have a view for a login form, I basically can't include that in another template?
      • gpaci
        I have a mysterious problem: some of my tables mysteriously get truncated (i.e. all rows deleted).
      • Victim tables include auth_users and some of our own tables.
      • twoface
        michaelfillier, it certainly sounds like the wrong solution - perhaps you should explain precisely what you are trying to do
      • gpaci
        My suspicion is I'm doing something stupid with Django or South or both.
      • But I have no idea what, and google has been no help at all.
      • Bubo has quit
      • Bubo joined the channel
      • twoface
        gpaci, using .delete() anywhere?
      • gpaci
        I think so, yes.
      • michaelfillier
        I have a login form page and I want to open it in a modal. I figured an include would be the best, but the form shows up without form fields.
      • twoface
        make sure you are not using it on non-filtered querysets
      • gpaci
        But not on those tables: they should never change. Much.
      • michaelfillier
        The template uses form.as_p but it seems like form is not available
      • twoface
        michaelfillier, include only includes the template - you still need to provide the correct context
      • hwrd|work joined the channel
      • anth0ny joined the channel
      • ryanisnan has quit
      • gpaci
        twoface, I just checked: we use delete() around 70 places, but never on auth_users or our vendors table.
      • twoface
        gpaci, i've never heard of django just truncating tables, so i really wouldn't know where to start
      • gpaci
        Oh, and all our south migration history disappears for ONE app (a new one).
      • kanja has quit
      • andrewjsledge has left the channel
      • twoface
        database cleanup scripts? replication gone bad?
      • gpaci
        twoface, No replication, not much cleanup. Maybe it's some mistake using South?
      • rbk404 has left the channel
      • twoface
        south doesn't delete rows
      • unless you have migrations that deleted models and creates them again - wouldn't know how you should have created them though
      • gpaci
        Have you ever heard of south migrationhistory disappearing?
      • twoface
        not at all
      • gmcabrita joined the channel
      • gpaci
        twoface, Well, thanks for listening.
      • Guddu joined the channel
      • michaelfillier
        twoface: How can I do that, I already tried creating a variable in my home view - 'login_form': login(request,**login_dict) but the login_form variable still doesn't have any form fields.
      • brainwarped
        gpaci: only when I delete it on purpose.
      • adamjon858 joined the channel
      • twoface
        michaelfillier, login is not a form - unless it is wrongly named
      • ehazlett has left the channel
      • michaelfillier
        login is a view, I thought creating a variable from a view that returns a render would work
      • Bubo
        Reading the django tutorial I came to --> p.choice_set.all() --> choice_set is syntax or?
      • twoface
        michaelfillier, a view does not return a form - a view normally returns a httpresponse object
      • juliaelman has quit
      • yva has quit
      • invisib joined the channel
      • invisib
        How would I setfirstweekday to a subclassed HTMLCal?
      • twoface
        Bubo, if it is not syntax, what else would it be?
      • JJMalina has quit
      • michaelfillier
        twoface: yeah, but my view loads a form, that doesn't work?
      • invisib
        For instance, I made an event calendar by subclassing HTMLCal, but I forgot to setfirstweekday. Where do I need to go to add that functionality?
      • twoface
        michaelfillier, how could it? you are trying to use a httpresponse as a form object
      • gpaci
        Bubo: whatever class p is has a class Choice that points to it.
      • mgrouchy joined the channel
      • Bubo
        Oh
      • gpaci
        p.choice_set means "all the Choice objects that have p as their P".
      • Bubo
        So
      • If it had a Foo class pointing to it
      • it would be foo_set ?
      • gpaci
        Yes.
      • michaelfillier
        twoface: here is the login view: http://dpaste.com/hold/839122/
      • Bubo
        Nice. thank you
      • mjvs joined the channel
      • michaelfillier
        twoface: it handles the form loading and passes it to the template
      • Bubo
        So the class Choice has a foreign key relation to the Poll one, and choice_set is used to populate the class Choice database with relation to the p.id
      • gpaci
        So Choice has a field that looks like this: models.ForeignKey(Poll) # if I recall the tutorial correctly, Polls have Choices
      • Bubo
        Yes
      • exactly
      • so it just makes the choice that I will set to a specific Poll
      • using the ForeignKey
      • gpaci
        Yeah.
      • notanumber has quit
      • JJMalina joined the channel
      • aberrant
        aw, man
      • this is really tough
      • I have a form with lots of fields. I've ordered the fields. Now I want to split them up in between two columns. I figured I can do that with {% cycle %} but I'm at a complete loss.
      • mjvs has left the channel
      • chrisramon has quit
      • Bubo
        p.choice_set.create(choice='Not much', votes=0) - to create a choice for the Poll. I don't need to run p.save() at the end to save the choices, right?
      • trbotime joined the channel
      • d0c0nnor joined the channel
      • adamsilver
        where should i save the custom Middleware?
      • twoface
        michaelfillier, i can see that - but you can't include a view in another view like that
      • ptone has quit
      • adamsilver, anywhere you want
      • ToApolytoXaos has quit
      • adamsilver
        twoface: what is the convention
      • twoface
        adamsilver, i usually create a middleware.py in the app it pertains to
      • etcetera has quit
      • adamsilver
        twoface: ok, thanks
      • hoot has quit
      • Drager
        Any idea why this; http://dpaste.org/dP82c/ would fail to insert a UserProfile? I know it's the save() in the model that causes it.
      • ptone joined the channel
      • Bubo
        poll = models.ForeignKey(Poll, null=True) - is the right sintax to be able to have NULL in the foreignkey column ?
      • latestrevision
        Bubo: -- yep
      • nedbat has quit
      • Drager: If you are inserting a new row, `self.id` will be None
      • JJMalina has quit
      • you should put a `super(UserProfile, self).save()` in an else branch should the user not meet the qualifications on 39
      • mgrouchy has quit
      • elabianca joined the channel
      • Bubo
        ty
      • Drager
        latestrevision: That did the trick, thank you very much :)
      • bullicon joined the channel