May 6, 2012
← next day
previous day →
- # 00:00 <dxtr> Okay, this turned out to be a lot of work :(
- # 00:30 <dxtr> I'd rather not
- # 00:30 <dxtr> But I mean.. is the django runserver caching stuff?
- # 00:30 <dxtr> And I have checked the database and the flag is set correctly
- # 00:30 <harnek_> Hi, does the django framework allow asynchronous connections to postgresql using psycopg2?
- # 00:30 <nanonyme> dxtr, it should not be
- # 00:30 <dxtr> nanonyme: Then why isn't it working like it should when I run that? :p
- # 00:30 <nanonyme> that is, it shouldn't be unless you have caching middlewares enabled
- # 00:30 <dxtr> I don't
- # 00:30 <dxtr> I'm connecting directly to the django webserver
- # 00:30 <nanonyme> I mean in settings.py
- # 00:30 <dxtr> Yeah
- # 00:30 <dxtr> I don't have that there either
- # 00:30 <Frantic> I'm working on an API, and for consistency, I want my users to log in to the app by POSTing to my API's URL, and I want it to return a new Session object with the session_key in it. I see that Django doesn't create the session key until after my views have returned.
- # 00:30 <nanonyme> dxtr, if you run the query from Django shell, does it give the results you expect
- # 00:30 <nanonyme> ?
- # 00:30 <dxtr> Yes
- # 00:30 <Frantic> So I have written a function _session_get_key(request): if not request.session.session_key: request.session.create(); return request.session.session_key
- # 00:30 <Frantic> Could this cause any trouble?
- # 00:30 <dxtr> nanonyme: Doesn't matter if I have .order_by() or not
- # 00:30 <dxtr> And the webserver doesn't spit out any error messages
- # 00:30 <harnek_> ostgresql using psycopg2?
- # 00:30 <harnek_> <nanonyme> dxtr, it should not be
- # 00:30 <harnek_> <-- soupnixer (soupnixer@s1.bestbnc.com) has left #django ("Leaving")
- # 00:30 <harnek_> Hi, does the django framework allow asynchronous connections to postgresql using psycopg2?
- # 00:30 <Frantic> SessionBase.create() never seems to get called, am I missing something? Is that only in there for the users to use to get a session_key before user code returns?
- # 00:30 <nanonyme> well, that definitely says the query itself is sound
- # 00:30 <dxtr> Yeah
- # 00:30 <dxtr> Seems like django just isn't executing the query for some reason
- # 00:30 <dxtr> And it just stored the answer from the last time
- # 00:30 <nanonyme> dxtr, feel like reading source code for archive_index function?
- # 00:30 <dxtr> Aaw :P
- # 00:30 <nanonyme> also, hmm
- # 00:30 <dxtr> I just don't get it
- # 00:30 <nanonyme> dxtr, well, if it'd work right after test server restart, I'd suspect setting context from url mapping only gets it set once
- # 00:30 <glosoli> hmm my MEDIA url is set to "/media/" and I get error: [05/May/2012 17:25:55] "GET /media/js/jquery.js HTTP/1.1" 404 2059 I am sure that file exist and etc set chmod 777 for that dir
- # 00:30 <glosoli> any ideas ?
- # 00:30 <nanonyme> dxtr, but since it never works, I don't know
- # 00:45 <nanonyme> ie iterating over the same queryset always yields the same results
- # 00:45 <dxtr> Well, yeah, it's working right after the server restart
- # 00:45 <nanonyme> right. well. how about using a lambda there that returns the queryset?
- # 00:45 <nanonyme> with no parameters
- # 00:45 <nanonyme> that way you'd get a new queryset each time the lambda gets called in the template
- # 00:45 <dxtr> oh right
- # 00:45 <dxtr> nanonyme: Like: extra_context: { 'latest_entries': lambda: Entry.objects.filter(published=1) } ?
- # 00:45 <nanonyme> dxtr, you also need clauses around the lambda afaik
- # 00:45 <nanonyme> so Python only has one way to parse it
- # 00:45 <nanonyme> but yeah, essentially like that
- # 00:45 <dxtr> Clauses?
- # 00:45 <nanonyme> but I'm not sure how to call it in the template
- # 00:45 <dxtr> haha
- # 00:45 <nanonyme> sorry, parenthesis
- # 00:45 <dxtr> Like: extra_context: { 'latest_entries': (lambda: Entry.objects.filter(published=1)) } ?
- # 00:45 <nanonyme> dxtr, a generator function would definitely do it, that would be just a normal iterable
- # 00:45 <dxtr> Looks decent
- # 00:45 <nanonyme> yeah
- # 00:45 <nanonyme> so if you can't get that to work, make a generator. the second least rewritey way to do it
- # 00:45 <dxtr> Oh
- # 00:45 <dxtr> That lambda seems to work
- # 00:45 <nanonyme> neat
- # 00:45 <dxtr> nanonyme: you saved my night, man
- # 00:45 <dxtr> I'd give you a beer. But you probably live far away :.p
- # 00:45 <dxtr> :p*
- # 00:45 <nanonyme> yeah, plus I've hangover anyway. but yeah, good that it started working
- # 00:45 <nanonyme> night
- # 01:00 <dxtr> haha
- # 01:00 <glosoli> as there are /templates/ dirs which I can keep in every app, can I do same for /media/ ?
- # 01:00 <Unode> is it possible to use the login signal to force a page redirect if some condition is met?
- # 01:15 <glosoli> httpdss: what do you mean by static is default name ?
- # 01:15 <Unode> I'm trying to ensure users provide certain information on their first login, but I'm using the builtin login view, so I have to way to hook code directly to the login besides using signals
- # 01:15 <httpdss> that you should create a static/ folder inside the app, not a media/ folder
- # 01:15 <httpdss> glosoli: that you should create a static/ folder inside the app, not a media/ folder
- # 01:15 <Unode> but as far as I've tested redirects don't seem to work inside signals, unless I'm missing something
- # 01:15 <glosoli> httpdss: aaa, just dealing with this one: was updated yesterday to use Django 1,4 https://github.com/boskee/django-schedule but all the static files still in media, and lot of icons missing ;D
- # 01:15 <Unode> if possible I would like to avoid copy/pasting contrib.auth.views.login to simply add two lines of code
- # 01:15 <httpdss> glosoli: ;)
- # 01:15 <glosoli> httpdss: maybe you ever used that app ?
- # 01:15 <httpdss> glosoli: nope but its on my github watch list :P
- # 01:15 <logabr> Hi guys, from where should I import DoesNotExist. I am using get() instead of a filter and I'm not sure in what module it's stored
- # 01:15 <glosoli> httpdss: why so ? :D
- # 01:15 <logabr> ah nevermind i found it
- # 01:15 <Unode> logabr, if your model is named Jane use Jane.DoesNotExist
- # 01:15 <httpdss> glosoli: there is also a static template tag to use specially if using custom storage stuff .. {% static 'css/base.css' %}
- # 01:15 <glosoli> httpdss: yep I understand, have been using static before
- # 01:15 <glosoli> httpdss: it looks really beautiful (the parts I managed to load), still fighting with it, would be nice to contact dev itself, but can't find any contacts
- # 01:15 <glosoli> httpdss: ah ok, bye :)
- # 01:15 <httpdss> glosoli: just fork that repo and then make a pull request when you fix it ;) he will appreciate it :P
- # 01:15 <glosoli> will try that tomorrow, 02:08AM here, time to sleep soon
- # 01:30 <daniel110> Hey can someone please help me with setting up static files (css) with django. I spent the last two hours trying to get it to work.
- # 01:30 <nkuttler> daniel110: just ask
- # 01:45 <Squeige> hey guys, dont think I am using south properly...
- # 01:45 <Squeige> first i need to run python manage schemamigration --initial blogger
- # 01:45 <Squeige> when i do python manage.py migrate blogger
- # 01:45 <Squeige> it returns an error
- # 01:45 <Squeige> django.db.utils.DatabaseError: table "blogger_blog" already exists
- # 01:45 <Squeige> if I just delete the .db file and do a syncdb it should be like starting over right?
- # 01:45 <nkuttler> Squeige: or use --fake
- # 01:45 <Squeige> but why am I getting the error in the first place?
- # 01:45 <nkuttler> Squeige: because the initial migration is trying to create a table that already exists
- # 01:45 <Squeige> is the procedure create your models, run syncdb, then do schemamigration initial, and then after that do migrate?
- # 01:45 <Squeige> the initial is not getting error that one works,
- # 01:45 <Squeige> its when i do the migrate that i get it
- # 01:45 <harnek_> I'm confused on what self.id actually does
- # 01:45 <harnek_> can someone explain that to me
- # 01:45 <harnek_> I tried googling it
- # 01:45 <nkuttler> harnek_: self.id is probably the default primary key
- # 01:45 <harnek_> ok
- # 01:45 <harnek_> thanks
- # 01:45 <lobius> Is there any central collection of django apps to drop into a project or is the idea that you build your own apps and, over time, reuse them in various projects?
- # 02:00 <herrwolfe45> w
- # 02:00 <jaddison> lobius: http://djangopackages.com/ has a decent comparison and listing of packages.
- # 02:00 <jaddison> There are a lot of Django packages on github and other DCVS-based source code sites.
- # 02:00 <lobius> Cool. I'll check that out.
- # 02:00 <herrwolfe45> hi - I'm using several of the class based views and I would like prefilter their query sets based on the account associated with the user. Would it be best, since I will be reusing this with each of the CBVs, to create a mixin that does this?
- # 02:15 <mlavin> herrwolfe45: that sounds like a great use for a mixin to me
- # 02:15 <mlavin> oh he/she is gone
- # 02:45 <cincinnatus> Is it normal if the latest Aptana Studio still displays a bogus warning with Django 1.4? Or does it mean my Django is messed up somehow?
- # 02:45 <cincinnatus> They're supposed to have fixed it in PyDev 2.5... Aptana comes with 2.5, just not the latest build
- # 02:45 <ParagonRG> I've got an issue involving the back button. When I load an edit page (using a view class extending the UpdateView generic view), there is a call in the dispatch() function that checks to see if the method is 'GET'
- # 02:45 <ParagonRG> If it is, it adds a database entry
- # 02:45 <ParagonRG> But if I click Back to get to the page, it does not add a database entry
- # 02:45 <ParagonRG> Does anyone know why this might be?
- # 02:45 <sqwerty> caching ?
- # 02:45 <cincinnatus> *browser* caching
- # 02:45 <sqwerty> idd
- # 02:45 <cincinnatus> some browsers won't hit the page at all
- # 02:45 <cincinnatus> In general, it's not recommended to use GET requests for anything state-altering
- # 02:45 <cincinnatus> (precisely because they may be cached)
- # 02:45 <cincinnatus> there are ways to kill the cache though
- # 02:45 <sqwerty> if it's absolutely required then do it with javascript on page load
- # 02:45 <ParagonRG> What kind of request is it, then? If I remove the conditional so that the database entry is always made, it works okay. So clearly the dispatch() method is being reaches
- # 02:45 <ParagonRG> *reached.
- # 02:45 <ParagonRG> But it doesn't make much sense to me that it would be POST
- # 02:45 <sqwerty> really? :\ doesn't make sense
- # 02:45 <sqwerty> log the request and have a look
- # 02:45 <ParagonRG> Will do
- # 03:00 <FunkyBob> carljm: awake?
- # 03:00 <ParagonRG> Yeah, it says it's a GET from cache
- # 03:00 <ParagonRG> And I was wrong, about the database entry being made either way. It's just working for some unknown reason
- # 03:00 <ParagonRG> Thanks gentlement
- # 03:00 <ParagonRG> It's a gentle settlement. No, thanks, gentlemen
- # 03:00 <lobius> I heard a rumor that django cannot handle forms well (get and post.) It sounds ridiculous and I would just like to know if any one else has heard this.
- # 03:00 <FunkyBob> first time I've heard anything of the sort
- # 03:00 <FunkyBob> what's the problem we're trying to solve?
- # 03:00 <cincinnatus> I think Django has less "magic" for forms than "Railsy" frameworks, but the functionality works pretty well
- # 03:00 <lobius> Data entry, make page based on data, save data to database, recall prior entries. Seems like a slam dunk for django. I do this kind of project quite often. I should just get started.
- # 03:00 <lobius> Never used any kind of framework for these little form projects. Django would be a first.
- # 03:00 <lobius> A long, long time ago, I did my first ones in ASP. Does not get harder than that so everything else looks easy. :-)
- # 03:00 <lobius> ASP: worst ever.
- # 03:00 <ParagonRG> What's so bad about ASP? I've never used it
- # 03:00 <lobius> 70 functions as opposed to 7000 that you would find in PHP.
- # 03:00 <lobius> You have to write a lot of stuff yourself.
- # 03:00 <lobius> Time consuming.
- # 03:00 <jfpoint> Can somebody look over this model and tell me why it only gives me a "karten_spiel.UrlName may not be NULL" error? http://dpaste.org/aeOkS/
- # 03:00 <lobius> SCAD
- # 03:00 <ParagonRG> Hah
- # 03:00 <ParagonRG> jfpoint: It seems like you're sending a value of NULL for UrlName
- # 03:00 <ParagonRG> Which, if it's a required attribute, is something that won't work
- # 03:00 <jroll> lobius: django has pretty good form support built in: https://docs.djangoproject.com/en/dev/topics/forms/
- # 03:00 <jfpoint> But it gives me that when i send something like "This is a long name" to it.
- # 03:00 <lobius> Looking at it now
- # 03:00 <lobius> Thanks. I'll be back in a few.
- # 03:15 <jroll> np ")
- # 03:15 <ParagonRG> Oh, it's a capitalization issue
- # 03:15 <jroll> :) *
- # 03:15 <ParagonRG> urlName is not the same as UrlName
- # 03:15 <ParagonRG> You're just not setting the right attribute
- # 03:15 <ParagonRG> jfpoint: Did that work?
- # 03:15 <jfpoint> ParagonRG: perfectly! Thanks a lot. It?s to late for me.
- # 03:15 <ParagonRG> jfpoint: Hah, no worries. Anyone can make that mistake
- # 03:15 <ParagonRG> jfpoint: And also, go to bed
- # 03:15 <jfpoint> yeah. I will definitifly go now to bed :D
- # 03:15 <jfpoint> bye everyone
- # 03:30 <lobius> A template page can be any page with the django template markup and pointed correctly (as per tutorial.)?
- # 03:30 <lobius> Not necessarily HTML?
- # 03:30 <FunkyBob> lobius: the templates don't care what they generate
- # 03:30 <FunkyBob> lobius: and views can serve any content type
- # 03:30 <lobius> Thanks. That's what it sounded like.
- # 03:30 <FunkyBob> however...
- # 03:30 <FunkyBob> the way you explain it sounds like you think it's like PHP
- # 03:30 <FunkyBob> where the template is the app
- # 03:45 <lobius> No, I'm looking over the django tutorial. I'm an experienced programmer. I don't think in PHP. I'm just double checking what I'm reading against, in this case, you.
- # 03:45 <FunkyBob> remember the cycle is thus: request is routed by a url pattern to a view. the view generates a response.
- # 03:45 <lobius> I think it's great. I've already implemented a lot of business critical code in python. This is the big one because it has to do with our contracts system.
- # 03:45 <FunkyBob> if the view uses a template to generate the content for that response... then a template is involved.
- # 03:45 <FunkyBob> well, I've just launched the biggest web site I've ever been involved in... so... :)
- # 03:45 <lobius> Django reads like it will be as liberating as python was. My python code was about mostly strings and sockets. Django is slightly more involved as I am translating a mess from PHP into something maintainable.
- # 04:00 <ParagonRG> FunkyBob: Care to share the site?
- # 04:00 <abisson> Hey guys... if I have a Model, in which I override the save method, it will call the save method for each individual fields it has right? In this case, will the S3Bucket save method be called? (if so, how can I pass argument to it?) http://dpaste.org/jgGkG/
- # 04:15 <FunkyBob> ParagonRG: www.kogan.com
- # 04:15 <ParagonRG> Sweet
- # 04:15 <FunkyBob> abisson: what do you mean "call the save method for each individual fields"? save gets called when save gets called, and it saves the whole instance at once.
- # 04:15 <abisson> FunkyBob: ok... but if you look at my model. the save method for the "file" will also be called right?
- # 04:15 <FunkyBob> abisson: that save looks ok
- # 04:15 <FunkyBob> abisson: what do ytou mean "save method for the file"?
- # 04:15 <abisson> the save function of the FileField
- # 04:15 <FunkyBob> I tend to rely on ModelForms to take care of that, tbh...
- # 04:15 <abisson> FunkyBob: right... but by S3Bucket.save() will also be called right?
- # 04:15 <phajas_desktop> I am following the Django tutorial, and utilizing the database API through the interactive shell (here: https://docs.djangoproject.com/en/dev/intro/tutorial01/#playing-with-the-api). When I type "p.id", the shell spits back nothing. Have I done something wrong? Here's my log: http://dpaste.org/aFXO5/
- # 04:15 <FunkyBob> I dug into that a while back... but can't remember exactly when the file gets saved...
- # 04:15 <FunkyBob> phajas_desktop: you're using iPython, that's why
- # 04:15 <FunkyBob> phajas_desktop: try "print p.id"
- # 04:15 <phajas_desktop> FunkyBob: It has a None id. I didn't know manage.py started an iPython shell.
- # 04:15 <FunkyBob> phajas_desktop: it will if you have it
- # 04:15 <FunkyBob> it's right there in line 9 of your paste
- # 04:15 <phajas_desktop> FunkyBob: Nevermind, I forgot to run save as a function. Line 25.
- # 04:15 <FunkyBob> :)
- # 05:00 <hell_razer> is any way to set view only permssion on model in django 1.4
- # 05:00 <iosolidar> i'm getting this error message http://pastebin.com/7zuK821Y when using this code http://pastebin.com/nqH4yrqF
- # 05:15 <FunkyBob> hell_razer: you can create your own permissions easily enough
- # 05:15 <FunkyBob> hell_razer: but if you want it for admin... you're doing it wrong :)
- # 05:15 <hell_razer> FunkyBob: i wan it for admin
- # 05:15 <FunkyBob> iosolidar: wow.. using old function-based generic views?
- # 05:15 <FunkyBob> iosolidar: the problem is... a model instance is not a queryset... and get() returns an instance
- # 05:15 <iosolidar> FunkyBob: it messes up my urls.py
- # 05:15 <FunkyBob> iosolidar: what does?
- # 05:15 <FunkyBob> why are you using the old, deprecated generic views?
- # 05:15 <FunkyBob> do you not have django 1.3+?
- # 05:15 <iosolidar> oh yes...
- # 05:15 <iosolidar> that's what they had in the docs
- # 05:15 <iosolidar> https://docs.djangoproject.com/en/1.3/ref/generic-views/#django-views-generic-list-detail-object-detail
- # 05:15 <iosolidar> based on this
- # 05:15 <FunkyBob> https://docs.djangoproject.com/en/1.3/ref/class-based-views/
- # 05:15 <FunkyBob> use that instead
- # 05:15 <iosolidar> k.. i'll check it out, thanks :)
- # 05:15 <FunkyBob> anyway
- # 05:15 <FunkyBob> your view in the paste was pointless... as the generic view would do all of that work
- # 05:15 <iosolidar> pointless maybe, but it's more organized for me
- # 05:15 <FunkyBob> but you were trying to do work that the generic view already does
- # 05:15 <iosolidar> i need to write that code anyway, just in urls.py instead of my views.py
- # 05:15 <FunkyBob> ...
- # 05:15 <FunkyBob> doesn't matter where you write it
- # 05:15 <FunkyBob> the generic view you were using, list_detail, takes a _queryset_ and picks an instance from it according to the lookup field
- # 05:15 <iosolidar> its more readable this way
- # 05:15 <FunkyBob> what way?
- # 05:15 <iosolidar> ohhh
- # 05:15 <iosolidar> got it
- # 05:15 <iosolidar> that makes more sense
- # 05:15 <FunkyBob> ok... so... only had to tell you twice...
- # 05:15 <FunkyBob> better than some
- # 05:15 <iosolidar> :S
- # 05:15 <FunkyBob> I guess I should have started by pointing out your immediate mistake, and then move onto best practices
- # 05:15 <iosolidar> FunkyBob: thank for your help
- # 05:30 <FunkyBob> np
- # 05:30 <FunkyBob> you ask questions well... I wish more people would :)
- # 05:30 <iosolidar> haha
- # 05:30 <FunkyBob> seriously.
- # 05:30 <iosolidar> https://addons.mozilla.org/en-US/firefox/addon/django-docs-search/
- # 05:30 <FunkyBob> neat
- # 05:30 <FunkyBob> if I used mozilla, that might be useful :P
- # 05:30 <iosolidar> it's never too late :P
- # 05:30 <FunkyBob> Chrome will do me fine, thanks :)
- # 05:30 <FunkyBob> does that let you configure which doc version it searches?
- # 05:30 <iosolidar> https://chrome.google.com/webstore/detail/fppchigfjbnpcinllncbeijgjlndpbkh
- # 05:30 <iosolidar> don't know - haven't checked it out yet
- # 05:30 <iosolidar> nope :(
- # 05:30 <iosolidar> it's buggy
- # 05:30 <FunkyBob> hmm
- # 05:30 <FunkyBob> it doesn't seem to know about 1.3+
- # 06:00 <mrtuple> What is the "best" way to filter input to a form field *before* it gets cleaned? I'd like to remove $ and commas from an integer field for income. Any thoughts on whether this belongs in javascript or in the view or in a subclassed field?
- # 06:00 <FunkyBob> I wouldn't rely on JS... use it too, but don't rely on it
- # 06:00 <iosolidar> def clean_field(...) is the best way to synthesize input
- # 06:00 <FunkyBob> iosolidar: sure, but that hooks in too late, I think
- # 06:00 <iosolidar> why?
- # 06:00 <iosolidar> it's before it gets cleaned, so he gets the actual data in the field
- # 06:00 <mrtuple> I want something before cleaning and validation, don't I?
- # 06:00 <iosolidar> oh
- # 06:00 <mrtuple> ACTION looking up clean_field...
- # 06:00 <iosolidar> you can access the fields directly do
- # 06:00 <iosolidar> request.POST.get('fieldname')
- # 06:00 <iosolidar> https://docs.djangoproject.com/en/dev/ref/forms/validation/
- # 06:00 <iosolidar> though*
- # 06:00 <mrtuple> yes, this is what I did originally, I just thought there might be a more djangoee way of doing it.
- # 06:15 <iosolidar> FunkyBob: can you access the fields before validation using something like form.fields.get('fieldname') ?
- # 06:15 <FunkyBob> look at the steps a form goes through for validation
- # 06:15 <FunkyBob> it's already done a fair bit of work before it reaches clean_FOO
- # 06:15 <FunkyBob> https://docs.djangoproject.com/en/1.4/ref/forms/validation/
- # 06:15 <mrtuple> ok, so I need to modify the data before to_python is called. looks like a need to either subclass the IntegerField for forms or do it on the post data in the view.
- # 06:15 <mrtuple> I'm using ModelForm, i'm not sure how to modify the formfield used for a data column... and I've only got one place in the view logic where this needs to go, so I'll stick with peeking at POST.
- # 06:15 <mrtuple> thanks all.
- # 06:15 <jY> any recommend a facebook connect module they like?
- # 06:30 <mrtuple> oh, so I can't modify request.POST: This QueryDict instance is immutable
- # 06:30 <Mohsen_Hassani> Why doesn't this page show the image of captcha?
- # 06:30 <Mohsen_Hassani> http://nimkateonline.com/registration/
- # 06:45 <iosolidar> http://nimkateonline.com/captcha/image/3ff11384d7abe455b7c7d4b2707837d27946dcc2/
- # 06:45 <iosolidar> use firebug to debug your code
- # 06:45 <iosolidar> it has a net panel where you can see all http requests and their information (including the content of the page which normally wouldn't be accessible)
- # 06:45 <Mohsen_Hassani> iosolidar, I've been working on it for 3 days, but with not chance! I've been using firebug and it says "expected string". I didn't write the captcha, nor I worked with the files which it finds errors in.
- # 06:45 <iosolidar> you do have access to the file?
- # 06:45 <Mohsen_Hassani> iosolidar, I'm using django-simple-captcha, it's working good on my PC and Laptop (debian) but on my VPS (debian) I'm getting this error recently.
- # 06:45 <Mohsen_Hassani> iosolidar, Yes I do. I can edit those files.
- # 06:45 <Mohsen_Hassani> iosolidar, Captcha is passing some characters to the PIL, I guess PIL is not working good. It's the same as the files and codes on my PC.
- # 06:45 <iosolidar> yeah those type of bugs are the worst
- # 06:45 <Mohsen_Hassani> iosolidar, I already reinstalled PIL (python-imaging) but it's still having those errors.
- # 06:45 <iosolidar> did you check the lines in the error?
- # 06:45 <iosolidar> does the code that calls it passes the right data?
- # 06:45 <Mohsen_Hassani> iosolidar, I have been checking line by line, but no luck! It's been three days (I'm not that experienced in Linux though!)
- # 06:45 <Mohsen_Hassani> iosolidar, it does! And it shows the characters in firebug too. It has 4 characters every time the page refreshes.
- # 06:45 <nirakara> how does one use/pass context variables to javascript files which are called in a template?
- # 06:45 <iosolidar> nirakara: i use <script type="text/javascript"> var some_var = "{{ some_var }}"; </script>
- # 06:45 <iosolidar> or if performance is not that important you can serve javascript with a view
- # 06:45 <Mohsen_Hassani> nirakara, I don't know how to do it in a separate javascript file, but I'm using javascript in HTML files, so I can use template tags {{ }}
- # 06:45 <nirakara> iosolidar, your solution seems best
- # 06:45 <nirakara> but, what if it is a separate file?
- # 06:45 <iosolidar> you include the file under the variables you want to define
- # 07:15 <maxwellbrown> trying to figure out why my project works fine on my local django server, but isn't being served with Apache + mod_wsgi - anyone up for troubleshooting with me?
- # 07:15 <wasmith> hey, can you tell me why i might be getting this error? 'QuerySet' object has no attribute 'len'
- # 07:30 <wasmith> this is the way i'm getting the QuerySet, ticket = feedbackItems.objects.filter(ticket_id=decoded[0:decoded.__len__()-1])
- # 07:30 <FunkyBob> maxwellbrown: does it complain that it can't find modules?
- # 07:30 <FunkyBob> wasmith: why call __len__ instead of len(decoded)?
- # 07:30 <maxwellbrown> FunkyBob: just getting 500 errors - trying one more time on my own. the default wsgi.py and my virtual host seem not be playing nice
- # 07:30 <wasmith> FunkyBob: that wasnt where it was erroring, it was erroring on: if ticket.len() == 0:
- # 07:30 <wasmith> i.e. trying to see if any results are being thrown back
- # 07:30 <FunkyBob> wasmith: again... why are you calling len() on it?
- # 07:30 <FunkyBob> either len(qs) or qs.count()
- # 07:30 <FunkyBob> if you want to know if there are _any_ results, use exists()
- # 07:30 <FunkyBob> qs.exists()
- # 07:30 <wasmith> ah i see
- # 07:30 <FunkyBob> however... all of these cause an extra query you can do without
- # 07:30 <FunkyBob> what language are you coming from?
- # 07:30 <wasmith> Java, mainly
- # 07:30 <FunkyBob> fits
- # 07:30 <wasmith> bits of C and C++ here and there
- # 07:30 <FunkyBob> in python if you want the length of something, use len(foo)
- # 07:30 <FunkyBob> as to the efficiency...
- # 07:30 <FunkyBob> does your code have anything to do differently if there's no items?
- # 07:30 <FunkyBob> or can it work with "a set of 0
- # 07:30 <FunkyBob> "?
- # 07:30 <wasmith> well, its a feedback system
- # 07:30 <wasmith> based on a ticket-id
- # 07:30 <wasmith> so if the feedback form has already been answered for a ticket
- # 07:30 <wasmith> it need to stop them from answering agaian
- # 07:30 <wasmith> *again
- # 07:30 <FunkyBob> ah, ok
- # 07:30 <FunkyBob> do you have the ticket instance already?
- # 07:30 <wasmith> yeah, its passed in the url in an encoded form, so its decoded then checked to see if its a valid ticket
- # 07:30 <wasmith> then if it is they get shown the form
- # 07:30 <FunkyBob> instance? or id?
- # 07:30 <FunkyBob> surely you're not passing the instance in the url... just the id
- # 07:30 <wasmith> yeah just an id number
- # 07:30 <FunkyBob> ok
- # 07:30 <wasmith> the ticket is something external to the app
- # 07:30 <FunkyBob> so feedbackItems has a 1to1 to ticket?
- # 07:30 <wasmith> so its just an id number
- # 07:30 <FunkyBob> ahg, ok
- # 07:30 <FunkyBob> well, you might find it easier to use exist()
- # 07:30 <FunkyBob> or get() with a try/except block
- # 07:30 <wasmith> i'll try exist
- # 07:30 <wasmith> one moment
- # 07:45 <FunkyBob> as in "if mymodel.objects.filter(...).exists():"
- # 07:45 <cuzzo> Is there any way to setup your site so that you can dynamically add meta tags / css / js from inside the view without needing to create a separate template to do that.
- # 07:45 <wasmith> awesome
- # 07:45 <wasmith> that works a charm
- # 07:45 <wasmith> thanks a lot
- # 07:45 <FunkyBob> cuzzo: admin does that
- # 07:45 <FunkyBob> wasmith: np
- # 07:45 <cuzzo> FunkyBob, as in it provides a framework for that or as in it's a good example for how to do it?
- # 07:45 <FunkyBob> example
- # 07:45 <FunkyBob> it might help if you could elaborate on your goals
- # 07:45 <cuzzo> FunkyBob, I want to basically be able to run a function like add_js('path/to/js') and then that js will be included--without having to create a separate template just to do that.
- # 07:45 <cuzzo> FunkyBob, I was thinking about extending the Context class, but that seems like a bad idea.
- # 07:45 <FunkyBob> why would you extend it?
- # 07:45 <FunkyBob> just add context
- # 07:45 <cuzzo> FunkyBob, yeah, I wouldn't need to extend it. I guess it's not such a bad idea.
- # 07:45 <FunkyBob> you could easily have a context processor that adds your default set of JS/CSS
- # 07:45 <FunkyBob> and then your view can manipulate that list once you have your context
- # 07:45 <cuzzo> FunkyBob, yeah, that's what I was thinking. It seems like it's not such a bad idea >.< Thanks,
- # 07:45 <FunkyBob> in fact... that would then make it easy for a tool to build a combined/minified version of each
- # 08:15 <nirakara> how does one use/pass context variables to javascript files which are called in a template?
- # 08:15 <FunkyBob> you don't
- # 08:15 <nirakara> nirakara, how do i get data from django to a js file?
- # 08:15 <nirakara> *FunkyBob :/
- # 08:15 <FunkyBob> ah, well
- # 08:15 <FunkyBob> you could embed a <script> tag in your template with the data you want
- # 08:15 <FunkyBob> remember -- the JS is loaded as a separate file, in a separate request, if you use <script src=...
- # 08:15 <nirakara> So embed the entire js in the template -- option one. Suppose i am using <script src="myjs.js" /> ? is there another option?
- # 08:15 <FunkyBob> they're not "called" in the template
- # 08:15 <nirakara> what is the correct terminology?
- # 08:15 <nirakara> referenced?
- # 08:15 <FunkyBob> referenced is good
- # 08:15 <nirakara> so, to rephrase, how do i get data from django to a js file which is referenced in a template?
- # 08:15 <FunkyBob> but the client, if it loads them, does so separately.. in a separate HTTP request
- # 08:15 <nirakara> there's the rub!
- # 08:15 <FunkyBob> embed a script block with the data you need
- # 08:15 <FunkyBob> what sort of data are you trying to pass?
- # 08:15 <nirakara> FunkyBob, a list of numbers to populate a graph
- # 08:15 <FunkyBob> and you can't load them via AJAX?
- # 08:15 <FunkyBob> then you could refresh the numbers easily, too :)
- # 08:15 <nirakara> FunkyBob, i'm new at this -- could you point me at some documentation as to what you mean by "load via AJAX"? and/or provide an example of what you mean by "embed a script block with the data you need"?
- # 08:30 <FunkyBob> nirakara: wow... so new you don't even know what AJAX is?
- # 08:30 <FunkyBob> nirakara: it's basically getting your JS to make a request
- # 08:30 <FunkyBob> as for embed a script block.... <script type="javascript"> var data_points = {{ myvar }}; </script>
- # 08:30 <FunkyBob> but make sure you've JSON encoded your data
- # 08:30 <nirakara> FunkyBob, thanks for the tips, i'll get googling. Ajax sounds awesome!
- # 08:30 <nirakara> so i don't need to wait for a request from the user :D
- # 08:45 <theCeres> Hello! i have a funny problem...
- # 08:45 <theCeres> here's my stackoverflow post http://stackoverflow.com/questions/10468646/django-python-strange-no-module-named-module-name
- # 08:45 <theCeres> can someone help me ? Thanks in advance
- # 08:45 <amine> Hey
- # 08:45 <theCeres> hello
- # 08:45 <amine> someone's using my nickname, interesting
- # 08:45 <endra> Much better :P
- # 08:45 <endra> Alright, so I was thinking of setting up a special development environment and I am looking for insight from someone who has done something similar
- # 08:45 <endra> I have multiple locations where I work and from time to time I want to load up the environment on a random laptop/machine without actually having to install anything more than, lets say, a text editor
- # 08:45 <endra> I'm thinking of getting a cheap cloud server, installing everything on it, and mounting the git repo cloned on the cloud server to the machine I want to develop on. This way, any unpushed branches, etc. remain on the cloud server as well as the whole dev environment
- # 08:45 <endra> Any pros/cons of this idea and has anyone done something similar? I think it will benefit me because I develop on different flavors of linux as well as OS X
- # 08:45 <endra> By "mounting the git repo" I mean mount the folder that contains the .git as if it is a local folder.
- # 09:15 <nirakara> what's the equivalent of a @login_required decorator for a class based view derived from a generic view?
- # 09:30 <zxq9> endra: Regarding your portable text environment; You're way overthinking things. If you have a computer at your home or office, you could just ssh into it and do whatever you want. No need for cloud bs or anything else fancy.
- # 09:30 <endra> zxq9: it's not "cloud bs", I realize I don't have a server that I can use reliably :)
- # 09:30 <zxq9> endra: You don't have access to any old hardware at all?
- # 09:30 <zxq9> endra: Its almost always cheaper to build a really tiny/lightweight system or repurpose some hardware that was headed for the recycle shop than to get a paid account somewhere just for this.
- # 09:30 <endra> zxq9: what happens if it goes down? What happens if something goes wrong and I can't access it? Do I simply not work? The projects I am working on cannot tolerate downtime which is why I prefer using a real hosting service. That is beyond the point, though: I am not asking about where to host it but I am asking about the setup itself and if anyone has used it and what feedback they might have.
- # 09:30 <endra> Also, I do not use shell editors
- # 09:30 <zxq9> endra: Then you're not asking about a dev environment, but production, and that's a different story entirely.
- # 09:30 <endra> Seriously? That's not a production environment lol
- # 09:30 <zxq9> endra: "The projects I am working on cannot tolerate downtime..." sounds like production, not dev. but meh. Anyway, good luck.
- # 09:30 <endra> zxq9: it doesn't serve clients, so it is not production. I develop on it, so it is development environment. Instead of saying "it cannot tolerate downtime" I meant "I don't care about $10/month if I can remotely access/manage it if something goes wrong with the hardware/internet/nat/million other problems that can occur if you are hosting it at home".
- # 09:30 <endra> zxq9: Anyways, I appreciate the help. If you've done a similar environment, I'd like to hear some feedback on how it worked out
- # 09:45 <zxq9> endra: I've never done a cloud account, no, but we have servers available from our office we use for all sorts of things over ssh and we've never had an issue. Ever. We're pretty big on hardware hygiene and keep our stuff up to date, though.
- # 09:45 <zxq9> endra: A cloud account probably wouldn't feel much different. Just be picky when you choose what type of instance to buy -- since you're paying you can be as picky as you want, so get something nice.
- # 09:45 <endra> zxq9: I realize that. I'm getting the feeling that we aren't talking about the same thing. I'm just looking for a machine that hosts my development environment. Imagine I go to some computer I've never developed on, and then I simply mount the source directory (over SSHFS or something), then I also SSH into it and start the dev server on a public (secure) interface. I would be able to develop
- # 09:45 <endra> from any machine I want without installing anything other than my favorite editor and an ssh client.
- # 09:45 <endra> zxq9: aside from where it is hosted, I was simply inquiring if someone had done a similar setup and if there are any downsides to it that anyone could think of
- # 09:45 <endra> I'm going to try it out tomorrow either way because I can't think of any downsides (except if the internet goes down, then I cannot develop)
- # 09:45 <zxq9> endra: My point is that mounting the source directory is a needless complication. Your server (or hosted instance, whatever, no difference here) can provide you with its native desktop via VNC, or shell via SSH, or whatever, and make your site available at any arbitrary address you want.
- # 09:45 <zxq9> endra: There is no need for mounting anything remotely so long as you can make a shell connection. You can tunnel the interface for your favorite graphical IDE if you aren't comfortable with shell tools, export the entire desktop remotely if that's how you roll, whatever. But a remote mount is a needless complication.
- # 10:00 <zxq9> endra: But it sounds like you've got your mind made up already.
- # 10:00 <endra> zxq9: yes that is also a possibility but then you'd need a larger, more powerful server and a faster internet connection. Also, it would still not feel 100% the same as having a local editor running. I think that might be a bit overkill. Perhaps in a few years when servers become cheaper and internet becomes faster :)
- # 10:00 <zxq9> endra: Um... powerful server? One of my servers is on an E350 and its plenty fast -- and it doesn't even have any moving parts (no fans, SSD). There is literally nothing that can break on it unless the power goes crazy, and its sub-netbook strength. You're similarly off target with regard to bandwidth. Remote mounts are a lot more process and bandwidth heavy than shells, every time.
- # 10:00 <zxq9> endra: You asked for advice based on experience, and I'm giving you advice based on doing just these sort of things since the late 80's -- back when bandwidth was literally slower than my typing speed.
- # 10:15 <endra> zxq9: .. but you said the server can provide a native desktop via VNC, which requires more memory than a $10 cloud server, and also more bandwidth to transfer it over. That is what I was referring to. Anyways, I am heading to bed. I really appreciate your help. Perhaps we can talk more tomorrow!
- # 10:15 <gtfx669> hey, is it possible to use choices as parent link in django-mptt?
- # 10:30 <zxq9> gtfx669: No idea what mptt is, but in Django, yes. You just populate the choices field in the form with whatever you want -- and that can be possible parent relations also. (I think this is what you're asking.)
- # 10:30 <narkeeso> Hey guys, I'm trying to get my form display some prefilled data, initial doesn't seem to be working - what am i doing wrong? https://gist.github.com/3dbbf80d1eecd33a726e
- # 10:30 <zxq9> gtfx669: OK, looked up mptt. I suspect that mptt would make defining the possibilities easier, but the principle remains the same: choices is a list that can be arbitrarily built.
- # 10:30 <zxq9> narkeeso: initial needs to be a dictionary, not a queryset.
- # 10:45 <narkeeso> zxq9: i'm still learning, but how can I pass it a dictionary of the queryset?
- # 10:45 <narkeeso> I guess that's what my error meant when it's not iterable.
- # 10:45 <zxq9> narkeeso: So something like "genre = {'genre': get_object_or_404(BandGenre, pk=band_id).genre}" and then BandGenreForm(initial=genre) would work
- # 10:45 <zxq9> narkeeso: You need to create a dict, beacuse there isn't one to begin with, which is what I'm doing in the line above in a sort of overly compact way.
- # 10:45 <nanonyme> zxq9, would ValuesQuerySet work?
- # 10:45 <gtfx669> zxq9: thanks, i am looking on how to make it done
- # 10:45 <nanonyme> it is, after all, a dict for all useful purposes
- # 10:45 <zxq9> narkeeso: You need to put a key, 'genre' in a dict and that key needs to point to a Python string that contains the genre data
- # 10:45 <narkeeso> zxq9: interesting, is there any docs that i might be able to study further so i can understand what you did?
- # 10:45 <zxq9> narkeeso: The quickest way to understand it is to just open the shell up and mess around.
- # 10:45 <glosoli> http://dpaste.org/LGocI/ anyone can check this one ?
- # 10:45 <zxq9> narkeeso: Try things like "print BandGenre.objects.get(pk=foo).genre" and see if it returns a string or not. If it does (should, I think) then you're on track for data you can use in the dict passed to Form(initial=foo)
- # 10:45 <nanonyme> yeah, I actually think genre = get_object_or_404(BandGenre, pk=band_id).values('genre') would work as well
- # 10:45 <narkeeso> zxq9: let me try messing around with it, and i'll try playing with nanonyme version as well
- # 10:45 <narkeeso> thank you for the assistance
- # 10:45 <zxq9> nanonyme: So play with it in the shell to make sure, then play with it in a dictionary construction (or, worst case, just assign a variable and then load the variable into a dict declaration), and you're good to go.
- # 10:45 <zxq9> Anyway, the form here is expecting a dict with a key 'genre' that will contain a string. Whatever that string is will get displayed. If its not a string I think it'll just be blank.
- # 10:45 <narkeeso> it might return pks since they are just foreignkeys?
- # 10:45 <zxq9> And honestly using the word "genre" so much is pretty confusing. I'd maybe call it something else.
- # 10:45 <zxq9> BandGenre.objects.get(id=foo) is the same. It returns an instance of your model object.
- # 10:45 <nanonyme> narkeeso, it will probably return something completely useless if it it's a related object that doesn't have __unicode__ method defined
- # 10:45 <zxq9> BandGenre.objects.get(id=foo).genre should return the genre attribute (variable declared in your model) that contains the string of whatever the Genre model returns.
- # 10:45 <narkeeso> nanonyme: it's returning <django.db.models.fields.related.ManyRelatedManager object at 0x106c3ffd0>
- # 10:45 <zxq9> Unless you dn't have a __unicode__() method defined
- # 10:45 <zxq9> on Genre
- # 10:45 <zxq9> which it looks like you don't.
- # 10:45 <zxq9> So can you paste the Genre(models.Model) ?
- # 10:45 <narkeeso> zxq9: it's in the Gist
- # 10:45 <nanonyme> narkeeso, heh, relation to other direction
- # 10:45 <narkeeso> i'm not sure how to put M2M in unicode
- # 10:45 <zxq9> hehe... duh...
- # 10:45 <nanonyme> narkeeso, you don't. are you sure this is the best way to model this?
- # 10:45 <zxq9> Hmmm... using an M2M here can be tricky. I didn't notice that at first.
- # 10:45 <zxq9> I might want to rethink the data model first.
- # 10:45 <narkeeso> nanonyme: I'm not sure, i didn't design the database
- # 10:45 <narkeeso> it's legacy
- # 10:45 <narkeeso> I also thought it was weird setting it up this way
- # 10:45 <narkeeso> Didn't seem very Django-like
- # 10:45 <nanonyme> narkeeso, proxy models or unmanaged models can help hack things up but that sounds a bit unintuitive modeling at any rate
- # 10:45 <zxq9> Can a single band have many genres? I think that is the point of the M2M here, but its awkward. but not impossible to work out.
- # 10:45 <narkeeso> zxq9: yes, a single band can be assigned more than 1 genre
- # 10:45 <nanonyme> or even just a method to model which joins names of all genres or just picks one
- # 10:45 <zxq9> Anyway, how do I find the Genre() class in the gist? I'm not familiar with navigating this.
- # 10:45 <narkeeso> refresh the gist zxq9
- # 10:45 <zxq9> That's a really odd max_length...
- # 10:45 <narkeeso> zxq9: it was what inspectdb spit out
- # 10:45 <narkeeso> like i said, it's a legacy database converted to django, i'm in the process of converting an app
- # 10:45 <zxq9> Anyway, we're trying to get at the .name attribute, and will probably need to iterate. These days I always have to tack extra information to my junction tables, so lemme check something (and then I can probably give you a solution).
- # 11:00 <narkeeso> zxq9: thanks for the willingness to tackle my problem, I've been running circles around how to work with M2M in django
- # 11:00 <zxq9> narkeeso: Its a little weird because they can return several things. Most likely the solution will involve iterating through the returned list to build a longer string for the dict.
- # 11:00 <glosoli> anyona can suggest me something for MEDIA files ? Getting 404 error for them, MEDIA_URL and MEDIA_ROOT it set properly, URLs.py is also configured for media files
- # 11:15 <zxq9> narkeeso: What do you get from BandGenre.objects.get(pk=foo).genre.all() ?
- # 11:15 <narkeeso> [<Genre: Classical>]
- # 11:15 <narkeeso> zxq9: ^
- # 11:15 <zxq9> narkeeso: And from BandGenre.objects.get(pk=foo).genre.all()[0].genre ?
- # 11:15 <zxq9> narkeeso: And from BandGenre.objects.get(pk=foo).genre.all()[0].name ?
- # 11:15 <zxq9> narkeeso: correction
- # 11:15 <narkeeso> u'Classical'
- # 11:15 <narkeeso> bingo???
- # 11:15 <zxq9> narkeeso: Yes
- # 11:15 <narkeeso> i was just reading up on how to iterate through M2M
- # 11:15 <zxq9> narkeeso: Unless you want the "genre" thing in the form to be a selection or radio box or whatever
- # 11:15 <narkeeso> i didn't get as far the [0].name part though
- # 11:15 <ticketbot> https://code.djangoproject.com/changeset/0
- # 11:15 <zxq9> lol btw, any un-prefixed [123] thing in here triggers the ticketbot.
- # 11:15 <ticketbot> https://code.djangoproject.com/changeset/123
- # 11:15 <zxq9> see
- # 11:15 <narkeeso> oh haha
- # 11:15 <zxq9> narkeeso: Anyway, what is the purpose of the form? I mean, in BandGenreForm what widget does the field 'genre' come out as?
- # 11:15 <narkeeso> zxq9: http://cl.ly/3r2s2q0g3n3z002m150e
- # 11:15 <narkeeso> basically just select from pre-defined genres
- # 11:15 <narkeeso> set by the admins
- # 11:15 <narkeeso> errr editorial
- # 11:15 <narkeeso> so is the [ 0 ].name a dictionary? grabbing the zero based entry of name?
- # 11:15 <zxq9> narkeeso: Then you'll probably want a list of tuples. I think in those lists the value is the pk/id and the string is the value from Genre.name
- # 11:15 <zxq9> narkeeso: Actually its a list of objects.
- # 11:15 <narkeeso> initial won't accept an object huh?
- # 11:15 <narkeeso> it wants strings?
- # 11:15 <zxq9> narkeeso: So what you would need to do is make the dictionary going to form(initial=dict) have a key 'genre' that points to a list of tuples.
- # 11:15 <narkeeso> a dict of strings that is
- # 11:15 <zxq9> narkeeso: Doin a list comprehension is easy here, but so is a for loop over iterables.
- # 11:15 <zxq9> narkeeso: Lemme write some pasta...
- # 11:15 <narkeeso> this is very helpful, learning a lot too
- # 11:30 <zxq9> narkeeso: OK, I wrote it a few ways. Hopefully that will illustrate what is going on: http://fpaste.org/hn26/
- # 11:30 <zxq9> narkeeso: Play with those constructions in the shell a bit to understand them better. Do it with other objects from your Django app and see what relations can lead where.
- # 11:30 <narkeeso> this is really great zxq9, i'm pretty sure i can figure it out from here
- # 11:30 <narkeeso> thank you
- # 11:30 <zxq9> No worries. :-)
- # 11:30 <narkeeso> and you make no assumptions as to my skill level in python/django
- # 11:30 <narkeeso> excellent teacher :)
- # 11:30 <zxq9> There are a lot of folks in this room who know way more about the details of widgets/form population than I do. If you get into sticky problems be patient in here and one of the real wizards will eventually find you.
- # 11:30 <narkeeso> yes, luckily I'm able to get away with using ModelForm for now which does a lot of that for me but I'm familiar with widgets in forms
- # 11:30 <zxq9> narkeeso: I appreciate the compliment. I'm still very new to Python myself. (background is C, bash, lisp(s))
- # 11:30 <narkeeso> my background is design/xhtml/css/javascript, django is teaching me python from scratch
- # 11:30 <narkeeso> it takes me longer to understand some concepts but if i take it slowly, it's not so bad
- # 11:30 <zxq9> narkeeso: Hrm... I'll probably have css questions for you someday. hehe. I *hate* web design, but Django provides a very good way to create reporting interfaces or trivial front ends for databases. But my stuff is really ugly because I don't know much about doing good CSS.
- # 11:30 <zxq9> narkeeso: You
- # 11:30 <zxq9> narkeeso: 'lll have to watch yourself. Python and the unix shell are seductive and before you know it you'll be a for-real programmer. Oh noes!
- # 11:30 <zxq9> narkeeso: You're already on the path to the darkside, my friend.
- # 11:30 <narkeeso> it's hard to stop when the documentation for django is so well written and the strong community in irc helps as well
- # 11:30 <zxq9> narkeeso: If you ever get curious, look into the deeper features of Postgres. Its a really amazing system -- and sadly very few people use much of its functionality, usually because they either think that all databases are the same (as in ~mysql) or because mature databases seem intimidating at first and they'd rather have a framework do it all for them.
- # 11:30 <zxq9> narkeeso: The Django docs are pretty great. They spent some time doing that right. So did the Postgres project. They are a good match.
- # 11:30 <narkeeso> zxq9: i'd prefer to try using postgres but this legacy database is mysql and the database guys want to keep it that way
- # 11:30 <zxq9> narkeeso: lol. Well, on another project or just tooling around you can explore Postgres. Its really a night/day type difference if you want to do anything non trivial that requires normalized data (in other words, a situation where you can't afford to be afraid of JOINs)
- # 11:45 <zxq9> narkeeso: Not that most Django apps have very deep data models -- but if you get curious it can provide weeks of entertainment learning about how much stuff can really be done right in data.
- # 11:45 <zxq9> narkeeso: Anyway, have fun. I've got to run the dog to the vet... and buy beer.
- # 11:45 <narkeeso> zxq9: sure np, have a good one! thanks again
- # 11:45 <nanonyme> narkeeso, 1.4 is starting to be so powerful that using it on MySQL MyISAM would be a total waste of its functionality :)
- # 11:45 <narkeeso> nanonyme: if i knew why, i'd probably try to advocate switching to the database guys but i'd have no solid argument as of now :)
- # 11:45 <nanonyme> narkeeso, well, if they have any sense, they have MySQL with InnoDB tables
- # 11:45 <nanonyme> As in, since otherwise you're not actually dealing with a database that tries to be ACID at all.
- # 11:45 <narkeeso> nanonyme: do you want to put that in laymans terms to someone who doesn't know much about databases :D?
- # 11:45 <nanonyme> narkeeso, last I checked foreign key constraints were among the features MyISAM doesn't support
- # 11:45 <nanonyme> MyISAM is for situations where you want SQL syntax to some database in which integrity rules are fairly nonexistent and tables aren't transaction-safe.
- # 11:45 <nanonyme> (it *was* fairly used nonetheless because it's bloody fast)
- # 11:45 <narkeeso> nanonyme: that must explain the data corruption recently
- # 11:45 <narkeeso> :D
- # 11:45 <nanonyme> Well, if the database guys are actually using MyISAM for anything which involves money, replacing them with people with some clue could be a good course of action.
- # 11:45 <narkeeso> nanonyme: I just pinged them and they said they are using 1 DB with MyISAM and the other is InnoDB
- # 11:45 <narkeeso> hopefully it won't be an issue for this app
- # 12:00 <Jackneill> is there support for python 3?
- # 12:00 <glosoli> nah
- # 12:00 <glosoli> there will be in the future for sure :)
- # 12:00 <Jackneill> i've seen the website but i didnt find anythong
- # 12:00 <glosoli> Jackneill: it takes time for project that big to be ported to py3 while keeping backwards compatibility
- # 12:00 <glosoli> :)
- # 12:00 <Jackneill> i last asked it last year :(
- # 12:00 <Jackneill> yep
- # 12:00 <glosoli> Jackneill: this year we might see it for py3 :) what's wrong with py2.7 ?
- # 12:00 <Jackneill> i dont know py3 yet
- # 12:00 <Jackneill> and i dont want to learn an old version
- # 12:00 <Jackneill> that will be unsupported later
- # 12:00 <glosoli> Jackneill: it isn't old, it get updates, so it's maintained
- # 12:00 <glosoli> :)
- # 12:00 <nanonyme> Just learn Python 2.7, you'll be fine with it for years.
- # 12:00 <glosoli> Jackneill: I came to django from Py3 most of the users don't feel the difference unless they do some py3 specific things which you most likely dont
- # 12:00 <Jackneill> you might be true
- # 12:00 <Jackneill> hm ok thanks
- # 12:00 <cheshair> Hi! I am having problems with blocktrans: {% blocktrans with account.activity_field as activity_field %}{{ activity_field }}{% endblocktrans %} doesn't work
- # 12:00 <cheshair> i18n is loaded
- # 12:00 <cheshair> no error is given
- # 12:00 <cheshair> just the output is not translated
- # 12:15 <sec_> in template .. how check {% if NOT(obj) %} << obj is not exist?
- # 12:15 <cheshair> i ran makemessages and compilemessages as expected
- # 12:15 <cheshair> and restarted development server
- # 12:15 <FunkyBob> sec_: {% if not obj %}
- # 12:15 <FunkyBob> sec_: is as close as you'll get
- # 12:15 <sec_> FunkyBob: oh let me try
- # 12:15 <sec_> FunkyBob: thanks
- # 12:15 <nanonyme> sec_, note that that's not existence check but falseness check
- # 12:15 <nanonyme> So if bool(obj) can return false for that object, that will also match.
- # 12:15 <nanonyme> (afaik)
- # 12:15 <FunkyBob> yeah... it'll test for falsey-ness
- # 12:15 <FunkyBob> so 0, '', {}, () and [] are all falsey
- # 12:15 <FunkyBob> as are None and False
- # 12:15 <wfq> hi guys
- # 12:30 <wfq> can anyone please let me know what is going on here? I can't find what the problem is but my static files are not served by Apache. Whenever I try to go to the static URL I get a page not found from Django (http://dpaste.com/743646/). Apparentl this guys has got exactly the same configuration as me except for different folders but it worked for him: http://stackoverflow.com/questions/5682809/
- # 12:30 <wfq> django-static-file-hosting-an-apache
- # 12:30 <wfq> I am offside. I don't know what else to do? any suggestion?
- # 12:45 <jdo_dk> Does anyone know of a way to create a change password function, but it should be done through ajax ?
- # 12:45 <FunkyBob> same way as it's already done?
- # 12:45 <FunkyBob> but respond with something your AJAX tool can read
- # 12:45 <jdo_dk> FunkyBob: Today i just use the "default" change_password view.
- # 12:45 <jdo_dk> FunkyBob: And i just create the change_password.html and change_password_done.html templates
- # 12:45 <cheshair> Hi! I have a tabularinline in my admin panel. At the end of item listing I am shown a "Add new item". I do not want that. Any tips?
- # 12:45 <FunkyBob> jdo_dk: and you can use the change password form and set password method on User.... in your own ajax view.
- # 12:45 <cheshair> setting max_num=0 in my admin.py did the trick. Will it have any downside effect?
- # 12:45 <FunkyBob> cheshair: nope... that'l do it
- # 12:45 <cheshair> FunkyBob: thank you
- # 12:45 <jdo_dk> FunkyBob: Will try look at set_password, thanks.
- # 12:45 <cheshair> FunkyBob: again in my tabularinline, each listed item is preceded by "OrderItem object"... is there any way I can get rid of that?
- # 12:45 <FunkyBob> cheshair: define a __unicode__ on your model?
- # 12:45 <cheshair> FunkyBob: ok, i'll do that way
- # 13:00 <cheshair> FunkyBob: hm... i would like the "orderitem object" line not to appear at all
- # 13:00 <cheshair> FunkyBob: is that feasible without hacking on template?
- # 13:00 <cheshair> orderitem is the name of my tabularinline object of course
- # 13:00 <FunkyBob> why are you so eager to customise Admin?
- # 13:00 <FunkyBob> it's not like regular users see it
- # 13:15 <cheshair> FunkyBob: regular users won't by my client will :-) so i would like to have it as clean as possible
- # 13:15 <cheshair> my client as an admin
- # 13:15 <cheshair> http://stackoverflow.com/questions/5086537/how-to-omit-object-name-from-djangos-tabularinline-admin-view
- # 13:15 <cheshair> ^ I found this
- # 13:15 <cheshair> css might be the right way to go
- # 13:15 <lynx_r> hi all, how to upload file in django project to get a file accessable via site.com/file.html?
- # 13:15 <apollo13> not possible just by uploading
- # 13:15 <cheshair> yep, using that css hack did the trick
- # 13:15 <apollo13> cheshair: don't bother unless the client complains
- # 13:15 <cheshair> apollo13: thanks! do always scold me when i end up being too nitpicking
- # 13:15 <cheshair> :-)
- # 13:15 <apollo13> well I figured it's less time consuming since you never know what the clients want ;)
- # 13:30 <cheshair> apollo13: i totally agree
- # 13:30 <ironm> Hello. Please allow me one question. I have installed django 1.4 and have created a local project in my home directory like: /home/ironm/projectx/ (due to the django.pdf tutorial part)
- # 13:30 <ironm> I am not sure where is the MEDIA_ROOT directory .. when installing some django apps there are instructions like:
- # 13:30 <ironm> * Symlink or copy `imagestore/static/imagestore.css` to your `MEDIA_ROOT`, or write youre own style (staticfiles supported as well).
- # 13:30 <brusca> you can set your media directory location in the settings.py file of your project
- # 13:45 <ironm> the setting in ~/projectx/projectx/ I have the setting like: MEDIA_ROOT = ''
- # 13:45 <ironm> brusca, does it mean it is a local directory like: ~/projectx/ ?
- # 13:45 <ironm> I mean ~/projectx/projectx/settings.py
- # 13:45 <ironm> I am confused
- # 13:45 <brusca> yes Im not sure what the default will be. You can specify both the physical media location in MEDIA_ROOT and the url in MEDIA_URL
- # 13:45 <ironm> thanks a lot brusca. I will try
- # 13:45 <easytiger> if i have a nav bar where i highlight the current section say like class='active'.. what's the best way of communicating that from the django POV. Because the nav bar is in a base.html. will i have to pass a var in each view?
- # 13:45 <easytiger> im sure its a common problem
- # 13:45 <schinckel> easytiger: I wrote a template tag that generates each menu item: it also inspects the request object and marks with an "active" class what it thinks is the current url.
- # 13:45 <schinckel> https://bitbucket.org/schinckel/django-menus
- # 13:45 <schinckel> (It also will only display menu items the logged in user will be able to view)
- # 14:00 <ironm> is there a kind of website example app-template for django 1.4?
- # 14:00 <ironm> or just a tutorial how to create new website using django 1.4
- # 14:00 <ironm> with all the stuff like menus, multilanguage support, serach engine etc ?
- # 14:00 <ironm> search
- # 14:00 <ironm> I have created the polls app (due to django.pdf) but there (tutorial part) is no further info about creating menus and all the stuff one needs for a website
- # 14:00 <ironm> or should I use django-cms to create a website ?
- # 14:00 <ironm> currently I use TYPO3 CMS for my websites *but" I am not quite happy with it (due to security problems in php)
- # 14:15 <king313> ironm, as far I know, there are not
- # 14:15 <king313> but I am a newbie
- # 14:15 <king313> Django is very well documentated
- # 14:15 <king313> I am planning to do a practice in Django
- # 14:15 <king313> which will have some of the features that you asked
- # 14:15 <king313> I have no problem in giving you the bitbucket link when it is finished
- # 14:15 <ironm> king313, thank you. It would be great :)
- # 14:15 <ironm> maybe there are some example apps with already created menu examples etc ...
- # 14:15 <king313> yes, I am pretty sure that if you search you will found it
- # 14:15 <ironm> I am looking around for two days already
- # 14:15 <king313> anyway, what is the part with menus that you find trouble?
- # 14:15 <ironm> king313, may I ask if you use django-cms ?
- # 14:15 <king313> No, I code directly with DJango
- # 14:15 <ironm> due to menu: first I would like to get an overview how such menus look like (django best practices)
- # 14:15 <king313> maybe Django-cms is what you need if you need to provide
- # 14:15 <king313> simple solutions very fast, and you don't want to be building the menu, registration systems and so
- # 14:15 <ironm> good idea. I should check django-cms again ..
- # 14:15 <ironm> thanks a lot king313 :)
- # 14:15 <ironm> anyway django makes a very good impression
- # 14:15 <ironm> .. and python code is much more easy to read or write compare to php
- # 14:15 <nanonyme> Plus Django being a framework forces you to write modular code whereas in PHP you easily result in script/URI style programming.
- # 14:30 <nanonyme> (some say there are proper PHP frameworks though)
- # 14:30 <ironm> yes nanonyme
- # 14:30 <king313> ironm, what really seduced me was the doc
- # 14:30 <ironm> king313, at least django.pdf is a very good reference (although the tutorial part is not completed now)
- # 14:30 <ironm> s/now/yet/
- # 14:30 <king313> don't know, I always use https://docs.djangoproject.com/en/1.4/ , then google, and then this channel
- # 14:30 <ironm> king313, it is the same content (https://docs.djangoproject.com/en/1.4/) as in django.pdf (1.4)
- # 14:30 <king313> cool! I can download it in a eReader format. I am going to place it in my Kindle so I can pick code while reading
- # 14:45 <ironm> king313, I use kindle DX to read django.pdf .. however the graphics are not displayed very well
- # 14:45 <king313> it is on ePub version too, I am trying with converting it to mobi and uploading to Kindle
- # 14:45 <ironm> king313, please let me know when you are successful. mobi will work probably better than a4 pdf
- # 14:45 <ironm> on my kindle DX
- # 14:45 <Ronnie> i have a problem with too many database connections (postgres): "FATAL: connection limit exceeded for non-superusers". My app involves a lot of threading,background processes and locking. What are the moments django creates a new database connection and when does django close the connection?
- # 14:45 <ironm> Ronnie, how many concurrent postgres connections does your pg config allows?
- # 14:45 <Ronnie> iron: 100
- # 14:45 <Ronnie> i did a stress test. but even after the test 97 connections were open
- # 14:45 <nanonyme> Ronnie, Django tends to create a new DB connection on each request afaik
- # 14:45 <Ronnie> nanonyme: and after the request is finised, the connection is closed?
- # 14:45 <nanonyme> Pretty much so, yes.
- # 14:45 <Ronnie> and what if the view starts a thread
- # 14:45 <Ronnie> does that thread create a new conenction or does it use the requests thread?
- # 14:45 <nanonyme> Don't start threads, use background processes with eg Celery
- # 14:45 <nanonyme> Well, most likely you end up with a connection that is never closed.
- # 14:45 <nanonyme> Since request ends -> DB connection closes; thread attempts to use DB -> new DB connection is spawned; thread is responsible for closing the DB connection.
- # 14:45 <Ronnie> and does Celery handle connections (open, close) automatic?
- # 14:45 <Ronnie> nanonyme: when a thread dies, doesn't it close the connection automatic
- # 14:45 <nanonyme> Ronnie, unless there are other threads still in the process, yes.
- # 14:45 <nanonyme> Otherwise no.
- # 14:45 <king313> ironm, 67%
- # 14:45 <nanonyme> Ronnie, don't use threads
- # 14:45 <ironm> king313, sounds good :)
- # 14:45 <Ronnie> nanonyme: ill have a look at Celery then. But why is it bad to use threads?
- # 15:00 <nanonyme> Ronnie, tends to result in rather messy implementations if you put background processes to same process as the web runner and it's not like threads would by any degree be cheap.
- # 15:00 <nanonyme> They're about as expensive in *nix as forking a new process for each executor.
- # 15:00 <nanonyme> (unless you do a lot of inter-thread communication which is where they're better)
- # 15:00 <yassine> hi all
- # 15:00 <nanonyme> And whereas with processes you'd get cleanups when a single process ends, with threads you only get cleanups when all threads end.
- # 15:00 <yassine> anyone of you guys happen to use django-multilingual with django 1-4 , i have some issue accessing models from the admin backend if they declar the inner class Translation as suggested by django-multilingual
- # 15:00 <nanonyme> Celery is kinda asynch-style programming anyway.
- # 15:00 <ironm> king313, would you mind to send me the .mobi version of django doc, please?
- # 15:00 <nanonyme> Ronnie, btw, are you using 1.4?
- # 15:00 <Ronnie> nanonyme: yes
- # 15:00 <nanonyme> Just started wondering whether https://docs.djangoproject.com/en/dev/releases/1.4/#database-connection-s-thread-locality changes things
- # 15:00 <Ronnie> altough i do not know if its the final version, could be one of the dev versions of a few months ago
- # 15:00 <Ronnie> im slowly migrating to virtualenv, so i can easily test new django versions
- # 15:00 <king313> ironm, done
- # 15:00 <king313> open me query and send your email
- # 15:00 <king313> or wait, I can put it in my dropbox folder
- # 15:15 <king313> ironm, and whoever could want a .mobi version of Django documentation in his eReader: https://www.dropbox.com/sh/4tn54smxqaxxf8x/CcE4fQn8g_/Django%20-%20Django%20Software%20Foundation.mobi
- # 15:15 <jfpoint> Can someone look over this error I?m getting? http://dpaste.org/uUQRU/
- # 15:30 <king313> jfilipe, I have a hard time reading deutch
- # 15:30 <king313> sorry, it was for jfpoint
- # 15:30 <king313> it's easier to get help when you have your code in english
- # 15:30 <jfpoint> Ok, wait a sec.
- # 15:45 <ironm> king313, thank you very much :)
- # 15:45 <yassine> anyone can suggest an alternative to django- multilingual app ?
- # 15:45 <jfpoint> king313 her it is shortened and in english. http://dpaste.org/hhTrj/ Might be that i forgot something while traslating it to this, but i dont think so.
- # 15:45 <king313> ACTION is taking a look
- # 16:00 <king313> http://stackoverflow.com/questions/1842389/reverse-for-with-arguments-and-keyword-arguments-not-found
- # 16:00 <king313> http://stackoverflow.com/questions/625047/django-newbie-reverse-not-found
- # 16:00 <king313> I have not fought with this error earlier, but maybe this links can help you
- # 16:00 <king313> a third, jfpoint: http://stackoverflow.com/questions/1326597/reverse-for-code-front-with-arguments-and-keyword-arguments-category-s
- # 16:00 <easytiger> schinckel: thanks, i shall take a look re the menu thing
- # 16:00 <jfpoint> sadly none of the things mentioned there helped :(
- # 16:00 <jfpoint> Could you maybe write how you would write that url function in the template based on my view and urls.py ?
- # 16:15 <jelkimantis> Hi!
- # 16:15 <jelkimantis> So I'm working on a project, and I added a url to the urls.py in the app I'm working on, but django is not finding it. I'm sure I'm doing something horribly wrong...
- # 16:15 <jelkimantis> The problem is I'm not sure what questions to ask...
- # 16:15 <ironm> jelkimantis, you have to acrtivate your app too .. (in settings.py)
- # 16:15 <ironm> jelkimantis, and restart the test sserver
- # 16:15 <ironm> server
- # 16:15 <jelkimantis> ironm -- ok... let me try deactivating and reactivating...
- # 16:15 <ironm> jelkimantis, how does the entry in your urls.py look like?
- # 16:30 <ironm> jelkimantis, it should be like:
- # 16:30 <ironm> urlpatterns = patterns('',
- # 16:30 <ironm> url(r'^polls/', include('polls.urls')),
- # 16:30 <jelkimantis> http://dpaste.com/743713/
- # 16:30 <ironm> ...
- # 16:30 <jelkimantis> it finds the first three entries just fine, but it's not finding the third.
- # 16:30 <jelkimantis> sorry, fourth.
- # 16:30 <jelkimantis> not third.
- # 16:30 <jfpoint> No one has a idea? Just one look: http://dpaste.org/hhTrj/ please.
- # 16:30 <ironm> jelkimantis, try to use another word than "test"
- # 16:30 <jelkimantis> okily dokily!
- # 16:30 <nanonyme> jelkimantis, btw, the URL pattern is a regexp. Dot means any character
- # 16:30 <jelkimantis> nanonyme: thanks! That is a helpful tip.
- # 16:30 <jelkimantis> unfortunately, changing to sample, its still not seeing the url.
- # 16:30 <jelkimantis> My 404 error shows me the first three urls as being valid (because I had debugging turned on)...
- # 16:30 <jelkimantis> So maybe this is my problem -- I am fiddling with the urls.py in an included app directory, and not my main directory. Will that make it not see any changes to urls.py?
- # 16:30 <ironm> jelkimantis, there are project/urls.py ... and app/urls.py
- # 16:30 <jelkimantis> does ./migrate.py runserver look at all of them every time?
- # 16:45 <ironm> I guess not always (depends on what files change)
- # 16:45 <jelkimantis> hmmm... let me try adding include to the other urls.py...
- # 16:45 <ironm> I have to reboot ... cul8r
- # 16:45 <jelkimantis> thanks!
- # 16:45 <jelkimantis> have fun
- # 16:45 <nanonyme> jelkimantis, yes, manage.py runserver does read all rules when it starts
- # 16:45 <jelkimantis> nanonyme: so any ideas why it's not seeing changes to my app/urls.py?
- # 16:45 <jelkimantis> FTR: it's not viewing my imported_app/urls.py -- I can force include it in my main_app/urls.py which makes ./manage.py runserver see it...
- # 16:45 <jelkimantis> Thanks for your help everyone!
- # 17:15 <abisson> anyone knows why I am getting this error with this code? http://dpaste.org/jpfWz/ ImproperlyConfigured: Storage module "common" does not define a "customStorage" class.... I mean, I am not drunk lol Why isn't this workign?!
- # 17:30 <iosolidar> common is a package not a module, the module is model.py
- # 17:30 <abisson> so common.models.customStorage?
- # 17:30 <iosolidar> try it out
- # 17:30 <abisson> iosolidar: but why in the case of the AUTH_PROFILE_MODULE I cant simply say: AUTH_PROFILE_MODULE = 'accounts.UserProfile' and UserProfile is a class within models.py?
- # 17:30 <iosolidar> because django is weird that way.. the documentation has an explanation i don't currently remember it
- # 17:30 <abisson> iosolidar: ohhh lol. So it works for the common.models.customStorage
- # 17:30 <abisson> iosolidar: wow lol
- # 17:30 <abisson> iosolidar: but I should (usually) do package.module.class?
- # 17:30 <iosolidar> yes.. it's normal python
- # 17:30 <abisson> yeah ok
- # 17:30 <abisson> iosolidar: cheers! thanks
- # 17:30 <iosolidar> :)
- # 17:30 <abisson> you familiar with django-storages (with Amazon S3?)
- # 17:30 <iosolidar> nope
- # 17:30 <abisson> ok :)!
- # 18:00 <iiie> abisson: hey! Sounds like you're making progress on your bucket changing storage
- # 18:00 <Squeige> So say I am making a site with django and I want it to have the ability to use english and spanish. How would I go about this task_
- # 18:00 <Squeige> ?
- # 18:00 <Pessimism> Squeige: https://docs.djangoproject.com/en/1.3/topics/i18n/
- # 18:00 <Pessimism> * https://docs.djangoproject.com/en/dev/topics/i18n/
- # 18:00 <iiie> abisson: I'm pretty sure the difference for storage needing the package vs auth profile module setting is auth profile module is run through django.db.models.get_model which takes 'APP.MODEL' (it is a model after all -- models in Django are commonly constrained to app_package.models so Django can guess very accurately where a given app.model is) whereas default file storage isn't a model and so could be in any module any where
- # 18:00 <Squeige> thank you reading...
- # 18:00 <Pessimism> wait, wrong link
- # 18:00 <Pessimism> this should do it: https://docs.djangoproject.com/en/dev/topics/i18n/translation/
- # 18:00 <Squeige> should I work on the site in all english and once completed I can figure out how to enable spanish?
- # 18:00 <Squeige> ah ok reading the other link now thanks
- # 18:00 <Pessimism> Squeige: Use trans and go for English as default in your source code like this: https://docs.djangoproject.com/en/dev/topics/i18n/translation/#internationalization-in-template-code
- # 18:00 <iosolidar> Squeige: yes, you should always develop in english
- # 18:00 <Squeige> still reading the previous link be right with you hehe,
- # 18:00 <iosolidar> it's much easier to convert to other lanauages afterwards
- # 18:00 <iosolidar> languages*
- # 18:00 <Squeige> ok sweet
- # 18:00 <Squeige> ty
- # 18:00 <Squeige> god feels like there is ssttill soo much to learn
- # 18:15 <iosolidar> there sure is :)
- # 18:15 <Pessimism> the good thing is that the time invested in learning it is paid back tenfold. Saves you a lot of time in the end
- # 18:15 <Squeige> almost to the point that it feels overwhelming
- # 18:15 <Pessimism> I am trying to define the default Site.get_current().domain in my local_settings.py, but I keep getting a Database.ENGINE error, when i do it for some reason. Would anyone know why, or what the best way to change the default site domain is?
- # 18:15 <iosolidar> do you have the admin app installed?
- # 18:15 <Pessimism> contrib.admin, yeah
- # 18:15 <iosolidar> you can edit it from there
- # 18:15 <Pessimism> I know, but I am doing a FOSS project, where it's better just to choose a default value for local projects
- # 18:15 <Pessimism> localhost is better than example.com
- # 18:15 <iosolidar> ./manage.py dumpdata could help
- # 18:15 <iosolidar> create the default values and than use loaddata when instaling
- # 18:15 <iosolidar> installing*
- # 18:15 <Squeige> I saw a good screen cast use and if conditional where if local_settings.py exists it uses that and if it does not it uses settings.py if thats what you are referring to
- # 18:15 <Squeige> I can pass you the link for that
- # 18:15 <Squeige> but I am still clueless so not sure if it might help you
- # 18:15 <Pessimism> nah, already have that, but cheers
- # 18:15 <Squeige> ok I tried hehe
- # 18:15 <Pessimism> I just need to put something in it that changes the default domain. The code I use creates a database error inexplicably
- # 18:15 <iosolidar> have you checked fixtures?
- # 18:15 <Squeige> <---- quietly sits in the corner of the room, and goes back to reading....
- # 18:30 <alicefreak> I am using model form factory. When I display the form in template. Its printing all the objects from the model. WIll you please help? thanks. Here is my code http://dpaste.org/yEpnL/
- # 18:30 <iosolidar> what's the problem?
- # 18:30 <alicefreak> iosolidar, uploading screenshot
- # 18:30 <alicefreak> iosolidar, if I use simple factory_form then result is http://imgur.com/gITG1. it is correct but if i use model form factory then result is http://imgur.com/Zf6vx
- # 18:30 <iosolidar> just remove the loop
- # 18:30 <alicefreak> iosolidar, removed but now form is empty
- # 18:30 <Squeige> so I just learned about html boilerplate,
- # 18:30 <iosolidar> don't remove it completely... :S
- # 18:30 <iosolidar> read the django documentation
- # 18:30 <Squeige> very cool concept, was wondering if there's any others
- # 18:30 <iosolidar> Squeige: link?
- # 18:30 <Squeige> http://html5boilerplate.com/
- # 18:30 <alicefreak> iosolidar, it worked. thanks alot :-)
- # 18:30 <iosolidar> :)
- # 18:30 <dknight> I was reading today that mod_python is abandoned. So, what is the preferred way of hosting python sites?/
- # 18:30 <iosolidar> wsgi
- # 18:30 <iosolidar> check out djangohosting.com
- # 18:45 <iosolidar> great services there
- # 18:45 <dknight> iosolidar: thanks
- # 18:45 <Squeige> I am planning on using https://www.arpnetworks.com/vps once I learn django
- # 18:45 <Squeige> as far as hosting goes
- # 18:45 <herrwolfe45> hi - I am trying to figure out a good way to only return objects relating to the user's account in every one of my views (found using request.user.get_profile().account and an account manager.) Would writing a mixin be the simplest and most DRY approach to add this functionality to the class based generic views?
- # 18:45 <nanonyme> herrwolfe45, DetailView or ListView?
- # 18:45 <herrwolfe45> list
- # 18:45 <nanonyme> Ahh, yeah. Mixing sounds fine anyhow if you can easily add it in.
- # 18:45 <nanonyme> Mixin even.
- # 18:45 <herrwolfe45> nanonyme: I mainly can't figure out how to add it it
- # 18:45 <herrwolfe45> nanonyme: would I just modify get_context_data?
- # 19:00 <bmispelon> herrwolfe45: are you returnong a list of objects (ListView) or a single one (DetailView) ?
- # 19:00 <herrwolfe45> bmispelon: a list of objects
- # 19:00 <bmispelon> herrwolfe45: then you probably want to extend get_queryset()
- # 19:00 <nanonyme> herrwolfe45, or get_queryset, depends on what you're after.
- # 19:00 <timkofu> hi guys
- # 19:00 <herrwolfe45> nanonyme, bmispelon : would i then need to have the order of inheritance be something like (Mixin, ListView): so that the queryset returned by the mixin is accessed in the listview?
- # 19:00 <alicefreak> iosolidar, If I remove the loop. it worked. But I want to manually render the forms.
- # 19:00 <nanonyme> herrwolfe45, read django.views.generic.list.MultipleObjectMixin to find out how it's done there
- # 19:00 <timkofu> Thing.objects.get(name=James or james)
- # 19:00 <nanonyme> ListView inherits that mixin.
- # 19:00 <timkofu> how do i properly get this or that?
- # 19:00 <iosolidar> alicefreak: read the django templates documentation
- # 19:00 <iosolidar> ticketbot: Q object
- # 19:00 <alicefreak> iosolidar, ok thanks
- # 19:00 <iosolidar> https://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects
- # 19:00 <bmispelon> herrwolfe45: the resolution order is from left to right
- # 19:00 <timkofu> anyone?
- # 19:00 <iosolidar> check the link
- # 19:00 <iosolidar> timkofu: it was meant for you
- # 19:00 <bmispelon> timkofu: you could use the __iexact field lookup: https://docs.djangoproject.com/en/dev/ref/models/querysets/#iexact
- # 19:00 <bmispelon> though it's not exactly what you asked for
- # 19:00 <herrwolfe45> nanonyme, bmispelon: thank you
- # 19:00 <timkofu> bmispelon: perfect. thanks.
- # 19:00 <timkofu> iosolidar: checking it out
- # 19:00 <nanonyme> herrwolfe45, but yeah, you probably want this method be called as the last thing and filter self.queryset based on self.request.
- # 19:00 <nanonyme> Simple stuff.
- # 19:00 <herrwolfe45> nanonyme: thank you, on lines 25 and 26 of the multipleobjectmixin it looks like I have found my answer
- # 19:00 <timkofu> bmispelon: worked perfect
- # 19:00 <nanonyme> herrwolfe45, ie you probably *want* get_queryset from MultipleObjectMixin to be called before your mixin is called.
- # 19:00 <nanonyme> (or rather the get_queryset in your mixin is called)
- # 19:00 <bmispelon> timkofu: be aware that it performs on case-insensitive search on the whole field (not just the first letter like in your example)
- # 19:00 <herrwolfe45> ah ok, here is how I have interpreted it: http://pastebin.com/Bv3WfG7c
- # 19:00 <bmispelon> herrwolfe45: I made a UserFilteredQuerysetMixin once. I could dig it up if you're interested.
- # 19:00 <timkofu> bmispelon: yea, read all its doc, it suits the case perfect
- # 19:00 <herrwolfe45> bmispelon: yes, that would be great, thanks!
- # 19:15 <nanonyme> herrwolfe45, no, that's not what I meant
- # 19:15 <herrwolfe45> nanonyme: do you see a prolem with it? It does look to e functioning
- # 19:15 <herrwolfe45> but, I haven't tested it fully
- # 19:15 <bmispelon> herrwolfe45: couldnt find the original file. It looked like this: http://dpaste.org/2go1I/
- # 19:15 <emacsen> If I need to make a db query without the model, where's the cannonical place to store the results? in a manager? somewhere else?
- # 19:15 <herrwolfe45> bmispelon: thank you!
- # 19:15 <bmispelon> but looking at your paste, it doesn't look like you're trying to do what i thought you were.
- # 19:15 <nanonyme> herrwolfe45, http://pastebin.com/index/Bv3WfG7c that's how I'd see it
- # 19:15 <nanonyme> Urf, sorry
- # 19:15 <nanonyme> It didn't save what I wrote
- # 19:15 <herrwolfe45> bmispelon: yeah I basically just have an FK on each model reltating to an account
- # 19:15 <herrwolfe45> and I only want the models related to the account
- # 19:15 <nanonyme> herrwolfe45, there we go http://pastebin.com/XgJwKEbu
- # 19:15 <herrwolfe45> but it is very similar to a ``user`` based model
- # 19:15 <bmispelon> herrwolfe45: my mixins assumes that you have models with a FK on auth.User (with the field called "user", but that can be changed)
- # 19:15 <nanonyme> I tried with a trivial example, that seems to be how the multiple inheritance works
- # 19:15 <bmispelon> if you use something like my mixin, you should put it before ListView
- # 19:15 <nanonyme> Yeap. Because it's right to left!
- # 19:15 <herrwolfe45> nanonyme, bmispelon : this does make more sense no
- # 19:15 <nanonyme> (confusing but appears to be so)
- # 19:15 <herrwolfe45> now*
- # 19:15 <herrwolfe45> ha
- # 19:15 <bmispelon> nanonyme: no, it's left to right
- # 19:15 <bmispelon> nanonyme: but I use super()
- # 19:15 <nanonyme> bmispelon, yeah, me too.
- # 19:15 <bmispelon> which will find the method defined on ListView
- # 19:15 <nanonyme> bmispelon, the super calls the parent, no?
- # 19:15 <bmispelon> nanonyme: not exactly
- # 19:15 <nanonyme> Multiple inheritance creates a linear inheritance of all classes.
- # 19:15 <bmispelon> it's a bit more subtle
- # 19:15 <nanonyme> Ie in Python
- # 19:15 <herrwolfe45> that is what I was thinking, due to the super()
- # 19:15 <nanonyme> But yeah, the left-most parent obviously overrides what is inherited from right-most parent. You can try this out with a trivial example if you don't believe it.
- # 19:15 <nanonyme> Oh, wait. Never mind.
- # 19:15 <bmispelon> a good reference on python's ineritance is: https://rhettinger.wordpress.com/2011/05/26/super-considered-super/
- # 19:15 <nanonyme> Ah, the magical Python3 super. :)
- # 19:30 <nanonyme> bmispelon, yeah, so left to right lookup when trying to find the parent but actual inheritance and overrides go the opposite way.
- # 19:30 <nanonyme> Since then the logical order is from parent to child which is right to left.
- # 19:30 <nanonyme> This can be easily proven by the pprint command in the blog post you linked to.
- # 19:30 <bmispelon> nanonyme: I'm confused now :) Let me re-read it.
- # 19:30 <nanonyme> bmispelon, search order is left to right, inheritance order is right to left which is opposite to search order.
- # 19:30 <bmispelon> my rule of thumb with CBV mixins is to put the mixins before the actual generic view
- # 19:30 <bmispelon> nanonyme: what do you mean by "inheritance order"?
- # 19:30 <nanonyme> I mean that class Foo(Bar, Baz): -> Baz is "parent" of Bar so Bar overrides methods and attributes in Baz, Bar is parent of Foo so Foo overrides methods and attributes in Bar
- # 19:30 <nanonyme> That's what the pprint mro tells you as well.
- # 19:30 <Guevara> hello! is possible make a return response to a modal window?
- # 19:30 <nanonyme> bmispelon, fairly intuitive, isn't it?
- # 19:30 <bmispelon> nanonyme: to me, Bar and Baz are unrelated to each other. They're just both parents of Foo.
- # 19:30 <bmispelon> if I try to access Foo.quux and it's not defined on Foo, then it will first search in Bar
- # 19:30 <nanonyme> bmispelon, well, according to resolution order they aren't. And super follows this resolution order.
- # 19:30 <nanonyme> bmispelon, sure and if it's not in Bar, it will then search in Baz. That's linear inheritance.
- # 19:45 <bmispelon> nanonyme: but you wrote "Baz is parent of Bar" which I still don't get
- # 19:45 <bmispelon> (the whole: the child overrides the parent's attributes/methods, i get it)
- # 19:45 <nanonyme> bmispelon, well, granted, it might not be immediate parent if Bar and Baz also inherit stuff
- # 19:45 <bmispelon> oh, i think i get it now.
- # 19:45 <bmispelon> by "parent', you basically means that it appears later in the MOR, right?
- # 19:45 <bmispelon> s/MOR/MRO/
- # 19:45 <nanonyme> Yeah.
- # 19:45 <Guevara> is possible return to a modal window when validation raise a error? http://postimage.org/image/5fs0t0ky5/
- # 19:45 <bmispelon> Guevara: not with django directly. You're going to have to do some heavy-lifting yourself (probably using ajax).
- # 19:45 <bmispelon> Maybe there's some 3rd party app that could help you, but i don't know of any.
- # 19:45 <Guevara> ok bmispelon, thanks =)
- # 19:45 <nanonyme> bmispelon, thanks for insisting me to try to explain though, I think I just figured out how to refactor some work code to be clearer.
- # 19:45 <bmispelon> nanonyme: glad to be of service :)
- # 19:45 <king313> Guys, how do you do to avoid having so much code in the app controller?
- # 20:00 <carljm> king313: if it's data validation code, offload it to a Form. if it's domain model code, offload it to the model. If it's presentation code, offload it to a custom template tag/filter. If it's reusable request/response handling code, offload it to a middleware or view decorator. The view functions (I'm assuming that's what you mean by "controller" you're left with should rarely be more than five to ten lines long.
- # 20:00 <Squeige> how can I type this symbol so I can delete it?
- # 20:00 <carljm> Squeige: same way you just typed it twice in IRC? :P
- # 20:00 <Squeige> I did past on here,
- # 20:00 <Squeige> but on my ssh window I cannot hit paste
- # 20:00 <carljm> You should be able to paste into an ssh terminal session, if you can't that's an unfortunate limitation of your OS and/or ssh client.
- # 20:00 <carljm> In any case, this is off-topic for #django.
- # 20:00 <king313> thanks carljm
- # 20:00 <carljm> You may want to check the appropriate support channels for your desktop OS, as that's what will determine how you can type that character.
- # 20:00 <bmispelon> king313: you could switch your keyboard to french layout and press the 9 key
- # 20:00 <Squeige> ok thanks
- # 20:00 <bmispelon> king313: oups, that wasnt for you. sorry ^^
- # 20:00 <king313> bmispelon, np
- # 20:00 <djangonewb> hmm i have a template but style.css doesn't seems to load.. What is default path ? as simple 'style.css' is not working
- # 20:00 <djangonewb> is it app/style.css ?
- # 20:15 <zhangxiao> In my form I have a MultipleChoiceField which has dynamic choices. Should I pass those choices as arguments to my form class's __init__() method?
- # 20:15 <alicefreak> iosolidar, there ?
- # 20:15 <iosolidar> ?
- # 20:15 <alicefreak> iosolidar, I am getting same problem. objects are displaying :(
- # 20:15 <iosolidar> can you paste the code again?
- # 20:15 <alicefreak> iosolidar, ok thanks alot :-)
- # 20:15 <iosolidar> sure
- # 20:30 <alicefreak> iosolidar, http://dpaste.org/PzOEh/
- # 20:30 <iosolidar> you still get all the objects?
- # 20:30 <iosolidar> {{ image_form.as_p }}
- # 20:30 <iosolidar> btw
- # 20:30 <alicefreak> iosolidar, let me try
- # 20:30 <alicefreak> iosolidar, no luck. getting all the objects
- # 20:30 <alicefreak> iosolidar, deleting brower history
- # 20:30 <alicefreak> iosolidar, result is same :(
- # 20:30 <anuvrat> hi
- # 20:30 <djangonewb> hmm
- # 20:30 <djangonewb> i have /static folder in my app
- # 20:30 <djangonewb> and loading static file like {{ STATIC_URL }}/style.css
- # 20:30 <djangonewb> but still it is not working
- # 20:30 <djangonewb> :/
- # 20:30 <alicefreak> iosolidar, I added this queryset=RecipeImage.objects.none(). Now It worked.
- # 20:30 <iosolidar> great :)
- # 20:30 <iosolidar> djangonewb: did you add STATIC_URL to the context processor?
- # 20:30 <anuvrat> I learned to use this way http://dpaste.com/743805/ , to provide path of the templates / data directory without hard coding .. but now since those directoires are no longer in the same directory as the settings file ... it does not work
- # 20:30 <anuvrat> how do I make it work?
- # 20:30 <alicefreak> iosolidar, thank you.
- # 20:30 <djangonewb> iosolidar i think i didn't, is it in settings.py ?
- # 20:30 <iosolidar> https://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own-context-processors
- # 20:30 <djangonewb> :)
- # 20:30 <iosolidar> anuvrat: point PROJECT_PATH to the directory where those files reside
- # 20:30 <anuvrat> iosolidar: okay, http://stackoverflow.com/questions/2860153/get-parent-directory-in-python would do right?
- # 20:30 <iosolidar> depends on your project
- # 20:30 <iosolidar> you just need to point out to where the files are, it doesn't matter how you do it (hard coded or dynamic)
- # 20:30 <iosolidar> there are some useful functions like the ones on the thread who can help you
- # 20:30 <iosolidar> import os; help(os);
- # 20:45 <gremmie> djangonewb, do you have django.core.context_processors.static in your TEMPLATE_CONTEXT_PROCESSORS setting?
- # 20:45 <djangonewb> hang on
- # 20:45 <djangonewb> let me look on it :)
- # 20:45 <gremmie> djangonewb, see https://docs.djangoproject.com/en/1.4/howto/static-files/#with-a-context-processor
- # 20:45 <gremmie> gremmie, that is step 1, then step 2 is to use RequestContext when you render your template
- # 20:45 <gremmie> d'oh
- # 20:45 <gremmie> djangonewb, ^^^
- # 20:45 <djangonewb> ;)
- # 21:15 <namfonos> im following the django Polls tutorial and i setup the /admin page but the css isn't showing up. if i check the source the /static/admin/css/base.css gets me a 404 error
- # 21:15 <tktiddle> does anyone know what user/group django dev server runs as?
- # 21:15 <namfonos> also the root page which was showing the blue congratulations banner is now also 404
- # 21:15 <namfonos> the last thing i did was uncomment the lines requiered for admin in the urls.py file
- # 21:15 <iosolidar> tktiddle: the one you run it in
- # 21:15 <anuvrat> hey .. I want to use git on my django project and am not sure where I should do git init ... the main project or separately in the apps directories?
- # 21:15 <gremmie> namfonos, are you using the devserver?
- # 21:15 <gremmie> namfonos, then you have to configure apache to serve static files
- # 21:15 <gremmie> namfonos, https://docs.djangoproject.com/en/1.4/howto/static-files/
- # 21:15 <namfonos> gremmie: thanks
- # 21:15 <gremmie> namfonos, if you are just experimenting and learning, using the devserver is easier; it serves static files for you
- # 21:15 <namfonos> gremmie: is there a reason btw why i can't run the server with python 3.x? i have to start it with python2.7
- # 21:15 <namfonos> python2.7 manage.py runserver
- # 21:15 <gremmie> namfonos, Django doesn't support Python 3 yet (officially)
- # 21:15 <namfonos> i see. is that coming soon?
- # 21:15 <gremmie> https://www.djangoproject.com/weblog/2012/mar/13/py3k/
- # 21:15 <nanonyme> namfonos, in the next few years
- # 21:15 <gremmie> so, experimental support in Django 1.5
- # 21:15 <iosolidar> finally
- # 21:30 <iosolidar> i've been waiting for so long for them to pick up python3
- # 21:30 <gawry> does anyone uses MongoEngine?
- # 21:30 <nanonyme> iosolidar, why do you feel like you'd want to use Python3?
- # 21:30 <nanonyme> Python 2.7 has most of the useful stuff backported.
- # 21:30 <iosolidar> nanonyme: it's more consistent
- # 21:30 <anuvrat> fiddlinge with django 1.4 .. which directory do I ask git to monitor? The whole projector or individual apps?
- # 21:30 <glosoli> http://dpaste.org/4Egu1/ any ideas why form.password.errors never shows the that paragraph or something, I am sure I am entering login data wrongly, so it should show me that paragraph, but it just refreshes page nothing else and asks me to enter data again without displaying error
- # 21:30 <averes> Hi there
- # 21:30 <gremmie> glosoli, paste your view function
- # 21:30 <glosoli> gremmie: you mean view for login ?
- # 21:30 <glosoli> gremmie: there isn't any view for login, I use login system included in Django
- # 21:30 <gremmie> glosoli, yes, unless you are using Django's contrib auth
- # 21:30 <glosoli> contrib one
- # 21:30 <gremmie> glosoli, ok
- # 21:30 <gremmie> glosoli, try outputting in the template form.non_field_errors
- # 21:30 <glosoli> gremmie: same syntax as with if for form.password.errors ?
- # 21:30 <gremmie> {{ form.non_field_errors }}
- # 21:30 <glosoli> and checking {% if form.non_field_errors %} or just outputing with it
- # 21:30 <glosoli> ?
- # 21:30 <gremmie> glosoli, just output it
- # 21:30 <gremmie> glosoli, if it is not defined it wont' render
- # 21:30 <gremmie> glosoli, you may want to review https://docs.djangoproject.com/en/1.4/topics/forms/#customizing-the-form-template
- # 21:30 <glosoli> nah it is not outputting anything
- # 21:45 <gremmie> glosoli, what about {{ form.as_p }} ?
- # 21:45 <gawry> Is it possible to use PostgreSQL to manage my users and MongoDB (with MongoEngine) for everything else?
- # 21:45 <glosoli> gremmie: well the same as I did above form.password and form.user
- # 21:45 <glosoli> gremmie: ah and {{ form.non_field_errors }} outputs now: Please enter a correct username and password. Note that both fields are case-sensitive.
- # 21:45 <nanonyme> gawry, sounds painful since you couldn't join or use transactions between the two.
- # 21:45 <nanonyme> You'd have to have plenty more content than just users for it to work sanely anyhow. Splitting between the two sounds perfectly doable though most likely completely useless and insanely complex.
- # 21:45 <nanonyme> Ie in SQL.
- # 21:45 <gawry> nanonyme: I was thinking because my users table would only be used to handle logins and permissions. Nothing else.
- # 21:45 <nanonyme> gawry, well, if you can get away with not needing relations to the user object, why not.
- # 21:45 <nanonyme> Ah, there's also the thing that I don't think you can get MongoDB to begin with without django-nonrel.
- # 21:45 <gawry> nanonyme: i'm using mongoengine.
- # 21:45 <iiie> glosoli: login form has special requirements, you wouldn't want to say that the username doesn't exist or have a different error for does not exist vs wrong credentials (the exception is requiring the fields)
- # 21:45 <gawry> nanonyme: I didn't want to use django-norel because it was the based in the version 1.3
- # 21:45 <nanonyme> gawry, not that there were so many new useful features in 1.4 that you can use without relational databases.
- # 21:45 <m1chael> ah, just registered mIRC. feels good. been using it for 17 years- about time
- # 21:45 <glosoli> iiie: I understand, I just want to say that error occured, please check info you entered or something like that :> seams like I figured out just to use that form.non_field_errors as described above
- # 21:45 <gawry> nanonyme: good point. I'm going to try django-norel.
- # 22:00 <dmishe> hey is there a clean non-hackish way to show both ends of m2m relation in admin?
- # 22:00 <dmishe> so i can edit m2m on one model admin as well as on the other model admin
- # 22:00 <nanonyme> dmishe, maybe with inlines?
- # 22:00 <dmishe> nanonyme suboptimal, i was considering that option too.
- # 22:00 <dmishe> this works kinda https://code.djangoproject.com/ticket/897#comment:28
- # 22:00 <dmishe> syncdb only tries to create the table twice :)
- # 22:00 <nanonyme> dmishe, fwiw with 1.4 you can actually create views and templates for admin so you can do pretty frigging much what you want.
- # 22:00 <dmishe> i see, thanks nanonyme
- # 22:00 <nanonyme> Could be overkill but just hinting it's doable.
- # 22:00 <nanonyme> (actually it might even be more efficient than inlines since with a view you can do prefetch_related properly)
- # 22:15 <ironm> good evening. Can you recommend a django based shop solution, please?
- # 22:15 <apollo13> satchmo
- # 22:15 <apollo13> or lfs
- # 22:15 <ironm> apollo13, thank you. I have checked it already however it is quite old
- # 22:15 <ironm> I meant satchmo
- # 22:15 <apollo13> last release is 31 march -- that's not old
- # 22:15 <ironm> apollo13, do you know how it is possible to install lfs in user's home directory?
- # 22:15 <apollo13> just use virtualenv
- # 22:15 <ironm> apollo13, thanks .. I have checked some old repository for satchmo .. (looks like)
- # 22:15 <ironm> how do you mean that? ... <apollo13> just use virtualenv
- # 22:15 <ironm> I am new to the django stuff
- # 22:15 <apollo13> well your question itself makes no sense, you can install every django app whereever you want, but usually one uses virtualenv to isolate the from each other
- # 22:15 <iosolidar> apollo13: how does that work? different apps using different interpreters?
- # 22:15 <apollo13> iosolidar: do you know what a virtualenv is? if not you probably want to read the docs on it (and start using it ;))
- # 22:15 <ironm> apollo13, I am missing some details about the structure. I have a local project directory with apps inside. How can I install inside such directory ready applications like lfs or satchmo?
- # 22:15 <nanonyme> apollo13, virtualenv per app? That sounds rather interesting a concept.
- # 22:15 <nanonyme> I tend to just have one per project.
- # 22:15 <apollo13> nanonyme: well more like project, but I mean if you test stuff you usually have one app + dependecies -> off into a new venv you go
- # 22:15 <apollo13> ironm: one usually doesn't install in that project directory
- # 22:15 <cheshair> Hi! I would like to add CSV-export capabilities to my django admin panel. I was thinking of a "export" button just next to "history" one (on the top right)
- # 22:15 <ironm> where else ?
- # 22:15 <cheshair> any tips on how to create such an action and place there a button?
- # 22:15 <apollo13> nanonyme: but yeah, for conflicting apps I did that too (one venv per app) *gg*
- # 22:15 <linelevel> Hi. So I'm trying to learn Django best practices. I've made several projects in Django, but I always follow what I've seen referred to as the "monolith antipattern", where I have an app called `main`, and sometimes I separate out some functionality into separate apps, but everything always hooks back together into that project's `main` app. I don't understand how to break this [anti]pattern. Can anyone refer me to further reading?
- # 22:15 <apollo13> cheshair: look up admin actions, then you have it in line with "delete selected objects"
- # 22:15 <cheshair> (given that "action" is the right name for it)
- # 22:15 <ironm> apollo13, where can I find more details how ?
- # 22:15 <apollo13> ironm: apps are normal python packages
- # 22:15 <apollo13> they are not treated specially
- # 22:15 <nanonyme> apollo13, so you'd have multiple gunicorns running on different ports or what?
- # 22:15 <apollo13> nanonyme: one apache to rule them all ;)
- # 22:15 <ironm> apollo13, so they would be installed inside the python-tree. Where can I configure them (to start the test server)
- # 22:15 <nanonyme> apollo13, ah, okay. I tend to run nginx anyhow.
- # 22:15 <apollo13> nanonyme: but yeah essentially 2 or more projects which then together result in a "site" for the enduser
- # 22:15 <apollo13> has some nice benefits, eg you can scale parts of your site ;)
- # 22:15 <apollo13> ironm: configure what?
- # 22:15 <nanonyme> Yeah, nginx works nicely for scaling.
- # 22:15 <apollo13> no that's not what I ment
- # 22:15 <nanonyme> Can just scale by adding more upstreams.
- # 22:15 <apollo13> eg imagine you have a forum and a news component
- # 22:15 <apollo13> then you want to have more workers for the forum
- # 22:15 <cheshair> apollo13, thank you very much! just one more thing. I'll deal with just one object at a time, so I was thinking more of a button on the single object detail rather than an action on the page list. Is there such a thing?
- # 22:15 <apollo13> cheshair: if you override the templates yes
- # 22:15 <cheshair> apollo13: ok, nice. I'll study docs, starting from actions and then I'll decide. Thanks again!!
- # 22:15 <ironm> apollo13, to configure settings in urls.py and settings.py for lfs or satchmo
- # 22:15 <apollo13> ironm: you'd do that in your project
- # 22:15 <nanonyme> apollo13, yeah, sure, though I don't see why you'd want to do that. Just having more all in all workers for entire project means it you don't have to touch it at all, load balances out anyway.
- # 22:15 <apollo13> nanonyme: I found it easier to hunt down bugs
- # 22:15 <nanonyme> ACTION shrugs
- # 22:15 <apollo13> well if you ever have to look with gdb into python processes ;)
- # 22:15 <ironm> apollo13, I did .. it is in /home/ironm/mysite/mysite/ .. two files ... urls.py and settings.py .. I am getting error messages when accessing the website (running local testserver )
- # 22:15 <apollo13> ironm: aha
- # 22:15 <nanonyme> Btw, is django a user or an organization in Github?
- # 22:15 <apollo13> the later
- # 22:30 <apollo13> at least that's what "Organization Members" indicates to me on https://github.com/django
- # 22:30 <nanonyme> Yeap.
- # 22:30 <nanonyme> https://github.com/django/django/blob/master/scripts/rpm-install.sh eargh, hackiness
- # 22:30 <apollo13> nanonyme: fwiw gdb is the new pdb ;)
- # 22:30 <nanonyme> apollo13, yeah?
- # 22:30 <nanonyme> Also, blah. Why no Trac integration in django/django?
- # 22:30 <nanonyme> (or is the integration plugin seriously so bad that it doesn't give you the proper links?)
- # 22:30 <apollo13> or you could have helped with the move ;)
- # 22:30 <nanonyme> Hey, I'm not part of the project and I only learned of the move when git pull stopped working for me.
- # 22:30 <apollo13> hey, I am neither ;)
- # 22:30 <nanonyme> (also the former Github repo was imo better; Django releases aren't in any way signified in the new one; needs moar tags or branches)
- # 22:30 <apollo13> time will bring those too
- # 22:30 <nanonyme> I suppose, they're increasingly less painful to do later on.
- # 22:30 <nanonyme> Erm, more painful even.
- # 22:30 <apollo13> not really
- # 22:30 <Stormlifter> Can someone give me a hand with template tags? http://dpaste.org/ePJfU/ I can't figure out how to get token[4] to the render() method.
- # 22:45 <maxwellbrown> mod_wsgi issues :( anyone up for helping? django.wsgi = http://dpaste.org/LYQSs/, virtualhost = http://dpaste.org/Z99Np/
- # 22:45 <Stormlifter> Can anyone help me get debug info out of a templat-tag that is failing?
- # 22:45 <wcapio> where can I find a tutorial on the ORM?
- # 22:45 <AlecTaylor> hi
- # 22:45 <birdpoop> Hi, im working on filebrowser which wasnt generation thumbnails and such, after a long search i found out that it crashes on the following line: im = im.resize((int(x*r), int(y*r)), resample=Image) which is a PIL fuction. could anyone point me in the right direction for debugging/fixing this?
- # 22:45 <AlecTaylor> How do I get my static admin css to load?
- # 22:45 <AlecTaylor> Settings.py (tried commenting out ADMIN_MEDIA_PREFIX): http://pastebin.com/4Z3cWWem Server output: http://pastebin.com/jJLSdxAf
- # 23:00 <ironm> apollo13, I got it (on behalf of pigletto) .. as in lfs-install-steps.txt
- # 23:00 <ironm> http://paste.debian.net/167637/
- # 23:00 <ironm> apollo13, thank you very much for your hints before :)
- # 23:15 <AeroNotix> How do I lint Django code? The metaclass magic messes with PyLint
- # 23:30 <MVXA> AeroNotix, did you try django-lint?
- # 23:30 <maxwellbrown> mod_wsgi issues any idea why I'm getting 500 errors? django.wsgi = http://dpaste.org/LYQSs/, virtualhost = http://dpaste.org/Z99Np/
- # 23:30 <apollo13> maxwellbrown: look into the error log
- # 23:30 <maxwellbrown> apollo13: have, i'm getting an import error - can't figure out why though
- # 23:30 <maxwellbrown> "Could not import settings '/home/max/fixthatplease.com/fixthatplease/settings.py' (Is it on sys.path?): Import by filename is not supported."
- # 23:30 <apollo13> well DJANGO_SETTINGS_MODULE is supposed to be a python import path, not a file name
- # 23:30 <apollo13> you know that the error actually tells you that you can't use filenames here=?!
- # 23:30 <apollo13> no
- # 23:30 <maxwellbrown> my example just set mysite.settings
- # 23:30 <apollo13> it want's an python path
- # 23:30 <apollo13> if the paths are set properly then yes
- # 23:30 <maxwellbrown> ahhh okay
- # 23:30 <AeroNotix> MVXA: I did and it sucks
- # 23:30 <kinabalu> with django, is there a way to get access to the user object from a parent template?
- # 23:45 <SmileyChris> kinabalu: the user object is on the context, not the template
- # 23:45 <kinabalu> ok... and I have access to a user object from the child templates already, but not the parent, is there some reason for that?
- # 23:45 <kinabalu> these are from logged in pages ala django-registration
- # 23:45 <kinabalu> SmileyChris: i've said something n00bish i gather:)
← next day
previous day →