March 16, 2012
← next day
previous day →
- # 00:00 <Derailed> Hey guys -- I'm working with a legacy MySQL database schema in Django, and i'd like to be able to create its tables duyring syncdb for testing purposes -- but in order to do that, I need to skip the entire normal method django creates tables and instead execute my own arbitrary 'CREATE TABLE' statement. has anyone done this before?
- # 00:00 <jaidan> Derailed: Never done that before, but how far off is the schema that is generated if you use the models generated by inspectdb
- # 00:00 <Derailed> jaidan, it includes data types that django doesn't support (blobs, enumerations, etc) and composite keys and some other snafu's.
- # 00:00 <Derailed> Django can work with the tables, but I don't trust it to make 'em
- # 00:00 <jaidan> Derailed: Fair enough, I'm pretty sure with a lot of work you could get django to generate the right schema. If you're afraid of the syncdb generated schema why not just dump the the schema from mysql and restore it like normal. In other words why worth with syncdb at all?
- # 00:00 <jaidan> as an aside if you want something commandline to get a dev enviroment bootstrapped maybe write a django-south migration with db.execute commands
- # 00:00 <Derailed> That's work -- mainly I want django to be able to create the tables so that automated testing and such is easier -- I don't really mind where I hook it in
- # 00:00 <Derailed> s/That's/That'd
- # 00:00 <eusid> you could use cycle to apply multiple css attritbutes at the template level for a table system...
- # 00:15 <eusid> joining late sorry guys
- # 00:15 <eusid> if Im off base
- # 00:15 <jaidan> Is there a way to register a signal on all child classes of an abstract model...other than adding one signal.connect for every single derived class
- # 00:15 <r3dd0> It is possible to require a login for 'TemplateView.as_view(template_name="account/profile.html")' inside urls.py
- # 00:15 <jaidan> r3dd0: https://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-class-based-views
- # 00:15 <r3dd0> jaidan, thanks!
- # 00:15 <jaidan> I personally prefer the second method in general, but that's because I prefer to have lines like foo = TemplateView.as_view() in my views.py file
- # 00:15 <jaidan> so that I don't have to import dozens of view classes into my urls.py files
- # 00:15 <SmileyChris> jaidan: you could just import the module :P
- # 00:15 <jaidan> SmileyChris: Well yes, but I don't know I like the string based view names =)
- # 00:15 <SmileyChris> i try to only import modules now
- # 00:15 <SmileyChris> with the odd exceptions
- # 00:15 <jaidan> I've been trying to convince my coworkers why from datetime import datetime is annoying as hell to me =P
- # 00:15 <jaidan> i finally convinced them that from foo import * was a sin
- # 00:15 <SmileyChris> heh
- # 00:15 <jaidan> I don't know I still don't do module imports with things like models and such
- # 00:15 <SmileyChris> i do, and it's much cleaner
- # 00:15 <SmileyChris> from myapp import forms, models... done
- # 00:15 <jaidan> yeah but doesn't that result in a ton of "as foo" things if you are importing from more than one app?
- # 00:15 <SmileyChris> yep, but that's fine to me
- # 00:15 <Derailed> jaidan, I think I might have a solution to my CREATE TABLE problem, although it's a little nasty -- I let django create the table, and then I add a some initial MySQL stuff to 'sql/ModelName.sql' which immediately DROPs the created table and CREATEs the one I want :-)
- # 00:15 <jaidan> lol
- # 00:30 <yuletide666> YO
- # 00:30 <jaidan> Ok so, is their a reason I'm not thinking of that models that inherit from an abstract model don't return true on isinstance(sender, MyAbstractBase)?
- # 00:30 <jaidan> wow that was dumb of me lol
- # 00:30 <jaidan> sender is the class not an instance
- # 00:30 <spersaud> I cant believe how hard it is to create a thumbnail of a PHOTO
- # 00:30 <jaidan> spersaud: sorl.thumbnail
- # 00:30 <jaidan> then it's trivial
- # 00:30 <spersaud> there are so many apps, then I tried to make my own, PIL is not working
- # 00:30 <jaidan> install pillow instead of PIL
- # 00:30 <jaidan> use sorl, it's the only one i'd even consider
- # 00:30 <jaidan> on my system i just do apt build-dep python-imaging before I install pillow, that way I get all the encodings without a headache
- # 00:30 <spersaud> jaidan: I didnt try that one ..
- # 00:30 <spersaud> jaidan: does it generate a thumbnail and store it on the filesystem ?
- # 00:30 <jaidan> yeah
- # 00:30 <jaidan> it's really good
- # 00:30 <jaidan> it has a template tag as well as a python api for generating them
- # 00:30 <jaidan> usually just need the template tag
- # 00:30 <jaidan> even works in the admin
- # 00:30 <spersaud> jaidan any idea why Image.open(ContentFile(upload_file.read())) will not work ?
- # 00:30 <jaidan> what's the error?
- # 00:30 <spersaud> jaidan: many of the others dont work well
- # 00:30 <spersaud> jaidan: lol, all I get is a 500 error :)
- # 00:30 <jaidan> do you have debug enabled?
- # 00:45 <spersaud> jaidan: yes, it just says 500 error, I am using plupload ..
- # 00:45 <jaidan> I've never used that library so I can't speak to it, but in django 500 errors usually give you a trace lol
- # 00:45 <spersaud> well the main photo uploads with no problem .. will now try sorl,
- # 00:45 <spersaud> what does sorl stand for ? I keep seeing it all over the place
- # 00:45 <jaidan> spersaud: https://github.com/sorl
- # 00:45 <superdmp> what urlpattern will match: /blahblahblah/<some positive integer> ?
- # 00:45 <jaidan> \d+
- # 00:45 <superdmp> thanks jaidan
- # 00:45 <superdmp> jaidan: so, "^blahblahblah/(\d+)/$" ?
- # 00:45 <jaidan> "^blahblahblah/(?P<foo>\d+)/$"
- # 00:45 <jaidan> would be what i'd do
- # 00:45 <jaidan> replace foo with something useful
- # 00:45 <SmileyChris> this is explained in tutorial 3... :P
- # 00:45 <gremly> Hi everybody, which option is better between override save method in a model and use pre_save or post_save signal with an specified sender?.... is there any reason to use one or another?
- # 00:45 <jaidan> gremly: well post save wouldn't have the same effect
- # 00:45 <superdmp> jaidan: i don't understand what you mean by useful
- # 00:45 <jaidan> superdmp: the "foo" portion becomes the keyword arg that is passed to your view
- # 00:45 <superdmp> ah yes
- # 00:45 <superdmp> doh
- # 00:45 <superdmp> for some reason I have a hip pain that is making it hard to think
- # 00:45 <jaidan> SmileyChris: It's been so long since I did that tutorial I couldn't tell you what's in it...except Poll
- # 00:45 <FunkyBob> ACTION tries to remember if the tute had Poll in it when he first did it
- # 00:45 <Jax> evening
- # 00:45 <gremly> jaidan: thanks... would you give me some tip about that effect?.... please
- # 01:00 <jaidan> gremly: post_save is after the instance has been saved to the db. While pre_save is before the actual save to the database. Pre_save is good for making changes to the instance before it gets saved such as maybe setting a default that's too complex to be done with a normal or callable default
- # 01:00 <jaidan> overriding save has it's place as well, but it is effectively very similar to handling a pre_save signal
- # 01:00 <SmileyChris> you could do post-save work in the method just the same
- # 01:00 <jaidan> sure, depends on what the work is, i mean i wouldn't be altering instance values and resaving in post_save lol
- # 01:00 <SmileyChris> you wouldn't do that after calling super().save either :P
- # 01:00 <jaidan> ^ truth
- # 01:00 <gremly> xDD
- # 01:00 <gremly> SmileyChris, jaidan thank you so much!
- # 01:00 <SmileyChris> gremly: if it's an action that should happen under all circumstances, i'd stick with it as a save method
- # 01:00 <SmileyChris> gremly: I leave the signals for when there's an edge chance that that behavior might be modified under some circumstances (you could deregister the signal), or for when you're modifying a third-party app's model
- # 01:00 <SmileyChris> but they'll both work. You pick
- # 01:00 <superdmp> the pleasantness of this channel compared to others is remarkable
- # 01:00 <superdmp> #python is excellent too
- # 01:00 <SmileyChris> cup of tea, anyone?
- # 01:00 <jaidan> no kidding. we have some old projects in CakePHP. Good luck ever getting help on that channel rofl
- # 01:00 <superdmp> there seems to be a particular kind of IRC character that likes to combine snide personal remarks with expert technical knowledge
- # 01:00 <FunkyBob> superdmp: well, try asking for help without (a) having read the docs, (b) tried it yourself, (c) explaining what you're really doing
- # 01:00 <FunkyBob> I can get really nasty if you do those :P
- # 01:00 <jaidan> funky yelled at me last week because I overlooked a line on my stack trace...
- # 01:00 <FunkyBob> yeah... bet you won't do that again in a hurry :P
- # 01:00 <superdmp> pff
- # 01:00 <gremly> SmileyChris: thanks
- # 01:00 <jaidan> FunkyBob: depends on how you define hurry I had been looking at that issue for the better part of an hour already lol
- # 01:00 <jaidan> we'll call it a bad day
- # 01:00 <FunkyBob> I'm trying to calm down
- # 01:00 <FunkyBob> right now we're days away from a site release, so i'm a little... pressured
- # 01:00 <Aut0Exec> whats the best way to set up multilpe mod_wsgi sites with django?
- # 01:00 <FunkyBob> Aut0Exec: one per vhost?
- # 01:00 <Aut0Exec> oh ok
- # 01:00 <FunkyBob> the box I'm IRCing from has about 20 or so
- # 01:00 <iiie> Aut0Exec: right, one per vhost, and name the process groups
- # 01:00 <Aut0Exec> FunkyBob: like so http://stackoverflow.com/questions/1553165/multiple-django-sites-with-apache-mod-wsgi
- # 01:00 <Aut0Exec> ??
- # 01:00 <FunkyBob> but it doesn't haev to be that way
- # 01:00 <Aut0Exec> FunkyBob: is that howuhave urs?
- # 01:00 <Aut0Exec> from my link?
- # 01:00 <FunkyBob> I have only one Directory entry, because I had a fairly consistent layout
- # 01:00 <Aut0Exec> FunkyBob: can you give me a pastie ors omething to work with?
- # 01:15 <FunkyBob> ever used mod_macro ?
- # 01:15 <Aut0Exec> no
- # 01:15 <Aut0Exec> coming from php
- # 01:15 <Aut0Exec> php is real easy to deploy
- # 01:15 <Aut0Exec> can you send me some links, docs, or pasties
- # 01:15 <Aut0Exec> ?
- # 01:15 <Aut0Exec> so i can see the best method to set up about 3 sites
- # 01:15 <Aut0Exec> it can be multiple vhosts.. i dont care
- # 01:15 <iiie> Aut0Exec: we use http://dpaste.org/mvNOJ/ for the central chunk of our mod_wsgi
- # 01:15 <Aut0Exec> to be honest... i reallydont want to have to point to different ports with vhosts.. like myserver:8090 myserver:8080
- # 01:15 <lacrymology> is there a way I can constrain the types a GenericForeignKey can point at? at least at the Form level (guessing that setting the QuerySet won't work because I can't create a QuerySet of two or more Model classes)
- # 01:15 <Aut0Exec> iiie: and how to do this formultiple?
- # 01:15 <FunkyBob> http://dpaste.com/717192/
- # 01:15 <FunkyBob> oops..
- # 01:15 <FunkyBob> http://dpaste.com/717193/ something like that
- # 01:15 <Aut0Exec> FunkyBob: wow.. never seen this before
- # 01:15 <FunkyBob> which bit?
- # 01:15 <Aut0Exec> macro wsgihost ....
- # 01:15 <Aut0Exec> is this the only way? seems perplexing
- # 01:15 <Aut0Exec> must be an easier way
- # 01:15 <FunkyBob> oh... mod_macro is hando
- # 01:15 <FunkyBob> no, it's not the only way
- # 01:15 <FunkyBob> but it does mean adding another vhost is a matter of just "Use WsgiHost www.another.com"
- # 01:15 <lacrymology> and moreover, why don't GenericForeignKey's accept verbose_name()? how can I localize such a model?
- # 01:15 <lacrymology> and moreover, why don't GenericForeignKey's accept verbose_name()? how can I localize such a model?
- # 01:15 <iiie> Aut0Exec: FunkyBob's is more dynamic (less config) we change out the it would be the YOUR_WSGI_NAME per site, but this is just to split the processes, otherwise the wsgi daemons are shared
- # 01:15 <FunkyBob> lacrymology: GFK are fields, not models
- # 01:30 <danols> I need some design decision feedback to a problem I have, may I have your attention :)
- # 01:30 <danols> I have a model A(models.Model) and model B(A)
- # 01:30 <FunkyBob> uh-oh
- # 01:30 <jaidan> lol
- # 01:30 <danols> so model B is a child of A, I have another model C that has FK to A (the base model)
- # 01:30 <lacrymology> FunkyBob: I mean a model that has a GFK field
- # 01:30 <danols> so I get an A object when accessing it through C, how can I call a method on object B through an instance of A
- # 01:30 <Aut0Exec> iiie: ur example u gave me earlier is for virtualenv installs right?
- # 01:30 <danols> downcast to the child A automatically, just like django magically allows me to reffer to fields on model B and A
- # 01:30 <iiie> Aut0Exec: yes it works great with virtualenvs
- # 01:30 <Aut0Exec> ok
- # 01:30 <jaidan> If A is a concrete model (as opposed to abstract) then it has a one to one file to B
- # 01:30 <jaidan> s/file/field
- # 01:30 <Aut0Exec> iiie: perfect cuz thats what i use.. but how to expand upon this now to just addanother site?
- # 01:30 <jaidan> danols: https://docs.djangoproject.com/en/1.3/topics/db/models/#multi-table-inheritance
- # 01:30 <danols> jaidan: hi jaidan thank you but I am not sure how that helps, I have read through that
- # 01:30 <danols> http://dpaste.com/717201/ is my code base
- # 01:30 <iiie> Aut0Exec: we include them in each virtualhost, the USERNAME and GROUPNAME are the user and group that you're running the wsgi daemon process as, YOUR_WSGI_NAME is something related to the given site, the path's are of course updated for the codebase (project and virtualenv) paths
- # 01:30 <danols> bottom line is I think I will have to use GFK here, as I can many inherited models and I so no clean way to be able to get from parent A to the right child class
- # 01:30 <jaidan> danols: If you have a VTbase instance you would call instanace.vatsimple to get the VATSimple instance
- # 01:30 <lacrymology> FunkyBob: ok, I'm finding a worse problem.. I get the content_type and object_id fields to edit, I want to be able to just selec the object =(
- # 01:30 <iiie> Aut0Exec: make sure you set the python path right, python2.6 or python2.7 or even python2.5 are based on what you have on your system
- # 01:30 <Aut0Exec> iiie: ok so ur setup uses multiple virtualhosts... but dont you have to keep swithing portstho... like mysite:8080 mysite:8090 ?
- # 01:30 <iiie> Aut0Exec: no switching ports, that's what the virtualhosts does
- # 01:30 <jaidan> danols: Maybe what you are looking for is abstract base classes rather than concrete inheritance and then use a GFK
- # 01:30 <Aut0Exec> ahhh ok
- # 01:30 <danols> jaidan: yes ok, VATSimple has .calculate_vat() method that I wish to execute, actually there could be VATComplex with a method calculate_vat too the dilemma is that if my Products have only many to many to VATBase, there is no way to know if it's VATComplex or VATSimple without trying vatinstance.vatsimple.calculate_vat(), instance.vatcomplex.calculate_vat(), right? at least I don't see it.
- # 01:30 <FunkyBob> Aut0Exec: wait, aren't you using Apache/mod_wsgi ?
- # 01:30 <FunkyBob> Aut0Exec: if so, why all the different ports?
- # 01:30 <Aut0Exec> iiie: so even tho site2 might be using port 8090 on the virtualhost once i put in http://site2 it automatically points it there right?
- # 01:30 <Aut0Exec> FunkyBob: yes
- # 01:30 <Aut0Exec> FunkyBob: dif ports for virtualhosts
- # 01:30 <FunkyBob> Aut0Exec: why?
- # 01:30 <FunkyBob> name-based vhosts works just fine
- # 01:30 <Aut0Exec> FunkyBob: going bythis http://stackoverflow.com/questions/1553165/multiple-django-sites-with-apache-mod-wsgi
- # 01:30 <FunkyBob> you're not doing that pointlessly complex "nginx infront of apache" bullshit, are you?
- # 01:30 <danols> it looks to me that this is a need for GFK, this way my instance is exactly what was attached to objects, and there is no guessing
- # 01:30 <Aut0Exec> i wish i had a straight outline i can use
- # 01:30 <jaidan> danols: It really sounds like you want abstract base classes
- # 01:30 <FunkyBob> whoever wrote that is a twit
- # 01:30 <Aut0Exec> lol
- # 01:30 <FunkyBob> Aut0Exec: as I said... I run about 20 sites on this single Apache intsance
- # 01:30 <FunkyBob> all on port 80
- # 01:30 <Aut0Exec> FunkyBob: can you point a nub like me in the right direction then
- # 01:30 <Aut0Exec> ok
- # 01:30 <FunkyBob> what about Graham's docs?
- # 01:30 <jaidan> danols: VatBase should be abstract and the various Vat* classes should inherit from that abstract
- # 01:30 <Aut0Exec> FunkyBob: its just that i dont get the whole macro wstihost thing
- # 01:30 <Aut0Exec> *wsgi
- # 01:30 <FunkyBob> forget the magro thing, then
- # 01:30 <FunkyBob> macro
- # 01:30 <danols> jaidan: let me clarfiy , I want a product object that I can attach any type of TAX to it, be it VATSimple, VATComplex, VATTiered, etc, I attempted to do it with FK VATBase, but ofcourse my VATBase doesn't have instance.calculated_vat() implemented, and even from python point of view how do you down cast to the right child, so am I right to assume this if GFK ?
- # 01:30 <Aut0Exec> so can u give me an easy setup
- # 01:30 <FunkyBob> for each vhost, set an Alias [so /static and /media come from the filesystem] and a WsgiScriptAlias
- # 01:30 <FunkyBob> danols: so, you want polymorphism?
- # 01:30 <Aut0Exec> thats it?
- # 01:30 <danols> FunkyBob: yeah exactly
- # 01:30 <FunkyBob> Aut0Exec: yes, that's it.
- # 01:30 <Aut0Exec> oh
- # 01:30 <Aut0Exec> i see
- # 01:30 <FunkyBob> danols: django-polymorphic
- # 01:30 <jaidan> danols: Yes youre products would need a GFK most likely. Or else you could do some sort of try: except: chains
- # 01:30 <danols> calling VATBase.calculate_vat() executes the child's method, be it the child is VATSimple, VATComplex, etc
- # 01:30 <danols> jaidan: try and except is what I thought too BUT then I would need to know 'future' possible VAT cases, which I would like to leave open
- # 01:30 <FunkyBob> danols: polymorphic will let you return an heterogenous group of child models when selecting from the base(parent) model
- # 01:30 <danols> FunkyBob: let me look at that
- # 01:30 <FunkyBob> danols: django-model-utils has another implementation
- # 01:30 <Tominator> hi
- # 01:30 <danols> is there a built in too for python for something like this ?
- # 01:30 <danols> to traverse down ? opposite of super ?
- # 01:30 <jaidan> danols: it really sounds like make VATBase abstract and then have GFK's for the product -> VAT relationship
- # 01:30 <danols> jaidan: yep , I would tend to agree,
- # 01:30 <Tominator> is there a way to call your own function when there comes an on_delete event? I want to cascade, but also do some additional stuff...
- # 01:45 <FunkyBob> danols: sure... you can reach a child model, so long as you know which one it is
- # 01:45 <jaidan> danols: you could also maybe do some really hacky stuff with getattr, hasattr, and __dict__
- # 01:45 <FunkyBob> Tominator: there's probably a pre-delete signal
- # 01:45 <danols> ACTION just the GFK widget is unusable by default --- any substitute you can recommend ?
- # 01:45 <Aut0Exec> FunkyBob: just to be sure... so each of these can be hosted on port 80 yes?
- # 01:45 <Tominator> FunkyBob: thanks for the hint!
- # 01:45 <FunkyBob> danols: grappelli offers an auto-complete for it, I believe
- # 01:45 <danols> FunkyBob: if I do not know the child ? --- how does django know how to do it with one-to-one ?, generates some kind of internal reference during init?
- # 01:45 <FunkyBob> Aut0Exec: sure... look at the Apache docs on "name-based virtual hosts"
- # 01:45 <Aut0Exec> FunkyBob: ok thanks bro
- # 01:45 <FunkyBob> danols: in raw django, all the child models are available through one-to-one like relations
- # 01:45 <FunkyBob> danols: this is all cvered in the docs
- # 01:45 <FunkyBob> django-polymorphic saves an extra field to tell it what the child for this parent instance is
- # 01:45 <danols> I see
- # 01:45 <FunkyBob> remember that in raw Django, there's nothign to stop you from having more than one child type instance for a single parent
- # 01:45 <danols> FunkyBob: yes of course, in raw django if I am VATBase, how do I get to the child, WITHOUT knowing the child class name? i.e. instance.<foo> where foo can be anything
- # 01:45 <FunkyBob> you can't
- # 01:45 <danols> ok
- # 01:45 <FunkyBob> because there isn't "the" child
- # 01:45 <danols> is there a list ? in Meta ?
- # 01:45 <FunkyBob> there's as many potential children as there are models deriving from this one
- # 01:45 <danols> in my scenario I will always have one
- # 01:45 <FunkyBob> right
- # 01:45 <FunkyBob> which is where django-polymorphic is a _perfect_ fit
- # 01:45 <FunkyBob> you never want to look at the base class... only the _one_ child... right?
- # 01:45 <danols> correct
- # 01:45 <danols> yes I am looking at it, without it though, is there to examine the 'children' without this extra storage field ?
- # 01:45 <FunkyBob> look at how it does it
- # 01:45 <FunkyBob> and how django-model-utils does it
- # 01:45 <Alpha1650> Hey guys, I'm having difficulties with the "makemessages"-command. There's a couple of (email) templates that are left out. I render them with render_to_string. Why are they left out and how can I add them to my locale files?
- # 01:45 <danols> if you were to pick one, which one ? django-model-utils or django-polymorphic
- # 01:45 <FunkyBob> danols: polymorphic, since you never want to look at the base model directly
- # 01:45 <FunkyBob> model-utils makes you call select_subclasses() or something
- # 01:45 <FunkyBob> and doesn't work as well through fkeys
- # 01:45 <danols> k
- # 01:45 <danols> ahh
- # 01:45 <danols> model-utils uses self.model._meta.get_all_related_objects() so no extra field
- # 01:45 <FunkyBob> yes, but it does other work to figure out which child to use, too
- # 01:45 <danols> it's also a manager which is interesting
- # 01:45 <danols> FunkyBob: thank you man
- # 01:45 <danols> this could potentially in most cases replace my GFK use
- # 02:00 <humanclay21> Hi there. I'm fairly new to django here. I've read the definitive guide to django book and it's been a great help, but i'm stuck on something at the moment. I'm trying to build a very simple application where a user will enter data within the django admin and then their clients will view it through a front-end. Everything is working, except I can't get a field in the model to sort the way I want it to. Here is the snippet from my
- # 02:00 <FunkyBob> humanclay21: learn to hit enter more often :)
- # 02:00 <FunkyBob> your line got truncated at "Here is the snippet from my"
- # 02:00 <humanclay21> the problem is that I need to be able to store alphanumeric content but have it sort numerically. So it should sort W1, W2, W100, rather than W1, W100, W2
- # 02:00 <humanclay21> Here is the snippet from my model: http://dpaste.org/gwjwF/
- # 02:00 <FunkyBob> humanclay21: can you think of how you'd achieve that in SQL?
- # 02:00 <humanclay21> in sql I would do 'select * from table order by field5+0, field4+0, field3+0, field2+0, field1+0'
- # 02:00 <humanclay21> as described here: http://www.linuxweblog.com/blogs/sandip/20060126/sorting-varchar-data-mysql
- # 02:00 <FunkyBob> so... mysql doesn't raise issues when you implicitly trying to case a string that isn't a number to a number?
- # 02:00 <FunkyBob> doesn't surprise me... just another "WTF" to add to the MySQL mountain
- # 02:00 <humanclay21> ya, no issues. mysql returns everything in the expected order
- # 02:00 <pjs> haha
- # 02:00 <FunkyBob> "Yes.. here's yet another case where MySQL doesn't complain on an error condition."
- # 02:00 <humanclay21> :) is there any way to make the Meta class sort things that way after grabbing the data from MySQL?
- # 02:00 <FunkyBob> django does its sorting in the DBMS
- # 02:15 <humanclay21> ok. then perhaps there is a way to use raw SQL for a specific model?
- # 02:15 <pjs> humanclay21 .raw()?
- # 02:15 <FunkyBob> for a model? "manage.py sqlall {appname}"
- # 02:15 <pjs> humanclay21 https://docs.djangoproject.com/en/1.3/topics/db/sql/#performing-raw-queries
- # 02:15 <crisisking> might be able to get away with doing it using .extra() as well
- # 02:15 <crisisking> and just pass the order by clause into it
- # 02:15 <humanclay21> hmm, well the thing is I need the admin interface to have the same sorting. is that possible?
- # 02:15 <crisisking> if you don't want the user to change sort order in the admin, yes
- # 02:15 <valdergallo> hi, i can use models to validate my models, without use modelsForm ?
- # 02:15 <valdergallo> i wanna use full_clean on my models
- # 02:15 <kesor> you mean on the data you already have in your databse?
- # 02:15 <valdergallo> somebody can help me ? I wanna use full_clean to validate my models, i dont wanna use modelForms.
- # 02:15 <humanclay21> crisisking: can you send me a link to documentation on how to use extra()?
- # 02:15 <kesor> valdergallo: to validate the data in your database?
- # 02:15 <crisisking> humanclay21: https://docs.djangoproject.com/en/dev/ref/models/querysets/#extra
- # 02:15 <valdergallo> kesor: to validade my business rules, before save
- # 02:15 <valdergallo> kesor: like i do on modelForm
- # 02:15 <kesor> valdergallo: where do you get the data for the save() from? a form?
- # 02:15 <humanclay21> crisisking: hmm, i think i understand the examples there and could use extra() from the console, but i'm not sure how to make that work with admin?
- # 02:15 <crisisking> in your modeladmin, you would override the queryset method
- # 02:15 <crisisking> https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.queryset
- # 02:15 <pjs> valdergallo this may help you: https://docs.djangoproject.com/en/dev/ref/validators/
- # 02:15 <valdergallo> kesor: from models ... i will put data create like ... MyModel.objects.create(name='valder')
- # 02:15 <kesor> valdergallo: where is the string "balder" coming from? a form?
- # 02:15 <kesor> *valder
- # 02:15 <valdergallo> kesor: before save i will vaidade my clean on my model to check if my name is valder on model
- # 02:15 <valdergallo> kesor: i can do this ? or this is wrong
- # 02:15 <kesor> valdergallo: not generally, its just not the correct place for it.
- # 02:30 <tiglionabbit> I want to put an Expires header in my HttpResponse. How do I format a date for it? Django isn't doing it automatically and the results are weird.
- # 02:30 <humanclay21> crisisking: i've finished reading here. https://docs.djangoproject.com/en/dev/ref/models/querysets/#extra says that extra() can only be used for custom select queries
- # 02:45 <humanclay21> crisisking: it doesn't look like it will allow custom order bys
- # 02:45 <humanclay21> and i'm not sure it will accept 'field+0' anyways. is there a way to sort things in python after mysql returns the data and before it shows up in the admin?
- # 02:45 <crisisking> humanclay21: it seems to work just fine for me
- # 02:45 <crisisking> the extra call that is
- # 02:45 <crisisking> no extra selects needed
- # 02:45 <humanclay21> crisisking: so the extra call can force the mysql query to add on 'order by field5+0' at the end of it's query?
- # 02:45 <crisisking> yeah
- # 02:45 <crisisking> though you'll need to use tablename.fieldname+0 instead of just fieldname
- # 03:45 <sir_tyrion> Hi, dumb ?, how can I allows nulls in a model?
- # 03:45 <sir_tyrion> I see the field documentation, don't know where to pu tit
- # 03:45 <FunkyBob> sir_tyrion: null=True
- # 03:45 <FunkyBob> in the field declaration
- # 03:45 <sir_tyrion> kaa
- # 03:45 <sir_tyrion> models.CharField(max_length=50, null=True)
- # 03:45 <sir_tyrion> ?
- # 03:45 <FunkyBob> yes
- # 03:45 <mbrochh> sir_tyrion: yep
- # 03:45 <FunkyBob> are you sure you want null in a CharField ?
- # 03:45 <FunkyBob> do you need to know the difference between '' and NULL ?
- # 03:45 <sir_tyrion> it is an example
- # 03:45 <mbrochh> sir_tyrion: for a char field you better just put blank=True so that an empty form value will be allowed
- # 03:45 <sir_tyrion> no i get that
- # 03:45 <mbrochh> for other fields you might want to put blank=True, null=True
- # 03:45 <sir_tyrion> Alright, but I put it in the paren like I did?
- # 03:45 <mbrochh> yes
- # 03:45 <sir_tyrion> models.CharField(max_length=50, blank=true)
- # 03:45 <mbrochh> yep
- # 03:45 <sir_tyrion> thanks
- # 03:45 <lacrymology> is there a way to create fixtures that add but don't override objects?
- # 04:15 <pycorbino> could someone do me a huge favor and take a look at http://dpaste.com/717237/ for me?
- # 04:15 <pycorbino> for some reason, the get_absolute_url function is not mapping the slug in my templates
- # 04:15 <tijko> whats happening?
- # 04:30 <pycorbino> for some reason, the get_absolute_url function is not mapping the slug in my templates
- # 04:30 <ptone> pycorbino: we can't see how you've set up the .slug attr on your model from that paste
- # 04:30 <pycorbino> ptone: in the model it is just slug=models.SlugField()
- # 04:30 <ptone> pycorbino: I think you are mixing up get_absolute_url with syntax for reverse()
- # 04:30 <ptone> strike that
- # 04:45 <ptone> pycorbino: is the indent of the function under the decorator a copy paste error - or is it like that - could be your problem there
- # 04:45 <pycorbino> yeah that was just misformatting in dpaste
- # 04:45 <pycorbino> so the get_absolute_url and decorator are all correct?
- # 04:45 <ptone> pycorbino: so what does {{ obj.get_absolute_url }} give you in a template?
- # 04:45 <pycorbino> in a the listview (that works correctly) i use it in an anchor tag to link to the detailview of each blog post
- # 04:45 <uberj> https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.validate_unique <--- that says a ValidationError should be raised when an object already exists in the database, but a *IntegretyError* is raised when an object is found to be violating a unique_together clause.
- # 04:45 <uberj> can someone help me understand why it's like that?
- # 04:45 <ptone> pycorbino: but how exactly is the link malformed - is it just missing the slug part?
- # 04:45 <pycorbino> yes, i am getting None in return, but if i do object.slug i get the slug
- # 04:45 <ptone> uberj: one is enforce lower down at the database level - and yields the Integrity error
- # 04:45 <ptone> pycorbino: if you get into a django shell - pull up an obj, and then do obj.get_absolute_url you might get a clue?
- # 04:45 <uberj> ptone: but it seems to be the same error, "the object exists."
- # 04:45 <uberj> it's not consistent.
- # 04:45 <ptone> uberj: same functional error, but different reason, easy enough to catch both if you need to do something when that happens
- # 05:00 <uberj> there are many reasons why a ValidationError is raised, but the exception consistent.
- # 05:00 <uberj> is there any reason why validate_unique *must* raise a ValidationError?
- # 05:00 <uberj> iirc forms catch IntegrityErrors, too.
- # 05:45 <bradleyayers> hi
- # 05:45 <bradleyayers> so is it correct that you shouldn't be able to reverse a class based view if it's namespaced
- # 05:45 <mattmcc> Being class-based view isn't related to the reversability of a view.
- # 05:45 <mattmcc> Assuming of course that you've got a named urlpattern.
- # 05:45 <bradleyayers> well i want to do reverse(view)
- # 05:45 <bradleyayers> where view is a function
- # 05:45 <bradleyayers> i'll rephrase my question
- # 05:45 <bradleyayers> so is it correct that you shouldn't be able to reverse a view using only it's function reference if it's namespaced?
- # 05:45 <bradleyayers> its*
- # 06:00 <mattmcc> That still shouldn't be a problem, but since views could be used by multiple patterns, it'll just grab the first match.
- # 06:00 <bradleyayers> i think this is just a bug in django then
- # 06:00 <bradleyayers> gah
- # 06:00 <mbrochh> hmmm... i have this in my requirements.txt: e hg+https://bitbucket.org/ubernostrum/django-registration#egg=registration
- # 06:00 <mattmcc> Reproducible test case! :)
- # 06:00 <mbrochh> when i run pip install -r requirements.txt on my server, I get this:
- # 06:00 <bradleyayers> mattmcc: deal.
- # 06:00 <mbrochh> warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
- # 06:00 <yuletide> django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: No module named psycopg
- # 06:00 <yuletide> ??
- # 06:00 <yuletide> just working through the tutorial
- # 06:00 <mbrochh> this happens 5 times, then pip install aborts
- # 06:00 <mbrochh> on my local machine this happens as well since forever but after 5 tries it just goes on...
- # 06:00 <bradleyayers> mattmcc: i take it you haven't run into this?
- # 06:00 <mbrochh> anyone knows how to shut mercurial up and just ignore the certs?
- # 06:00 <bradleyayers> mbrochh: this is #django, pip and mg are unrelated
- # 06:00 <FunkyBob> mbrochh: stop using https?
- # 06:00 <mbrochh> bradleyayers: ok sorry
- # 06:00 <mattmcc> bradleyayers: No, but I've also done very little namespacing of URLs, it gives me a headache.
- # 06:00 <bradleyayers> mattmcc: fair enough
- # 06:00 <mattmcc> yuletide: You're missing python-psycopg2
- # 06:00 <PressedWeb> You can't .save() a QuerySet in the shell can you? .save() is only for submitting changes to the db right?
- # 06:00 <mbrochh> FunkyBob: indeed that works, thanks!
- # 06:00 <FunkyBob> PressedWeb: that's so full of wrong, it's scary
- # 06:00 <PressedWeb> I'm a pretty wrong kinda dude
- # 06:00 <yuletide> argh
- # 06:00 <PressedWeb> Elaborate please?
- # 06:00 <yuletide> i have the db engine set to just postgres tho
- # 06:00 <yuletide> i have to pip install that too?
- # 06:00 <PressedWeb> pip install postgres?
- # 06:00 <FunkyBob> PressedWeb: why would you call save() on a queryset?
- # 06:00 <yuletide> no distro found
- # 06:00 <yuletide> matmcc how do i fix?
- # 06:00 <yuletide> mattmcc how do i fix?
- # 06:00 <yuletide> wish it were in the tutorial :)
- # 06:00 <PressedWeb> FunkyBob: Was just curious if there was a way to open up shell and do something like... c = Car.objects.all() reverso_cars = c.reverse() reverso_cars.save()
- # 06:00 <PressedWeb> and then be able to use reverso_cars in a template.
- # 06:00 <PressedWeb> yuletide
- # 06:00 <PressedWeb> pip install psycopg2
- # 06:00 <mattmcc> PressedWeb: You can update() a queryset to update specific fields.
- # 06:00 <FunkyBob> PressedWeb: makes no sense
- # 06:00 <PressedWeb> yuletide: Are you on Linux?
- # 06:00 <PressedWeb> FunkyBob: Hey, I'm a newbie. It doesn't have to make sense.
- # 06:00 <yuletide> osx
- # 06:00 <FunkyBob> PressedWeb: what are you expecting it to save?
- # 06:00 <PressedWeb> That variable
- # 06:00 <PressedWeb> For use in templates
- # 06:00 <PressedWeb> I know it's a long shot and stupid
- # 06:00 <PressedWeb> But I figured I'd ask
- # 06:00 <FunkyBob> if you want to use it in a template, put it in the Context
- # 06:00 <PressedWeb> In case there was some other way to do something similar from shell
- # 06:00 <PressedWeb> Otherwise, what's the purpose of shell? Just to modify the database?
- # 06:00 <FunkyBob> there's no need to save it... a QuerySet is generally cheap to create
- # 06:00 <PressedWeb> That's true
- # 06:00 <PressedWeb> I supposed I figured QuerySets might get really complex and it'd be nice to save variables for use later
- # 06:15 <PressedWeb> yuletide: What are you trying to do? Set up a Postgres database and connect it to Django?
- # 06:15 <yuletide> yayy
- # 06:15 <yuletide> it worked
- # 06:15 <PressedWeb> :)
- # 06:15 <yuletide> ACTION dances
- # 06:15 <yuletide> thanks :D
- # 06:15 <PressedWeb> de nada
- # 06:15 <PressedWeb> FunkyBob: See me pay it forward right there? :D
- # 06:15 <PressedWeb> There's more where that came from.
- # 06:15 <bradleyayers> this is probably a 1.4 blocker
- # 06:15 <bradleyayers> unless i just noobed up big time
- # 06:15 <PressedWeb> ?
- # 06:15 <bDreadz> PressedWeb: for your reverse define that as a method in your model and call on that. I would think. I'm pretty noob. That's how I'd go about it though.
- # 06:15 <PressedWeb> Yeah, I'm sure it would. I really just ask stupid questions so I can thoroughly understand something.
- # 06:30 <PressedWeb> I was pretty sure there was no way to do derp.herp().savethisjunkforuseintemplate(), but gotta make sure so I ask the gurus.
- # 06:30 <PressedWeb> ;)
- # 06:30 <PressedWeb> Legit question, is it possible to have a space between words in an app name?
- # 06:30 <yuletide> hm
- # 06:30 <yuletide> error importing timezone from django.utils
- # 06:30 <yuletide> i dont see anything in the tutorial about preqs related to this
- # 06:30 <PressedWeb> If I had an app named big_cats, and in Admin I wanted it to say Big Cats, how could I do that? By default it does Big_Cats
- # 06:30 <PressedWeb> What timezone are you using?
- # 06:30 <yuletide> America/Vancouver
- # 06:30 <yuletide> but it wont let me import the library at all
- # 06:30 <yuletide> i'm just following the tutorial
- # 06:30 <yuletide> from django.utils import timezone
- # 06:30 <yuletide> this sucks
- # 06:30 <PressedWeb> Are you manually adding that to settings.py?
- # 06:30 <yuletide> no...
- # 06:30 <PressedWeb> Hm.
- # 06:30 <yuletide> "# Support for time zones is enabled in the default settings file, so"
- # 06:30 <yuletide> i'm just following the tutorial
- # 06:30 <PressedWeb> What tutorial?
- # 06:30 <yuletide> https://docs.djangoproject.com/en/dev/intro/tutorial01/
- # 06:30 <yuletide> the django tutorial :)
- # 06:30 <PressedWeb> Try America/Chicago
- # 06:30 <PressedWeb> See if it works
- # 06:30 <FunkyBob> the one in the docs
- # 06:30 <FunkyBob> the one _everyone_ should have done
- # 06:30 <yuletide> ?
- # 06:30 <yuletide> the problem is importing the timezone library
- # 06:30 <yuletide> i cant do it in a fresh python prompt either
- # 06:30 <FunkyBob> have you installed the timezone lib?
- # 06:30 <yuletide> is that not included with django?
- # 06:30 <PressedWeb> It should be
- # 06:30 <yuletide> guess not
- # 06:30 <yuletide> its part of django.utils no?
- # 06:30 <PressedWeb> When you install Django, it should install timezone
- # 06:30 <yuletide> no i haven't install anything
- # 06:30 <PressedWeb> Yeah, that's what I'd think
- # 06:30 <yuletide> i'm doing it in virutalenv
- # 06:30 <yuletide> just django and psycopg2
- # 06:30 <PressedWeb> Did you pip install django?
- # 06:30 <yuletide> yes
- # 06:30 <PressedWeb> INSIDE of your virtualenv?
- # 06:30 <PressedWeb> Or outside for your whole system?
- # 06:30 <PressedWeb> Try workon my_virtual_env
- # 06:30 <PressedWeb> then pip install django
- # 06:30 <PressedWeb> er, pip freeze
- # 06:30 <PressedWeb> See what you have installed on your virtualenv
- # 06:30 <PressedWeb> If Django doesn't show up, then your virtualenv doesn't have django
- # 06:30 <PressedWeb> And you'll need to do pip install virtualenv
- # 06:30 <PressedWeb> er pip install django
- # 06:30 <yuletide> i have pip installed django yes
- # 06:30 <PressedWeb> To your virtualenv?
- # 06:30 <yuletide> yes
- # 06:30 <PressedWeb> You have Skype?
- # 06:30 <yuletide> "Requirement already satisfied (use --upgrade to upgrade): django in ./lib/python2.7/site-packages"
- # 06:30 <PressedWeb> Type "deactivate"
- # 06:30 <PressedWeb> What's it say?
- # 06:30 <yuletide> it deactivated
- # 06:30 <yuletide> i may just call it a night, this is pissing me off
- # 06:30 <yuletide> python >>> from django.utils import timezone
- # 06:30 <yuletide> fails also
- # 06:30 <yuletide> and i have django pip'd globally as well
- # 06:30 <PressedWeb> Are you using Django for anything globally?
- # 06:30 <PressedWeb> If not, uninstall it
- # 06:30 <PressedWeb> pip uninstall django (while you're not in your virtualenv)
- # 06:30 <PressedWeb> then workon my_virtual_env
- # 06:30 <PressedWeb> then pip install django
- # 06:30 <PressedWeb> I'd say if you uninstall all instances of Django and create a new virtualenv, you won't get that weirdness
- # 06:30 <yuletide> requirement already satisfied
- # 06:30 <PressedWeb> Really seems like something is corrupt. Have you tried Googling it?
- # 06:30 <yuletide> reinstalling django in my virutalen
- # 06:30 <yuletide> \
- # 06:30 <yuletide> v
- # 06:30 <yuletide> still cannot import name timezone
- # 06:30 <yillkid> Hi all I want to extend UserProfile class to the "add user" page, should I edit the views.py file ?
- # 06:45 <FunkyBob> yillkid: what add user page?
- # 06:45 <yillkid> FunkyBob: "/admin/auth/user/add/" page, I want to add some field in .
- # 06:45 <FunkyBob> yillkid: the Admin page... ok
- # 06:45 <yuletide> no google hits
- # 06:45 <yuletide> totally fubar
- # 06:45 <PressedWeb> yuletide: Sorry man. I have no idea. :(
- # 06:45 <FunkyBob> yillkid: i'ev seen an app that lets you meddle like that
- # 06:45 <yuletide> thanks for tryin :)
- # 06:45 <yuletide> is it maybe not in django 1.3.1
- # 06:45 <PressedWeb> np, sorry again. Best of luck. If I had a Mac I'd try to replicate.
- # 06:45 <FunkyBob> yuletide: no, it's not in 1.3.1
- # 06:45 <yuletide> that could do it
- # 06:45 <yuletide> the tutorial is for 1.4
- # 06:45 <yuletide> pip doesn't install 1.4
- # 06:45 <yuletide> for me at least
- # 06:45 <yuletide> is there a way to change that btw?
- # 06:45 <Qalqi> wats to_field alternative to manytomanyfield?
- # 06:45 <yillkid> FunkyBob: You have seen an app ? can you give me a cule ?
- # 06:45 <FunkyBob> Qalqi: probably using a through model
- # 06:45 <yuletide> now i'm getting "Settings cannot be imported because enviro var Django_settings_module" is undefined
- # 06:45 <FunkyBob> yuletide: yep
- # 06:45 <yuletide> is it recommended to use 1.4 at this point?
- # 06:45 <FunkyBob> it's due to release within the week... so... sure
- # 06:45 <yuletide> how do i install it with pip?
- # 06:45 <FunkyBob> pip install svn+{get the svn url from the install page}
- # 06:45 <yuletide> hm
- # 06:45 <yuletide> k
- # 06:45 <yillkid> FunkyBob: Now I can add some filed to the UserProfile class, and I can Modify "add user" template, But I don't how to pass UserProfile filed to the new template .
- # 06:45 <FunkyBob> better option would be to customise the _form_ that admin uses
- # 06:45 <FunkyBob> but it sounds like you're talking about editing two objects at once
- # 06:45 <FunkyBob> probably better to monkey-patch the User admin class to have your UserProfile as a on inline
- # 07:00 <FunkyBob> ACTION can hear the F1s practising
- # 07:00 <bradleyayers> mattmcc: http://dpaste.com/717287/
- # 07:00 <bradleyayers> ./runtests.py --settings=test_sqlite urlpatterns_reverse
- # 07:00 <bradleyayers> FunkyBob: u look 2
- # 07:00 <FunkyBob> bradleyayers: YES, SIR! o>
- # 07:00 <yillkid> FunkyBob: Sorry, I can't understand .
- # 07:00 <bradleyayers> http://dpaste.com/717288/
- # 07:00 <bradleyayers> mattmcc: FunkyBob http://dpaste.com/717288/
- # 07:00 <bradleyayers> (fixed expected URL from reverse())
- # 07:00 <FunkyBob> yillkid: do you know about Inlines in admin classes?
- # 07:00 <yillkid> FunkyBob: I think I just need modify my views.py th bridge my model and template file ?
- # 07:00 <bradleyayers> FunkyBob: i feel like you're patronizing me after my complaining of you not respecting me
- # 07:00 <yillkid> FunkyBob: Inlines ... I don't know ... I googling ..
- # 07:00 <FunkyBob> yillkid: don't google it.. read the Admin docs!
- # 07:00 <FunkyBob> bradleyayers: you're the one who ordered me about :P
- # 07:00 <yillkid> FunkyBob: OK .
- # 07:00 <bradleyayers> FunkyBob: what do you think of my patch?
- # 07:00 <FunkyBob> yillkid: it may save you days of crazy wasted work
- # 07:00 <yillkid> FunkyBob: sorry, the link is what you say right? http://readthedocs.org/docs/django/en/latest/ref/contrib/admin/index.html#django.contrib.admin.InlineModelAdmin
- # 07:00 <FunkyBob> ...
- # 07:00 <FunkyBob> https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#inlinemodeladmin-objects
- # 07:00 <FunkyBob> you know... the _actual_ django docs
- # 07:00 <bradleyayers> FunkyBob: huh what? isn't the real docs google?
- # 07:15 <jiaji> I have a class EmailUserCreationForm(UserCreationForm), and an extra EmailField in it, somehow it won't go into form.fields, I changed the EmailField to a dozen of other types of field, they all come out fine, what's going on here?
- # 07:15 <pr0ton> https://docs.djangoproject.com/en/dev/ref/forms/api/#styling-required-or-erroneous-form-rows
- # 07:15 <pr0ton> is there any easy way by which i can set the class of the input field?
- # 07:15 <pr0ton> instead of the row?
- # 07:15 <bradleyayers> pr0ton: use 'attrs' argument to the widget
- # 07:15 <pr0ton> ok
- # 07:15 <jiaji> and if I add a label to it, I got an exception http://dpaste.com/
- # 07:15 <ses1984> i'm having trouble diagnosing a problem when trying to create a model object. i get DatabaseError: can't adapt http://dpaste.com/717292/
- # 07:15 <jiaji> and if I add a label to it, I got an exception http://dpaste.com/717291
- # 07:15 <FunkyBob> ses1984: you're passing something to the DB layer that it doesn't know how to turn into a DB-friendly value
- # 07:15 <ses1984> i have just dropped all the tables in my app and re-did a syncdb, so that shouldn't be a problem
- # 07:15 <FunkyBob> it's not about that
- # 07:15 <ses1984> the model definition and data i'm trying to pass in are right in the paste at the top and they seem to look alright to me
- # 07:15 <FunkyBob> ses1984: what's all that about multi-line parsing errors?
- # 07:15 <ses1984> i'm not sure...it shows up in my python console sometimes depending on where in my code an exception is raised
- # 07:15 <bradleyayers> FunkyBob: what'd you think
- # 07:30 <ses1984> if it's raised within django code then that comes up, if it's raised in my project code it doesn't. it's peculiar but i haven't thought a lot about it
- # 07:30 <ses1984> the first number in that tuple is the line where the error occured in my code, but i was calling a django function at that line and something went wrong there...like you said in the db layer somewhere
- # 07:30 <ses1984> "The error message is: ('EOF in multi-line statement', (175, 0))"
- # 07:30 <ses1984> line 175
- # 07:30 <ses1984> at line 175 is t = Team.objects.get_or_create(**team_dict)
- # 07:30 <ses1984> i was in interactive python and called a method that has that line in the source at 175
- # 07:30 <ses1984> am i making sense at all?
- # 07:30 <ses1984> i probably shouldn't have even pasted it, it's inconsequential to the problem
- # 07:30 <ses1984> i didn't realize that before i guess
- # 07:30 <pr0ton> how do i go about handling multiple number of file uploads?
- # 07:30 <pr0ton> like i can have 0...n number of file uploads. n is a variable
- # 07:30 <pr0ton> how can i do that using django forms?
- # 07:45 <bradleyayers> FunkyBob: mattmcc https://code.djangoproject.com/ticket/17914
- # 07:45 <mattmcc> Interesting.
- # 07:45 <yillkid> FunkyBob: Hi "Admin inline model" just can add my model into "admin page" via "admin.site.register", but if I want to add my model data into "add user page" ? it seen can't ?
- # 07:45 <PressedWeb> I've created some "Person" objects in Django complete with an ImageField but I can't seem to access those pictures.. I've set my MEDIA_ROOT, didn't set my MEDIA_URL. Do I have to do that? It seems like it's appending a slash to the end of the URL
- # 07:45 <bradleyayers> mattmcc: unfortunately for me the urlresolver stuff got more complex is 1.4 :(
- # 07:45 <bradleyayers> with language specific urls
- # 07:45 <bradleyayers> hpefully i can come up with a patch to fix it :/
- # 07:45 <mattmcc> Well, it wouldn't hurt to put it in front of the eyes of someone in #django-dev, too.
- # 07:45 <bradleyayers> good idea.
- # 08:00 <PressedWeb> Is it cool to use backslashes in MEDIA_URL?
- # 08:00 <PressedWeb> (windows)
- # 08:00 <FunkyBob> PressedWeb: no
- # 08:00 <ses1984> i'm still having trouble trying to diagnose a DatabaseError: can't adapt
- # 08:00 <ses1984> http://dpaste.com/717303/
- # 08:00 <PressedWeb> FunkyBob: Any suggestions for defining a MEDIA_URL (so I can access uploaded pics and such) on Windows?
- # 08:00 <Escherial> hey, do any of you have suggestions for running a lightweight django webserver on windows? i was considering nginx, but it seems like the windows version isn't as good at the unix one (it only supports select() polling of sockets, for instance...which, on second thought, might not be a disadvantage, necessarily, but it's not IOCP...)
- # 08:00 <Escherial> i know i could run apache, but i've never had much luck getting it to work :\
- # 08:00 <Escherial> (also, it's kind of on the not-lightweight side...)
- # 08:00 <PressedWeb> Eh. Thanks anyway for the help. I'm exhausted. G'night guys.
- # 08:15 <FunkyBob> Escherial: surely you're not deploying on windows?
- # 08:15 <prometheus> I don't always deploy, but when I do I make sure it's on windows.
- # 08:15 <Qalqi> http://dpaste.com/717306/
- # 08:15 <Qalqi> hello, what does __in match stuff with -primary keys?
- # 08:15 <FunkyBob> Qalqi: you have a lst of what would go in Tag.details ?
- # 08:15 <Qalqi> how should i get __in filter query to match some field in a model and not with a primary key?
- # 08:15 <Escherial> FunkyBob: no, it's a tool for my personal use
- # 08:15 <FunkyBob> Escherial: so what's wrong with runserver?
- # 08:15 <Escherial> i suppose i could just use the dev server, but it's serving up a lot of static content
- # 08:15 <FunkyBob> gunicorn?
- # 08:15 <Qalqi> list comprises of Tag.tag
- # 08:15 <Escherial> cool, gunicorn it is :) thanks!
- # 08:15 <FunkyBob> Qalqi: then you must filter on tags__tag__in=
- # 08:15 <FunkyBob> Qalqi: since you want to compare against the tag field on the objects through the tags relation
- # 08:45 <yillkid> FunkyBob: I think I need a good example ... :'(
- # 09:30 <FunkyBob> muddy bucket of plaster an pitch!
- # 09:30 <mattmcc> Ugly bags of mostly water..
- # 09:30 <FunkyBob> mattmcc: trekkie
- # 09:30 <FunkyBob> fuck
- # 09:30 <FunkyBob> this combination is causing a cartesian join
- # 09:30 <FunkyBob> so my counts are the square of what they ought be
- # 09:30 <mattmcc> Have you curb stomped your SQL DB today?
- # 09:30 <FunkyBob> clearly not enough
- # 09:30 <FunkyBob> hmm
- # 09:30 <FunkyBob> wait...
- # 09:30 <FunkyBob> yeah... the same x->y->z is in there twice
- # 09:30 <FunkyBob> second time with table aliases
- # 09:45 <FunkyBob> ok... found what's causing it
- # 09:45 <raj> if I provide js with a url for an img tag's src, I need to change the mime-type? cuz I'm getting "Resource interpreted as Image but transferred with MIME type application/octet-stream"
- # 09:45 <mattmcc> Eh, how is your server handling the image?
- # 09:45 <mattmcc> Besides 'badly'
- # 09:45 <FunkyBob> raj: is this using runserver ?
- # 09:45 <raj> what's that?
- # 09:45 <FunkyBob> !?!?
- # 09:45 <FunkyBob> you know... when you type "./manage.py runserver"
- # 09:45 <raj> so django handles it automatically
- # 09:45 <raj> interesting
- # 09:45 <FunkyBob> huh?
- # 09:45 <raj> does django normally handle mime-type with /manage.py runserver?
- # 09:45 <FunkyBob> well, I was going to suggest the issue may be that it _doesn't_
- # 09:45 <FunkyBob> but you'd actually have to answer my question
- # 09:45 <raj> :)
- # 09:45 <raj> no, not with runserver =P
- # 09:45 <FunkyBob> so... what are you serving the images with?
- # 09:45 <FunkyBob> because that's what's to blame
- # 09:45 <mattmcc> It will handle static files automatically, but not user-uploaded media.
- # 09:45 <FunkyBob> ok... time to go home
- # 09:45 <mattmcc> How to tell when Google's creeping you out:
- # 09:45 <mattmcc> In Gmail, the ad it gave me is for a hotel which is roughly 80 yards to the south of me.
- # 10:15 <yillkid> FunkyBob: Sorry, after django doc reading, I still having question, can I ask you ? :)
- # 10:30 <hubx> hi there, what is the way to go for django ajax form validation?
- # 10:30 <jeverling> hi all, is it safe to use set() to get a distinct list of Django model objects? I know about distinct(), just wondering.
- # 10:30 <jeverling> safe in the sense of you will really only get distinct objects
- # 10:30 <Maior> as opposed to what with distinct()....?
- # 10:30 <jeverling> I expect it to yield exactly the same result as distinct()
- # 10:30 <IanWizard-Cloud> I have a django db, it is sqlite based, and I want to transfer it to a mysql db.
- # 10:30 <IanWizard-Cloud> Is there any good way to do that?
- # 10:30 <jeverling> IanWizard-Cloud: I would try with dumpdata and loaddate (fixtures)
- # 10:30 <jeverling> python manage.py dumpdata --indent 2
- # 10:30 <jeverling> will give you a JSON fixture
- # 10:30 <IanWizard-Cloud> just to, setup a secondary db in the settings, and then read all of the objects over?
- # 10:30 <jeverling> you should be able to import this into mysql using manage.py loaddate
- # 10:30 <jeverling> loaddata
- # 10:30 <IanWizard-Cloud> yeah, but for my site, that will be rather slow
- # 10:30 <IanWizard-Cloud> ok, I'll do it the "right' way :P
- # 10:30 <jeverling> don't know if that is the right way, but it will work. Using a dump and convert it somehow (there should be plenty of tools for that) should work equally well.
- # 10:45 <Qalqi> if I have print some x in my view, where does it get print during execution of that view?
- # 10:45 <Maior> Qalqi: 'print"? "execution"?
- # 10:45 <jeverling> Qalqi: I assume you mean in production, when run by a webserver like apache?
- # 10:45 <Qalqi> i mean when the view is called, how will the print command be executed
- # 10:45 <jeverling> i think it will just be ignored
- # 10:45 <jeverling> you should use logging for this
- # 10:45 <Qalqi> wats the command for logging and where is it logged into?
- # 10:45 <Maior> Qalqi: see the django docs re logging
- # 10:45 <Qalqi> ok
- # 10:45 <jeverling> https://docs.djangoproject.com/en/1.3/topics/logging/
- # 10:45 <Qalqi> django-debug-toolbar doesnt show up when I render templates. I dunno why
- # 10:45 <Qalqi> should I add any argument torender_to_response() for it to show up?
- # 10:45 <mattmcc> Missing part of the installation requirements?
- # 10:45 <jeverling> debug toolbar will only work when you have DEBUG=True, and i think you will also have to set INTERNAL_IPS
- # 10:45 <jeverling> changing anything in the arguments to render_to_response isn't necessary
- # 10:45 <Qalqi> it works for some pages but not when I shortcuts like render, render_to_response
- # 10:45 <niluje> I have a table with thousands of rows. I'd like to return a CSV of +100k rows. What is the most efficient way to do this? Requesting and looping over resuls in a template is too long
- # 10:45 <jeverling> Qalqi: no idea, sorry. if the order or your MIDDLEWARE_CLASSES is ok then it should show up for all views, i think
- # 10:45 <jeverling> of
- # 11:45 <demorose> hi
- # 12:00 <Adys> how do I add a blank label to a form with a choice field?
- # 12:00 <Adys> modelchoice has that but not choicefield
- # 12:00 <Maior> hm, can I loaddata from stdin?
- # 12:15 <FunkyBob> Maior: I don't think so
- # 12:15 <Maior> mmm, I just discovered http://rockycode.com/blog/django-loaddata-heroku/ (my use-case for this) - time for some grimness
- # 12:15 <Maior> cheers though
- # 12:15 <FunkyBob> np
- # 12:15 <tktiddle> why is the urlconf loaded into the request object? whats that for? Is it always a pyhton module object or can it also return a string?
- # 12:15 <FunkyBob> tktiddle: umm... according to the docs, it's not
- # 12:15 <FunkyBob> not loaded, that is
- # 12:15 <FunkyBob> HttpRequest.urlconf
- # 12:15 <FunkyBob> Not defined by Django itself, but will be read if other code (e.g., a custom middleware class) sets it. When present, this will be used as the root URLconf for the current request, overriding the ROOT_URLCONF setting. See How Django processes a request for details.
- # 12:15 <tktiddle> It should be set as a string right?
- # 12:30 <pfote> hi
- # 12:30 <pfote> erm. while formulating my question, i found the answer. tnx guys :-)
- # 12:30 <Maior> hm, I seem to have a deployment here with no sites - this is hampering my ability to log in to the admin ui
- # 12:30 <Maior> is there a nice way of fixing this short of manual db-pokery?
- # 12:30 <Jax> Maior: just create a new site in the shell?
- # 12:30 <Jax> Site.objects.create(...
- # 12:30 <Maior> ...of course, sorry
- # 12:30 <Maior> doing the foolish thing and panicking slightly, which clouds my thinking
- # 12:30 <Jax> take it easy, it's friday
- # 12:30 <Jax> ;)
- # 12:30 <Maior> whew, thanks
- # 12:45 <Qalqi> Instead of giving reference or pk to a manyrelatedmanager.add how can I give some other field as an argument?
- # 12:45 <Qalqi> say 'pizza.toppings_set.add(topping1.pk)' is fine but how to do this 'pizza.toppings_set.add(topping1.name)' ?
- # 12:45 <apollov> Hello there. I use django-tinymce, and trying to add a `class` field to a `link` editor window. How can I achieve my goal? At the moment, I see that field in a template, but can't see it in a admin interface, so cannot I figure out what config string do I have to pass. Anty help will be appreciated.
- # 13:00 <raj> can i not send a url withon a json object? it seems to get encoded
- # 13:00 <Jygga> raj depends on what you tell your serializer to do and whatnot
- # 13:00 <Maior> Qalqi: think you'll have to have the second lookup
- # 13:30 <Thaidaree> here's a quick question. what happens with primary key in postgres on transaction rollback from django?
- # 13:30 <no_freedom> I am getting error message "username Enter a list of values in form". But I already define required=False for username. Here is my statement > username = forms.MultipleChoiceField(required=False, choices=get_my_choices()). Here is my full form http://dpaste.org/IOXx2/. Will you please help me ?
- # 13:30 <glauco29> how can I remove a table without remove related tables
- # 13:30 <glauco29> ?
- # 13:45 <bryanp_> Is it funky to have multiple M2M fields on one object/model?
- # 13:45 <bryanp_> Tickets belong to Sites, Tags belong to Tickets. I need tags to be M2M to both Tickets & Sites. That not weird?
- # 14:00 <talin> i have a ModelForm with fields = ("blah", "foo", ...)... is there a way to set one of those to required=False?
- # 14:00 <bryanp_> Tickets belong to Sites, Tags belong to Tickets. I need tags to be M2M to both Tickets & Sites. That not weird?
- # 14:00 <pfote> bryanp_: nope
- # 14:00 <bryanp_> pfote: A pretty normal thing to do? I just don't want to end up with some crazy ass DB that people never do.
- # 14:00 <bryanp_> Also, does it really matter which 'way' I make the M2M? Like, should I put the M2M field on one object and not the other? Or is either way the same?
- # 14:00 <pfote> bryanp_: its not totally common, but not weird either, at least from a database point of view, cant say about django, i'm not really expert here
- # 14:00 <bryanp_> pfote: Thanks
- # 14:15 <ptoal> Is there any way to use the %(key)s string formatting with django model attributes?
- # 14:15 <ptoal> I.e., "%(id) - %(name)" % mymodel_instance
- # 14:15 <ptoal> I.e., "%(id)s - %(name)s" % mymodel_instance
- # 14:15 <ptoal> (which doesn't work, btw, because mymodel_instance "isn't subscriptable")
- # 14:30 <lauxley> ptaol "%(id) - %(name)" % (mymodel_instance.id, mymodel_instance.name)
- # 14:30 <bigkevmcd> lauxley: that wouldn't work
- # 14:30 <lauxley> ?
- # 14:30 <ptoal> Actually, I _was_ using "%s - %s" % (my.id, my.name) already
- # 14:30 <ptoal> I was just trying to shorten it.
- # 14:30 <lauxley> oh yeah sorry you have to use format()
- # 14:30 <ptoal> And str.format() seems to be the way to go in the future, according to the folks in #python
- # 14:30 <rohit_nsit08> hello #django
- # 14:30 <rohit_nsit08> can someone please tell me how to get django default admin work with mongodb, I can see the collections but can't edit them ... ( I am not using any dictfield or other particular things of mongodb )
- # 14:30 <rohit_nsit08> I tried to add user to auth_user
- # 14:30 <rohit_nsit08> and it says query not supported
- # 14:30 <Maior> rohit_nsit08: django-nonrel?
- # 14:30 <rohit_nsit08> Maior: hi, ya django-nonrel
- # 14:30 <seeg> hello
- # 14:30 <seeg> how can i add a field called 'user_email' but only when the user is logged in, in django forms.Form?
- # 14:30 <graingert> I seem to remember there was a way to get a databased model object from a non database model object
- # 14:30 <graingert> database backed*
- # 14:30 <rohit_nsit08> Maior: is there any support for mongodb backend in new release of django?
- # 14:30 <graingert> eg b = Blog(slug="food-for-thought")
- # 14:30 <graingert> and because slug is unique
- # 14:30 <graingert> I can grab the database backed version
- # 14:45 <rdodev> Morning folks, quick question: what's the recommended model field type for a field containing a comma separated list of strings? Just CharField? Text?
- # 15:00 <forcer> There's CommaSeparatedIntegerField, but I guess you mean strings and not ints?
- # 15:00 <rdodev> forcer: yeah it's strings, not ints
- # 15:00 <forcer> rdodev: The "correctness geek" in me would like to suggest using a separate table :-]
- # 15:00 <forcer> Guess you could look at how CommaSeparatedIntegerField is implemented and do something similar for your use case
- # 15:00 <rdodev> forcer: I would tend to agree, but it's not me making the DB schema decisions :/
- # 15:00 <rdodev> maybe turn then string into the integer representation of bytes and then parse them back? :D
- # 15:00 <rdodev> I think I'm gonna go with text given than it can be a rather substantial list.
- # 15:00 <raczman> im trying to use django-knowledge, but i have some urlpatterns pains
- # 15:00 <raczman> gimme a sec to dpaste that
- # 15:00 <raczman> http://dpaste.org/Vzmfi/
- # 15:00 <raczman> i want to customize urls, that's why i pasted them to my urlconf
- # 15:00 <raczman> so, what did i screw up?
- # 15:00 <rdodev> RegExes are super powerful, but doggone they're nasty to read
- # 15:00 <raczman> oh wait, fixed my issues
- # 15:00 <rdodev> sorry racz, not a RegEx kind of guy
- # 15:00 <raczman> thanks to whoever read that though
- # 15:00 <forcer> I've found that the automatic concatenation of strings (or verbose regexes) can make them relatively easy to read. Relatively. And you need to make sure they are.
- # 15:00 <raczman> rdodev: i had to paste that include line into main urlpatterns declaration
- # 15:00 <raczman> and it worked
- # 15:00 <rdodev> forcer: what kills me it's the "idioms" and modifiers prefix/sufix type of thing.
- # 15:00 <forcer> rdodev: Oh, you mean the *TOTALLY INTUITIVE* stuff like (?<= ...)?
- # 15:00 <rdodev> It fells I'm reading Perl :o
- # 15:00 <rdodev> forcer: precisely
- # 15:00 <forcer> Yeah.
- # 15:00 <forcer> (Well, I guess you could say that a lot of that syntax was established *by* Perl, so in a sense you are.)
- # 15:00 <raczman> forcer: regexr.com helps masively when writing urlconf
- # 15:00 <raczman> i wouldnt do shit without it
- # 15:00 <Aut0Exec> can someone please give me a straight forward way to deploy multiple apps that are in virtualenv using mod_wsgi
- # 15:00 <Aut0Exec> multiple projects i should say
- # 15:00 <Aut0Exec> been trying for over a day and cant find a good way
- # 15:00 <raczman> Aut0Exec: lemme paste that for ya
- # 15:00 <Aut0Exec> raczman: oh thank you so much bro
- # 15:00 <raczman> oh wait, i use uwsgi
- # 15:00 <raczman> but it is virtualenved
- # 15:00 <Aut0Exec> :(
- # 15:00 <raczman> still want it?
- # 15:00 <Aut0Exec> ok its worth a shot
- # 15:15 <raczman> Aut0Exec: wait, i found another server that uses apache+mod_wsgi
- # 15:15 <raczman> im digging there
- # 15:15 <Aut0Exec> ok awesome :)
- # 15:15 <raczman> damnit, it doesnt use virtualenv
- # 15:15 <raczman> but my admin guy pointed me to this link
- # 15:15 <raczman> http://jmoiron.net/blog/deploying-django-mod-wsgi-virtualenv/
- # 15:15 <Aut0Exec> oh i saw this already.... doesnt work for me
- # 15:15 <ptoal> ACTION confused...
- # 15:15 <Aut0Exec> also.. he doesn't explain multiple projects
- # 15:15 <Aut0Exec> raczman: but thanks for the effort bro
- # 15:15 <Aut0Exec> preciate it anyways
- # 15:15 <ptoal> I have a model with a computed property that I can't seem to access from a template.
- # 15:15 <ptoal> I can access all the other fields just fine, but not the @property methods.
- # 15:15 <ptoal> I.e.: {{ line.price }} (where price is a DecimalField) works
- # 15:15 <ptoal> {{ line.extended_price }} where extended_price is an @property function doesn't.
- # 15:15 <ptoal> Is that expected behaviour?
- # 15:15 <raczman> Aut0Exec: ill molest him until he gives a coherent answer
- # 15:15 <Aut0Exec> raczman: lol ok thanks bro
- # 15:15 <ptoal> It doesn't seem right to me.
- # 15:30 <raczman> anyone in here has some experience with localising django apps?
- # 15:30 <piquadrat> Hi. Is it possible to disable APPEND_SLASH for certain URLs? I have a view that protects access to a file, but django appends a slash to the file name in the URL, so most browsers can't figure out the name of the file
- # 15:45 <graingert> how do I grab the code out of a ValidatorError exception?
- # 15:45 <graingert> it is not documented in https://docs.djangoproject.com/en/dev/ref/exceptions/#django.core.exceptions.ValidationError
- # 15:45 <graingert> also seems odd that I have to check inside the exception to determine the exception type
- # 15:45 <graingert> but I guess that's to support multiple exceptions in one go
- # 15:45 <silent1mezzo> graingert: what do you mean by code?
- # 15:45 <graingert> silent1mezzo: code: The error code used by ValidationError if validation fails. Defaults to "invalid".
- # 15:45 <graingert> https://docs.djangoproject.com/en/dev/ref/validators/#django.core.validators.RegexValidator.code
- # 15:45 <graingert> is that code value available anywhere?
- # 15:45 <Aut0Exec> if i'm using a virtualenv how to i make my app use my python path from my virtualenv?
- # 15:45 <raczman> graingert:
- # 15:45 <raczman> argh
- # 15:45 <raczman> not this terminal
- # 15:45 <raczman> sorry graingert
- # 15:45 <graingert> unacceptable
- # 15:45 <graingert> (nah it k)
- # 15:45 <graingert> silent1mezzo: worked it out yet?
- # 15:45 <silent1mezzo> ah
- # 15:45 <silent1mezzo> nope, never worked with that stuff..
- # 16:00 <graingert> anyone who had?
- # 16:00 <graingert> has*
- # 16:00 <ptoal> ACTION is pulling his hair out...
- # 16:00 <ptoal> If I try to access {{ foo.decimal }} where decimal is a property method returning a decimal.Decimal(), it doesn't display anything.
- # 16:00 <dekuked> hey, what does this mean, I'm getting it in my apache error log: TemplateSyntaxError: Caught ImportError while rendering: No module named blah
- # 16:00 <dekuked> blah is the name of an app in the main django folder
- # 16:00 <ptoal> dekuked: When you say "main django folder", do you really mean in your project directory?
- # 16:00 <cjohnston> I just created a new server, installed django 1.3.1, python 2.6, and a few other things.. The install is missing CollapsedFieldsets.js -- any idea why it would be missing this?
- # 16:15 <ptoal> cjohnston: What do you mean "missing" it?
- # 16:15 <graingert> cjohnston: collect static
- # 16:15 <graingert> for your admin pages
- # 16:15 <cjohnston> ptoal: the file doesn't exist..
- # 16:15 <ptoal> cjohnston: I presume you mean that you're web browser is unable to load it?
- # 16:15 <ptoal> If so, then graingert is right.
- # 16:15 <ptoal> You need to collect your static files.
- # 16:15 <cjohnston> ptoal: correct, but looking for the file it isnt found when browsing the server
- # 16:15 <ptoal> https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/
- # 16:15 <graingert> and ensure you have the static files and admin site loaded
- # 16:15 <graingert> maybe I need to use a form to access error codes
- # 16:15 <graingert> how pants
- # 16:15 <rdodev> General model question: when I have, say, Parent_Model and ChildModel, ForeignKey fields are defined in the ChildModel, correct? Now, if I have a Model and ExtendedModel with a one-to-one relatioship, should that one-to-one field be defined in the ExtendedModel, Model, or both?
- # 16:15 <Aut0Exec> can someone please help me with setting up virtualenv with django and mod_wsgi
- # 16:15 <Aut0Exec> i went thru a couple tuts but none work
- # 16:15 <ptoal> Aut0Exec: Sorry, but you're going to have to provide more information.
- # 16:15 <ptoal> We can't help you unless you give us a specific step that you're stuck on, or an error, etc.
- # 16:15 <ptoal> Unless you want to pay one of us to log into your server and do it for you. :)
- # 16:15 <joshuajonah> Aut0Exec: It's a pretty ominous thing you will have to debug to find the answer, it's not that your doing it wrong.
- # 16:15 <Aut0Exec> ptoal: i think i'm almost there but i'm getting "ImportError at / No module named myapp"
- # 16:15 <rdodev> Aut0Exec: I did it a while back, so my memory is not too fresh. I'd say look at your apache logs first, see if there's anything of value there
- # 16:15 <Aut0Exec> rdodev: ok i post my settings in dpaste
- # 16:15 <ptoal> Aut0Exec: Sounds like your pythonpath isn't setup properly
- # 16:15 <joshuajonah> Aut0Exec: Ok, then it cant find your app. Is it in the path?
- # 16:15 <Aut0Exec> ptoal: yes.s... i was just about to say that... lol
- # 16:15 <Aut0Exec> yes i am using mod_wsgi
- # 16:15 <joshuajonah> Forget about apache logs
- # 16:15 <Aut0Exec> how to specify my pythonpath so that it finds my python version in virtualenv?>
- # 16:15 <joshuajonah> Are you having issues with runserver or wsgi?
- # 16:15 <Aut0Exec> its using /usr/local/python
- # 16:15 <ptoal> PythonPath "['/path/to/project'] + sys.path"
- # 16:15 <joshuajonah> Aut0Exec: That's not a virtualenv
- # 16:15 <ptoal> In your apache.conf
- # 16:15 <ptoal> Ah...
- # 16:30 <rdodev> aut0exec: the easiest, but least elegant to fix that is to copy your app directory to your python's install site-packages :)
- # 16:30 <Aut0Exec> rdodev: :(
- # 16:30 <ptoal> Aut0Exec: What is your .wsgi file?
- # 16:30 <Aut0Exec> was trying to keep things seperate
- # 16:30 <Aut0Exec> ptoal: let me post my .wsgi file one sec
- # 16:30 <Maior> consider using gunicorn
- # 16:30 <ptoal> Maior: I think that's like solving an engine problem by changing the car.
- # 16:30 <rdodev> Aut0Exec: You can have it separate. It's just to test if that's the only issue you have
- # 16:30 <Maior> ptoal: sure
- # 16:30 <Aut0Exec> debug is showing that Python Executable: /usr/bin/python
- # 16:30 <Aut0Exec> i need this to be my python in my virtualenv
- # 16:30 <Aut0Exec> not this one
- # 16:30 <Maior> except ime a lot of people don't seem to particularly care about their server tech if they're asking that-sort-of-level-of-question in here
- # 16:30 <ptoal> Aut0Exec: In your httpd.conf, do you have a line like this: WSGIPythonHome /path/to/virtualenv ?
- # 16:30 <Aut0Exec> ptoal: no
- # 16:30 <ptoal> Maior: But again, I point out that you're not solving the problem. You're suggesting a major change, just beause of a minor issue.
- # 16:30 <ptoal> Aut0Exec: Try it. :)
- # 16:30 <Aut0Exec> in http.conf ok
- # 16:30 <Maior> ptoal: I don't claim to be solving the specific problem
- # 16:30 <Maior> ptoal: I'm offering a solution for what is potentially the overall problem
- # 16:30 <Aut0Exec> ls
- # 16:30 <Aut0Exec> ptoal: listen... path to my project ?
- # 16:30 <Aut0Exec> cuz i have that on top of my virtualhost
- # 16:30 <ptoal> Not path to your project.
- # 16:30 <Maior> (I don't claim it is The Fix That Should Be Taken, but I note Aut0Exec has asked this on days prior to this, and I wonder if the bigger-picture problem is "I cannot deploy django", with Apache just being a route taken to achieve that)
- # 16:30 <ptoal> path to your virtualenv home directory.
- # 16:30 <ptoal> in a shell type: echo $VIRTUAL_ENV
- # 16:30 <ptoal> And put that path in your httpd.conf as WSGIPythonHome
- # 16:30 <ptoal> Maior: I disagree.
- # 16:30 <Aut0Exec> ptoal: ok
- # 16:30 <ptoal> You're introducing technology religion to the problem.
- # 16:30 <Maior> ptoal: religion?
- # 16:30 <ptoal> Yeah... "my webserver is better than yours"
- # 16:30 <ptoal> Use gnunicorn because it's better than apache.
- # 16:30 <Maior> ptoal: try getting some context before the ad hominem
- # 16:30 <Maior> (I speak as an Apache / uwsgi user)
- # 16:30 <GrizzGreen[KU]> ptoal everyone knows jboss is the best web server /sarcasm
- # 16:30 <Absolute0> Is it possible to run runserver, such that on any error, it automatically restarts?
- # 16:30 <Maior> GrizzGreen: lol
- # 16:30 <Maior> ptoal: I'm merely trying to ensure that the right problem is being solved
- # 16:30 <ptoal> Maior: I think you're missing the point. Why suggest changing the underlying web server because of a problem getting wsgi to work?
- # 16:30 <ptoal> When it's clearly possible to make wsgi work with apache, given the correct configuration?
- # 16:30 <ptoal> Maior: Again... technology religion. A belief that the "problem" is the web server.
- # 16:30 <Maior> ptoal: because (excuse me while I dig out my irc logs) they've had this problem for some time now, so obviously haven't managed; I'm in no position to help with the Apache issue, but if the real problem in reality happens to be the one I suggest ("I can't get Django deployed" with no particular ties to how this is done) then my suggestion is potentially helpful
- # 16:30 <Maior> I make no claims as to the nature of the problem, I have no "belief" of what the problem is - it's precisely *because* I don't that I make the suggestion
- # 16:30 <latestrevision> Boys, boys, calm down.
- # 16:30 <PKKid2> NO!
- # 16:30 <ptoal> I'm calm. :) I'll stop flooding the channel with my philosophies on how to help users. :)
- # 16:30 <Maior> latestrevision: please don't bring gender into this?
- # 16:30 <latestrevision> Maior: I think ptoal is suggesting that, although your suggestions may be superior, that they don't address the specific problems that the user was encountering in the most minimal way possible.
- # 16:30 <Maior> latestrevision: I don't disagree
- # 16:30 <ptoal> I won't disagree either. :)
- # 16:30 <ptoal> How's it coming Aut0Exec ?
- # 16:30 <Aut0Exec> ptoal: trying to do it now
- # 16:45 <Maior> latestrevision: I disagree with being accused of having technology bias rather than merely trying to consider the bigger picture
- # 16:45 <m0no> Can I specify in a ModelForm that a field is hidden
- # 16:45 <ptoal> Ok. As Maior states, if you switch to gnunicorn he may be able to assist you better. I am willing to continue to help you get it to work on apache (as much as I can), if you chose that route.
- # 16:45 <Aut0Exec> ptoal: still nothing bro... and python path is still /usr/bin/python
- # 16:45 <mlavin> m0no: yes you can change the widget to HiddenInput
- # 16:45 <Maior> Aut0Exec: also note, http://www.caktusgroup.com/blog/2010/04/22/basic-django-deployment-with-virtualenv-fabric-pip-and-rsync/ has what looks like reasonable guidance on getting Apache to use your virtualenv
- # 16:45 <ptoal> Aut0Exec: pythonpath isn't /usr/bin/python.
- # 16:45 <ptoal> that's the path to the interpreter.
- # 16:45 <ptoal> I presume you're doing something like "which python"?
- # 16:45 <Aut0Exec> yes... it shouldnt be using that on e
- # 16:45 <Aut0Exec> yes
- # 16:45 <ptoal> So... "which python" will tell you which interpreter you are using for the _shell_.
- # 16:45 <Aut0Exec> yes
- # 16:45 <ptoal> If you want to "activate" your virtualenv for the _shell_ your using, you will need to execute: source /path/to/your/virtualenv/bin/activate
- # 16:45 <ptoal> It sounds like you're wrestling with virutalenv, not mod_wsgi.
- # 16:45 <Aut0Exec> ptoal: yes i have no problem doing that... but mod_wsgi needs to know this
- # 16:45 <Aut0Exec> i can run the server with runserver
- # 16:45 <Aut0Exec> but just not with apache
- # 16:45 <Maior> Aut0Exec: did you read the link I pasted?
- # 16:45 <Aut0Exec> not sure i'm even doing it right
- # 16:45 <rns> is there a way to keep track of a variable in a template?
- # 16:45 <ptoal> Aut0Exec: You can run it with runserver in your virtualenv, or in the main python?
- # 16:45 <Aut0Exec> ptoal: only inside virtualenv
- # 16:45 <Aut0Exec> Maior: i am about to
- # 16:45 <Aut0Exec> Maior: thanks man
- # 16:45 <Maior> specifically the bit about appending to site_packages
- # 16:45 <Maior> (obviously replace the path given to the path with your virtualenv's site packages)
- # 16:45 <ptoal> So your prompt looks something like: (myvenv)machine: ?
- # 16:45 <ptoal> And is myapp in your project directory, or in site-packages?
- # 16:45 <Aut0Exec> ptoal: yes
- # 16:45 <Aut0Exec> in project directory
- # 16:45 <Aut0Exec> not in site packages
- # 16:45 <ptoal> Ah... that's different.
- # 16:45 <ptoal> That's probably not a virtualenv problem.
- # 16:45 <rns> can I add forloop counters together in my template?
- # 16:45 <ptoal> Aut0Exec: Where is your .wsgi file located?
- # 16:45 <ptoal> And did you paste its contents somewhere
- # 16:45 <Aut0Exec> ptoal: i can... its in an apache older on my project root
- # 16:45 <Aut0Exec> *folder
- # 16:45 <ptoal> Aut0Exec: In your wsgi file, put a line like this: sys.path.insert(0,"/path/to/project/dir")
- # 16:45 <ptoal> Make sure you import sys, first.
- # 16:45 <Aut0Exec> ok
- # 16:45 <ptoal> I would make it the first line after all the imports
- # 16:45 <dekuked> when a wsgi script is executing, where do the print outs go? it's hard for me to figure out what's going wrong because right now apache is catching the error "TemplateSyntaxError: Caught ImportError while rendering: No module named blah"
- # 16:45 <m0no> mlavin: ta
- # 16:45 <Maior> dekuked: check your apache's error.log
- # 16:45 <Maior> dekuked: also, consdier the "email admins on error" config
- # 16:45 <ptoal> This is the same thing that the PythonPath "['/path/to/project'] + sys.path" line would do, in your apache config.
- # 16:45 <ptoal> But this just hard-codes it into your wsgi file.
- # 16:45 <Aut0Exec> ptoal: http://dpaste.com/717454/
- # 16:45 <Aut0Exec> ptoal: i think thats ok
- # 17:00 <ptoal> Aut0Exec: remove the /myapp part
- # 17:00 <Aut0Exec> k
- # 17:00 <rdodev> So ... __unicode__ overwrite in models needs to have __unicode__(self) when it's inside model definitions. Interesting.
- # 17:00 <ptoal> And I would also replace the sys.path.append with a sys.path.insert(0,
- # 17:00 <ptoal> That way, your project packages will be tried _before_ any system ones with the same name. Just in case.
- # 17:00 <ptoal> Oh... Is myapp your project, or an app?
- # 17:00 <Aut0Exec> ptoal: zomfg bro i go tit
- # 17:00 <Aut0Exec> whew
- # 17:00 <Aut0Exec> finally
- # 17:00 <Aut0Exec> omfg
- # 17:00 <Aut0Exec> let me paste what i did
- # 17:00 <Aut0Exec> http://dpaste.com/717455/
- # 17:00 <Aut0Exec> small change
- # 17:00 <Aut0Exec> after i took out myapp like u said...
- # 17:00 <Aut0Exec> i also put it at the myapp.settings varialbe
- # 17:00 <Aut0Exec> in os
- # 17:00 <Aut0Exec> ptoal: thanks for all your help bro
- # 17:00 <ptoal> no problem.
- # 17:00 <ptoal> I'm not 100% clear on your folder structure, but if it's working, I'm not going to poke at it. :)
- # 17:00 <Aut0Exec> lol
- # 17:00 <Aut0Exec> me either man
- # 17:00 <Aut0Exec> perhaps i'll tinker with it and see if i can see what works and what doesnt but at last i know where to start from
- # 17:00 <Aut0Exec> and move things around more appropriatly i guess
- # 17:00 <Aut0Exec> ptoal: what do you think is wrong with my structure from what you can see?
- # 17:00 <Aut0Exec> ptoal: i put apache folder where it says from all the docs i've read
- # 17:00 <ptoal> Aut0Exec: My confusion was more around where your project was.
- # 17:00 <ptoal> And it's relation to your venv.
- # 17:00 <ptoal> I keep my venvs in a /home/username/venv/env-1 directory
- # 17:00 <ptoal> And my projects in /home/username/django_projects/project_home/
- # 17:00 <ptoal> But your folders are probably fine. I was just concerned that you might have your virtualenv as a sub-folder of your project, which might introduce weird behaviour.
- # 17:00 <Aut0Exec> ptoal: oh ok
- # 17:15 <Aut0Exec> ptoal: i probably do... first i create a virtualenv... say "virtualenv --no-site-packages mysite".. then i source /bin/activate and then inside of that i "django-admin.py startproject testproject"
- # 17:15 <Jax> we got a decent postal address app or contact/person/address app?
- # 17:15 <dekuked> is there an easy way to tell if I'm using mod_python or modwsgi?
- # 17:15 <imanc> dekuked: do you have a wsgi file?
- # 17:15 <forcer> dekuked: Compare request.__class__.__name__ with 'WSGIRequest' and 'ModPythonRequest'.
- # 17:15 <forcer> dekuked: Don't complain if that ever breaks, though.
- # 17:15 <forcer> I.e. check whether the class names still are correct on django upgrades
- # 17:15 <Dan23> Any idea why using STATIC_ROOT would give my MEDIA_ROOT path instead of my actual static root path?
- # 17:30 <rdodev> I'm trying to REST my app w/o using Piston or such. What's the easiest way to raise a "method not supported" error?
- # 17:30 <vectorjordan> Hey, can anyone help me understand filtering by foreignkey?
- # 17:30 <jvdz> vectorjordan: What are you trying to do?
- # 17:30 <eternicode> rdodev, return HttpResponse(status=501)
- # 17:30 <Maior> 5?
- # 17:30 <Maior> eternicode: I think you mean 405
- # 17:30 <vectorjordan> I have a model called Event that has a foreignkey which related to the User model in Auth
- # 17:30 <vectorjordan> I want to just filter the events by the logged in user
- # 17:30 <vectorjordan> to see just the events they have created
- # 17:30 <vectorjordan> My current code: "my_events = Event.objects.filter(creator__exact=request.user)[:10]"
- # 17:30 <imanc> Events.objects.filter(user=request.user)
- # 17:30 <vectorjordan> So thats basically what I have minus the exact
- # 17:30 <Maior> rdodev: either return an HttpResponseNotAllowed (https://docs.djangoproject.com/en/1.3/ref/request-response/#httpresponse-subclasses) or use the @require_POST / @require_GET decorators if you can
- # 17:30 <vectorjordan> Which is odd because it is not working
- # 17:30 <imanc> vectorjordan: use pdb and debug it.
- # 17:30 <Maior> things Maior doesn't feel write typing: request.POST.get('foo')
- # 17:30 <Maior> write? right
- # 17:30 <eternicode> Maior, 405 is not allowed, 501 is not implemented.
- # 17:30 <Aut0Exec> ptoal: i got disconnected
- # 17:30 <Aut0Exec> sorry i missed the last few things that was said
- # 17:30 <Aut0Exec> ptoal: u still there?
- # 17:30 <Aut0Exec> ptoal: i was asking if i was using virtualenv the right way
- # 17:30 <Maior> eternicode: my bad, I parsed "method not supported" somewhat differently
- # 17:45 <Aut0Exec> ?
- # 17:45 <vectorjordan> Maybe its my render_to_response? "return render_to_response('main.html', {'latest_events': latest_events, 'my_events': my_events}, context_instance=RequestContext(request))"
- # 17:45 <fetzig> hi, anybody who can help me with a sentry/raven problem (nobody answers in the sentry room)?
- # 18:00 <apollo13> fetzig: sure
- # 18:00 <cocoloa> hello, my aim is to change the admin's layout, so i've created a templates dir in my project root, copied the original templates over there, did minimal modifications (correct syntax) and i pointed TEMPLATE_DIRS there (using this line: 'os.path.join(PROJECT_ROOT, 'templates')'), but the admin's appearance has not changed yet, do i somehow have to tell django not to search elsewhere first elsewhere maybe? maybe something else is wrong (
- # 18:00 <yuletide> morning folks
- # 18:15 <cocoloa> i'm using the filesytem and app_directories loaders, by the way
- # 18:15 <dogarrhea2> hello all. is there a way to do a jsfiddle style url?
- # 18:15 <dogarrhea2> basically domain, then a hash. and it redirects to a page
- # 18:15 <Maior> ew
- # 18:15 <Maior> (but yeah, probably - you'll have to re-hack a urls.py due to how the regexp is applied though, I believe)
- # 18:15 <cocoloa> maybe it's a bad idea to have the templates directory living in the project's root directory?
- # 18:15 <dogarrhea2> seems you'd want to provide the user with ultimate flexibility with those urls i guess it's not possible here
- # 18:15 <dogarrhea2> (not worth it)
- # 18:15 <codejunky> cocoloa: why should that be a bad idea?
- # 18:15 <dogarrhea2> maybe he means without any folders around it
- # 18:15 <cocoloa> me?
- # 18:15 <dogarrhea2> mix it in with the config and other files
- # 18:15 <cocoloa> codejunky: well, i don't know, that's why i'm asking
- # 18:15 <PressedWeb> Is Pinax any good?
- # 18:15 <codejunky> cocoloa: i see no problem with it.
- # 18:15 <cocoloa> maybe something's wrong here: https://gist.github.com/f2b1056d9453481abe7b ?
- # 18:30 <codejunky> what error do you get?
- # 18:30 <Artemis_> hey - some south users around here? I'm having a problem with migrating a used defined database field
- # 18:30 <cocoloa> no error, it's just not using the right template file
- # 18:30 <sebastia_> Hey guys, I have a question. Decided to use Django instead of Zend for my own sanity. Anyways, I need to be able to create schools that will contain. (School info, Course, Teachers, Students, Rosters, Calendar, Tasks, Teachers Reminders, Notes). What is the best way to approach this as far as when you add a school it will create the proper tables?
- # 18:30 <cocoloa> everything else is fine, even the os.path... fiddling is handled right
- # 18:30 <usedWEB> hi all, i just installed django and I am having a little problem with the CSS on the admin
- # 18:30 <usedWEB> can anyone point me in the right directiomn?
- # 18:30 <Artemis_> usedWEB: http://bit.ly/xYQvPf SCNR
- # 18:30 <cocoloa> maybe i have to copy over *all* templates to my project's template dir so that '{% extends admin/base.html %}' can work correctly?
- # 18:30 <Artemis_> I'm trying to write my own ENUM-Field so that in an MySQL database it really is an ENUM not a VARCHAR - but the migration with south doesn't work
- # 18:30 <cocoloa> has someone uploaded the official djangoproject tutorial project somewhere?
- # 18:30 <cocoloa> it seems to be changing the admin interface
- # 18:30 <cocoloa> found it
- # 18:30 <cocoloa> actually not, they are all missing the admin templates
- # 18:45 <cocoloa> no, definetly found it
- # 18:45 <dekuked> the urls for my app are not being included in the main urls! what could be causing this? whatever it is, it's failing silently.
- # 18:45 <avidal> I'm using django-redis to use redis as my cache backend; but since I want to use some of the more advanced datatypes in redis (instead of just the raw pickle interface provided by the django cache engine) I find myself using django.core.cache.cache._client to get to the underlying redis connection
- # 18:45 <avidal> I'm guessing I'd be better off just using the underlying redis library (redis-py) directly, eh?
- # 18:45 <avidal> Yank some of the configuration settings from the cache backend
- # 18:45 <rdodev> eternicode: belated thx
- # 18:45 <rdodev> Maior: I can't do decorators cause the same function will use either the 501 code or HttpResponseNotAllowed.
- # 18:45 <xastey> I have a IntegerField and I'm trying to do model.field=F('field')-1.. but upon debuging I see that the values never change
- # 18:45 <xastey> but on the other handle doing F('field')+1 seems to work
- # 19:00 <cocoloa> obviously it requires a lot more to change the admin interface (copying over all the css/js, adding a index.html for an app etc.)
- # 19:00 <cocoloa> maybe i'm mistaken
- # 19:00 <cocoloa> ?
- # 19:00 <riboflavin> I need to link to/display an image that is hosted on a network share. Python has access to the file, but it is not hsoted on a webserver so I can't link to it by address, plus I wouldn't want to anyway since this should be th eonly way anyone can view it. Does anyone know a way to do that?
- # 19:00 <dekuked> what does it mean if an app doesn't load? like the urls.py in my app isn't being loaded, although it's in my settings.py
- # 19:00 <riboflavin> more generally, is there a way in django to link to a file that is not served up by the webserver
- # 19:00 <Maior> riboflavin: sure
- # 19:00 <Maior> your view just performs the mapping and returns the file contents
- # 19:00 <riboflavin> ok, cool
- # 19:00 <riboflavin> I think I can figure out how to do that
- # 19:00 <PKKid2> I have an example, hang on..
- # 19:00 <rdodev> get_object_or_404, does it work with any field or has to be via primary key?
- # 19:00 <PKKid2> riboflavin, This is the function we use to cerate the response: http://dpaste.org/fy1GO/
- # 19:00 <PKKid2> rdodev, I believe anything you can put in a filter. But it must only return one object.
- # 19:00 <riboflavin> PKKid2: awesome thanks. THat's exactly what i need.
- # 19:15 <rdodev> PKKid2: cool. thx
- # 19:15 <PKKid2> riboflavin, If performance becomes an issue, you might want to look into doing this without Python. IE: symlinking the files or network share into a location served via your webserver.
- # 19:15 <yuletide> for a newbie learning django, is it better to go with 1.4 or 1.3.1?
- # 19:15 <joshuajonah> yuletide: Wont make much of a difference, use 1.3.1 as more third party plugins will weork for now.
- # 19:15 <PKKid2> yuletide, Go with 1.4. They are not much different.
- # 19:15 <yuletide> hm
- # 19:15 <PKKid2> lol
- # 19:15 <yuletide> haha
- # 19:15 <PKKid2> I dont think 1.4 breaks any compatibility
- # 19:15 <joshuajonah> I've found quite a few plugins that dont work with 1.4 already.
- # 19:15 <yuletide> 1.4 also doesn't work with pip out of the box
- # 19:15 <PKKid2> they simply added a few ORM functions
- # 19:15 <yuletide> tho that will change this week?
- # 19:15 <PKKid2> interesting.
- # 19:15 <joshuajonah> My SSO package, Ella, and Django-CMS dont quite work right yet.
- # 19:15 <yuletide> i like being able to just do pip install -r requirements.txt
- # 19:15 <joshuajonah> Then use 1.3.1
- # 19:15 <PKKid2> yuletide, You know you can add HG, SVN, GIT paths to a pip requirements file too, right?
- # 19:15 <PKKid2> Thats often an overlooked feature of pip.
- # 19:15 <sebastia_> Hey guys, I have a question. Decided to use Django instead of Zend for my own sanity. Anyways, I need to be able to create schools that will contain. (School info, Course, Teachers, Students, Rosters, Calendar, Tasks, Teachers Reminders, Notes). What is the best way to approach this as far as when you add a school it will create the proper tables for that specific
- # 19:15 <sebastia_> school?
- # 19:15 <joshuajonah> Wait until 1.4 is complete before switching to it unless you want to participate in the development of other plugins till they are ready.
- # 19:15 <yuletide> sounds good, thanks for the input!
- # 19:15 <PKKid2> yuletide, Do what joshuajonah says. He convinced me too. ;D
- # 19:15 <joshuajonah> sebastia_: This would all be done in your save() method on the school model.
- # 19:15 <yuletide> sounds good
- # 19:15 <riboflavin> PKKid2: yea, I thought about doing that but I wanted to do it in python if possible. I don't think performance will be an issue in this case, I'll find out though
- # 19:15 <yuletide> got reallly confused doing the tutorial
- # 19:15 <yuletide> there should be a flag on there that indicates the default page load is for the dev version
- # 19:15 <PKKid2> riboflavin, If you're serving files off an network sahre, I assume the site you're building is for internal use only. In which case.. you're probably fine. :D
- # 19:15 <yuletide> which pip does not install
- # 19:15 <yuletide> so i was on here for 20 minutes trying to figure out why timezone wasn't loading :)
- # 19:15 <rdodev> For the sake of development: is there a convenience method to dump all of an model's fields in a view/template?
- # 19:15 <riboflavin> im too busy to upgrade to 1.4 :(. I think the upgrade will break some of what I have setup because I am using some non public api functionality that I think is being changed in 1.4
- # 19:15 <joshuajonah> rdodev: Generic views
- # 19:15 <riboflavin> should be fun
- # 19:15 <PKKid2> yuletide, All help pages show the version in the bottom right corner.
- # 19:30 <yuletide> pkkid2: right, but it's not very prominent
- # 19:30 <yuletide> just a usability tip for whoever manages those pages, could help to have it default to the latest prod version, for example
- # 19:30 <yuletide> or at least have a big warning saying "HEY, this doc is for DEV!"
- # 19:30 <joshuajonah> yuletide: It does default to the current production release.
- # 19:30 <yuletide> really?
- # 19:30 <joshuajonah> Yeah
- # 19:30 <joshuajonah> Google may index the dev version though
- # 19:30 <yuletide> ah guess it was a google fail
- # 19:30 <yuletide> good call
- # 19:30 <yuletide> might still make sense to have a little thingy at the top, if others are having the same problem. Maybe it was just me :)
- # 19:30 <danols_work> SmileyChris you here sir?
- # 19:30 <danols_work> or maker of sorl-thumbnail ?
- # 19:30 <joshuajonah> danols_work: I use it frequently, is it something I may help with?
- # 19:30 <danols_work> it's more of a feature request --- thank you though
- # 19:30 <joshuajonah> fork it then
- # 19:30 <danols_work> yep will do
- # 19:45 <samuel> hello guys
- # 19:45 <joshuajonah> Howdy
- # 19:45 <samuel> I am trying to use the app_label Meta in my models to arrange things in the admin, however it does not seem to create any tables when using the app_label
- # 19:45 <samuel> when doing the syncdb
- # 19:45 <samuel> is this expected?
- # 19:45 <joshuajonah> So you're trying to tie the models to another app?
- # 19:45 <samuel> no, im just trying to organize the admin navigation
- # 19:45 <samuel> all in the same app
- # 19:45 <no_freedom> I am using MultipleChoiceField and already mentioned required=False. Then Why I am getting this error Username: Enter a list of values. Here is my form. http://dpaste.org/a8FZc/ thanks
- # 19:45 <joshuajonah> samuel: Use verbose_name and verbose_name_plural
- # 19:45 <samuel> joshuajonah, no, thats not the problem
- # 19:45 <joshuajonah> no_freedom: use blank=True
- # 19:45 <joshuajonah> shit nvm
- # 19:45 <joshuajonah> i was thinking model
- # 19:45 <joshuajonah> no_freedom: It kind of seem like you should be using MultipleModelChoiceField and changing the labels.
- # 19:45 <no_freedom> joshuajonah: The problem is : when I submit the form (with one or more values selected) I've this validation error : "Enter a list of values."
- # 19:45 <joshuajonah> no_freedom: https://docs.djangoproject.com/en/1.3/ref/forms/fields/#modelmultiplechoicefield then use the label_from_instance attribute
- # 19:45 <Yxven> Is there a fast way to determine that an uploaded file is a text file?
- # 19:45 <joshuajonah> You are hacking the multichoicefield to do something thats already built into django
- # 19:45 <no_freedom> joshuajonah: thanks let me try it.
- # 19:45 <joshuajonah> Yxven: http://docs.python.org/library/mimetypes.html
- # 19:45 <joshuajonah> Yxven: Then try to read it as text and catch a failure
- # 19:45 <Bodie79> Hi guys...Django noob here. I have a modelform with several "videos" attached, which are really just storing YouTube links. I want to show the preview image on existing rows of my inline formset. I have a property on the model that figures out that URL, but properties don't seem to be accessible on the form. Am I missing something?
- # 19:45 <joshuajonah> Bodie79: form.instance.attribute
- # 19:45 <Yxven> thanks joshuajonah
- # 19:45 <joshuajonah> Yxven: np ;)
- # 19:45 <Bodie79> Lemme try that...
- # 19:45 <joshuajonah> The instance is always attached to a modelform.
- # 19:45 <Bodie79> Holy crap...thanks Josh! Totally worked!
- # 20:00 <joshuajonah> np ;)
- # 20:00 <samuel> joshuajonah, I want to divide the models in the same app for viewing purposes. nothing more. still same app. but when I use app_label it does not work, it wont create the models it needs
- # 20:00 <sebastia_> joshuajonah: By using the save() method on that school model in order to create prefixed tables per school. Can I have the Teachers in school "ABC" only access students in school "ABC" with user permissions?
- # 20:00 <sebastia_> yes, noob here.
- # 20:00 <joshuajonah> samuel: You cant assign an app name that doesn't exist as an app.
- # 20:00 <joshuajonah> sebastia_: You'll have to hack that.
- # 20:00 <samuel> joshuajonah, I see, so the app_name needs to exist
- # 20:00 <joshuajonah> yeah
- # 20:00 <samuel> is there any way to organize the admin navigation without getting into the templates?
- # 20:00 <joshuajonah> samuel: not really, it sucks
- # 20:00 <samuel> joshuajonah, ok... so i need to divide things up....
- # 20:00 <samuel> oh well
- # 20:00 <joshuajonah> samuel: The other way is to unregister things from admin and register them in order. It's a nightmare.
- # 20:00 <sebastia_> joshuajonah: Any examples or a pointer on how to accomplish that
- # 20:00 <joshuajonah> sebastia_: Just a decorator on a view usually that will check if they are part of that school.
- # 20:00 <sebastia_> joshuajonah: Got it.
- # 20:00 <joshuajonah> just somethign that either does nothing or returns a redirect to an access denied view.
- # 20:00 <samuel> joshuajonah, does 1.4 "fix" this? is it worthwhile upgrading?
- # 20:00 <Jimi`> where does one put app-specific variables that they'll use in views? i.e. blog name, blog description, etc...
- # 20:00 <joshuajonah> samuel: Nope. a lot of apps still have compatability problems with 1.4
- # 20:00 <samuel> wow
- # 20:00 <joshuajonah> Jimi`: At the top of the views if they are constants or import them from settings if they are something that is likely to be changed.
- # 20:00 <Jimi`> thank
- # 20:00 <Jimi`> thanks*
- # 20:00 <joshuajonah> samuel: no big deal, it's not released yet, third party app makers do their best.
- # 20:00 <joshuajonah> Jimi`: np ;)
- # 20:00 <Jimi`> putting them at the top of views means i'd have to constantly put them in every view's context, though, right?
- # 20:00 <joshuajonah> Jimi`: yeah, if you want something always in context, make a context_processor
- # 20:00 <joshuajonah> context isn't for use in views, it's for use in templates.
- # 20:00 <samuel> joshuajonah, is it a good idea to create a "ghost" app?
- # 20:00 <Jimi`> yeah i know
- # 20:00 <joshuajonah> samuel: not really
- # 20:00 <joshuajonah> samuel: it's your call to be honest.
- # 20:00 <samuel> to help in organizing things and then just use db_table to specify a tablename?
- # 20:00 <samuel> what would you suggest?
- # 20:00 <joshuajonah> samuel: if you dont have models, it wont make it to the admin.
- # 20:00 <samuel> hmmmm.....
- # 20:00 <samuel> ok, thanks!
- # 20:00 <lacrymology> I'm trying to use this http://djangosnippets.org/snippets/790/ and it breaks in line 49, it queryset.model._meta.admin is None, but I'm actually on that model's admin page... maybe this changed sometime between the writing of the snippet and 1.2?
- # 20:15 <joshuajonah> lacrymology: shitty, looks like your going to have to dir() shit up and find a link to a regtistered admin.
- # 20:15 <kavelot> are there some tool that can anaylise code and try to identify "similar" code (to help in a refactoring)? ie, issuing similar commands but with different parameters (ignoring whitespace) and so on
- # 20:15 <lacrymology> joshuajonah: model._meta.admin *is* there, but it's None
- # 20:15 <AlexMax> YAY!
- # 20:15 <AlexMax> from __past__ import unicode_literals
- # 20:15 <AlexMax> unicode literals are back in 3.3
- # 20:15 <lacrymology> joshuajonah: http://dpaste.com/717519/ there line 4
- # 20:15 <mlavin> kavelot: pylint can detect "similar" code http://www.logilab.org/card/pylintfeatures#similarities-checker
- # 20:15 <joshuajonah> lacrymology: weird, seems to not be in use anymore.
- # 20:15 <joshuajonah> I tried printing it at all steps of a request. None in all places.
- # 20:15 <joshuajonah> I also tried an instance in all those places too.
- # 20:30 <lacrymology> joshuajonah: seems like an awfully useful thing, too
- # 20:30 <joshuajonah> I would start dir()ing further up the line, the functionality is likely reproduced somewhere.
- # 20:30 <lacrymology> joshuajonah: I'll start looking in AdminSite.register
- # 20:30 <Jimi`> in one of my field option parameters in a model, i tried to reference another field by using self.fieldname and python's yelling at me. is there a proper way to do this?
- # 20:30 <JJMalina> Does django create a test database every time you run a testcase even if it doesnt require a database?
- # 20:30 <joshuajonah> Jimi`: The field you're referencing doesn't exist yet, you would need to do somethinglike that in the __init__() method of the model ;)
- # 20:30 <joshuajonah> JJMalina: If you register an app, it will create a DB for it, as far as i know, theres no way around it.
- # 20:30 <JJMalina> joshuajonah: sucks because there is all this overhead of setting up a database
- # 20:30 <JJMalina> what if you want to test your whole app, does it create a new test database for every single test?
- # 20:30 <joshuajonah> JJMalina: no, just once at the start
- # 20:45 <xastey> there was a talk at pycon about a fast fixture test.. somewere in django-nose
- # 20:45 <riley526> Hey, might someone be able to help explain this weird URL ordering issue? http://dpaste.com/717528/
- # 20:45 <Escherial> hey, say that i want to use the @login_required decorator, but i want to have the redirect page be on an app-specific basis
- # 20:45 <Escherial> do i have to supply the login_url parameter every time i use the decorator, or is there an easier way?
- # 20:45 <splic> Hello, I'm having problems with my choices' text in a ModelChoiceField not rendering as HTML (unsafe). I've tried autoescape off blocks but it doesn't do anything. What should I do?
- # 20:45 <joshuajonah> riley526: regardless, the parent urls should always go at the bottom.
- # 20:45 <joshuajonah> splic: You shouldn't be using html in a choice label anyway.
- # 20:45 <splic> It's not a label its's from __unicode__() from my instances
- # 20:45 <joshuajonah> Then override the label
- # 20:45 <joshuajonah> Or don't use html in __unicode__
- # 20:45 <splic> joshuajonah: I need italics on species names, I don't think it's something I could easily do anywhere but in __unicode__()
- # 20:45 <joshuajonah> splic: Where? in the admin change list?
- # 21:00 <splic> joshuajonah: No, I'm trying to make a basic search for one of my models
- # 21:00 <joshuajonah> splic: See the third and fourth code examples in this section: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display
- # 21:00 <joshuajonah> splic: explain what you mean by search
- # 21:00 <VladKr> does anyone know what is the right way of manually requesting height recalculation of an SC.ScrollView?
- # 21:00 <VladKr> sorry, wrong room :)
- # 21:00 <sebastia_> Noob Q#2: Are apps within apps a good idea?
- # 21:00 <splic> joshuajonah: I have a QS of an entire model I'm trying to filter and show the results for. A user picks some attributes to filter on and gets the results. One of the fields I'm trying to filter is a M2M field to another model that needs HTML in it's __unicode__() method. The form for this search uses a ModelChoiceField that is escaping my HTML. Sorry if I've given too much detail.
- # 21:00 <graingert> sebastia_: no
- # 21:00 <graingert> just use setup.py dependancies
- # 21:00 <graingert> sebastia_: but if you want modules within apps go ahead
- # 21:00 <graingert> splic: override your validators
- # 21:00 <sebastia_> graingert: Got it.. thanks
- # 21:00 <kurtis> Hey guys, I've come across a wierd issue in my code. Usually for Forms, I use a Form class and do everything the right way. I'm trying to take a quick shortcut while I'm working on something else by simply hitting self.request.POST in my TemplateView. For some reason, this view returns a blank page when I post data to it. Any ideas what's goin on there?
- # 21:00 <kurtis> I am using the csrf_token so I don't think it's a problem there
- # 21:00 <splic> graingert: Won't that only affect rules for is_valid() and not how it's rendered when empty?
- # 21:00 <kurtis> I actually removed all of my code that even uses self.request.POST and it still returns a blank page when I POST to this view ... so weird. Maybe it's something specific to TemplateView or one of the mixins?
- # 21:15 <jaidan> kurtis: I'm pretty sure TemplateView only implements get()
- # 21:15 <jaidan> kurtis: https://code.djangoproject.com/browser/django/trunk/django/views/generic/base.py#L113
- # 21:15 <kurtis> jaidan: ahh I didn't even think about. That's probably what it is. Thank you!
- # 21:15 <jaidan> kurtis: So just to check you know how to address it?
- # 21:15 <jaidan> you need to implement a post method on a subclass of TemplateView
- # 21:15 <splic> nevermind, figured it out, had to override ModelChoiceField and make the label safe
- # 21:15 <kurtis> jaidan: Implement post(self, request, *args, **kwargs)?
- # 21:15 <Linovia> kurtis: is your debug turned on ?
- # 21:15 <jaidan> kurtis: Exactly
- # 21:15 <kurtis> Linovia: no, I'm on a weird setup. no good debugging at the moment
- # 21:15 <kurtis> jaidan: sweet, thanks!
- # 21:15 <Linovia> kurtis: so you probably have a 500 error with a white 500.html
- # 21:15 <kurtis> that's the weird thing, we actually haven't defined any XXX.html error pages so that it pops up with the debug when most problems do happen. But for some reason this just returns a blank response (nothing in source code)
- # 21:15 <Linovia> kurtis: somehow you must have a 500.html somewhere
- # 21:15 <Linovia> might be through a module
- # 21:15 <Linovia> see your logs to see what response code is returned
- # 21:15 <kurtis> Yeah, that's worth checking out. It could be through a module, we've got several third party apps plugged in. I'll give the logs a look-see
- # 21:15 <jaidan> I'm going to go out on a limb and guess that the response status code would be 405 in his case
- # 21:15 <jaidan> Since I think he'd be getting TemplateView.http_method_not_allowed as his handler
- # 21:15 <kurtis> hmm, in my log I don't see any error? I'm going to dpaste the line, one second
- # 21:15 <kurtis> actually
- # 21:15 <jaidan> What about in firebug, or chrome developer tools =)
- # 21:15 <kurtis> jaidan, youhit it spot-on ... it was a 405 code haha
- # 21:15 <kurtis> nice call!
- # 21:15 <kurtis> (HTTP/1.1 405)
- # 21:15 <jaidan> Yup =) also explains the blank response
- # 21:15 <jaidan> I end up staring at the CBV source every time I use them
- # 21:15 <kurtis> Is 405 typically blank?
- # 21:15 <kurtis> jaidan: haha I usually do too :) But in this case, I couldn't find an explanation for that. I'm pretty sure I learn something new in Django every other day
- # 21:30 <jaidan> truthfully I'm not sure offhand if a 405 normally results in a blank page, but it wouldn't surpise me if it did by default
- # 21:30 <kurtis> hmm, that's no good. I actually use that code in certain places in my code. I guess I better test it haha. Luckily I return some content in my HttpResponse
- # 21:30 <kurtis> oh well -- I guess this is all of the fun of rapid development. We can go back and fix our hidden problems later :P
- # 21:30 <jaidan> Well usually people shouldn't be getting 405's. Usually when I'm dealing with handling 405's it's in javascript
- # 21:30 <jaidan> http://stackoverflow.com/questions/4614294/how-to-display-a-custom-error-page-for-http-status-405-method-not-allowed-in-d
- # 21:30 <jaidan> that's what a quick google turned up on the matter of 405 templates
- # 21:30 <Aut0Exec> hi guys... when deploying multiple projects ... is it wise to just use one virtualhost and multiple WSGIScriptAlias calls?
- # 21:30 <Aut0Exec> is this the right way to do this?
- # 21:30 <Aut0Exec> ?
- # 21:30 <pjs> Aut0Exec that doesn't make much sense to me.
- # 21:30 <kurtis> jaidan: Yeah, I did it one of my weird non-cbv views. Implemented GET and POST and otherwise returned a 405
- # 21:30 <kurtis> Not sure if tha'ts the best way to go about it, but it's in there haha
- # 21:30 <pjs> Aut0Exec Are each "project" actually part of the same virtualhost? If so, why are they separated into different code bases?
- # 21:30 <kurtis> jaidan: Thanks for the find there on that 405 middleware. I'll def. bookmark that
- # 21:30 <jaidan> kurtis: It is the correct way, but you have to remember at this point it's impossible for a browser to submit anything other than get/post
- # 21:30 <ukleinek> if I have something like http://pastebin.com/XJFxFDHE, how can I assert that in D b.a == c.a?
- # 21:30 <kurtis> jaidan: really? What about the HTML5 methods?
- # 21:30 <kurtis> not implemented yet?
- # 21:30 <jaidan> kurtis: No browser implements them. You can call them with ajax
- # 21:30 <kurtis> ahh okay. I figured they were there already since I've seen them in a bunch of ReST APIs haha. Guess I was just a little over-prepared
- # 21:30 <jaidan> kurtis: yeah resful api's should handle them for sure...but obviously then you're dealing with something programatic that should be able to correctly interrept a 405 just from the status code
- # 21:30 <jaidan> interpret
- # 21:30 <kurtis> very true
- # 21:30 <jaidan> That isn't to say that a template to be served in case of a 405 (via a middleware) is a bad idea...it just might be YAGNI
- # 21:30 <kurtis> haha yeah, nobody we'll see it
- # 21:30 <kurtis> will*
- # 21:30 <Aut0Exec> pjs: yes same virtualhost
- # 21:30 <kurtis> man i think it's time to shutdown for the day :P
- # 21:30 <Aut0Exec> pjs: am i doing it wrong?
- # 21:30 <Aut0Exec> pjs: different projects alltogether...
- # 21:30 <Aut0Exec> pjs: i just use WSGIScriptAliases to seperate them
- # 21:30 <kurtis> Time to ride the bike and get some fresh air! See ya guys. Thanks a lot for the help and good info, Jaidan!
- # 21:30 <Aut0Exec> pjs: but use same virtualhost under apache2
- # 21:45 <jaidan> I'd use a different VHost for each project personally...but that's just cause that makes sense to me. And I haven't used apache in like 2 years so offhand i'm not sure how you'd do what you're suggesting but that might just be I don't know apache that well
- # 21:45 <Aut0Exec> jaidan: u use virtualenv?
- # 21:45 <jaidan> yes
- # 21:45 <Aut0Exec> jaidan: what server do you use?
- # 21:45 <jaidan> nginx
- # 21:45 <Aut0Exec> webserver?
- # 21:45 <Aut0Exec> ahh ok
- # 21:45 <jaidan> nginx in front of uwsgi usually
- # 21:45 <Aut0Exec> hmmm
- # 21:45 <Aut0Exec> is that easier to deploy?
- # 21:45 <dlam> is there a way to get STATIC_URL in a custom template tag/filter? right now im just manually getting it via 'from settings import STATIC_URL'
- # 21:45 <jaidan> you're asking a hard to answer question...it's a different stack not harder or easier
- # 21:45 <jaidan> in my stack i set up a virtual host for each project being hosted on that box under nginx
- # 21:45 <Aut0Exec> k
- # 21:45 <jaidan> and then run uwsgi instances for each virtual host. When i deploy I simply kill the uwsgi workers (effectively restart uwsgi)
- # 21:45 <jaidan> but deployment for me is as simple as fab production deploy:git_tag_name_here
- # 21:45 <jaidan> because we use fabric to automate our deploys
- # 21:45 <jaidan> but that's another whole can of worms if you're still just trying to understand how to make django run on a server =)
- # 21:45 <Aut0Exec> the 1,2,3 step version
- # 21:45 <Aut0Exec> easy setup
- # 21:45 <Aut0Exec> i was just looking for the pain free way
- # 21:45 <Aut0Exec> without pulling my remaining hair out
- # 21:45 <jaidan> For simplicity until you understand it. I'd set up a seperate virtual host for each project under apache. That should be fairly simple
- # 21:45 <Aut0Exec> i tried dude
- # 21:45 <Aut0Exec> the 2nd virtualhost wasnt even recognized
- # 21:45 <Aut0Exec> only the one on top
- # 21:45 <Aut0Exec> so i decided to drop the 2nd and just add a wsgiscritpalias right into the 1st one
- # 21:45 <ptone> Linovia: render v render to response - render is newer and is a convenience as it includes the request context
- # 21:45 <Linovia> ptone: I know, but I was wondering if there was a consensus on that on the core team
- # 21:45 <Aut0Exec> i reckon i can keep adding just like that
- # 21:45 <ptone> They are both supported - what kind of consensus would you be looking for?
- # 21:45 <Linovia> ptone: documentation updates if required
- # 21:45 <jaidan> not sure off the top of my head why that would be. I've set up plenty of virtual hosts with apache (in fact still do for php projects). Apache is fussy though
- # 21:45 <ptone> Linovia: do you see a problem in the current docs?
- # 21:45 <ptone> It seems like each shortcut just layers more and more on a base HTTPresponse
- # 21:45 <Linovia> ptone: I need to find where I found that, but I've seen an example of render_to_response without RequestContext that made the associated template failed
- # 21:45 <ptone> If the template uses the request object, then yes
- # 21:45 <Linovia> it did
- # 21:45 <ptone> You're saying that happens somewhere inside Django itself?
- # 21:45 <Linovia> on django's doc
- # 21:45 <KillaKlown> does anyonoe object to use multiple wsgiscriptaliases with 1 virtualhost in apache2?
- # 21:45 <ptone> OK - if there is an inconsistency in the docs - that would need to be fixed, but there is no direct conflict between the shortcuts in terms of a "best practice"
- # 21:45 <Linovia> ptone: ok
- # 21:45 <ptone> Linovia: still wondering if I understood what you were asking originally
- # 21:45 <Aut0Exec> sup
- # 21:45 <Aut0Exec> anyone object to using 1 virtualhost with multiple apps with wsgi?
- # 22:00 <Aut0Exec> working for me but just want to make sure
- # 22:00 <Linovia> ptone: I'm going to find that issue again and submit a patch. I was wondering if render_to_response was still correct or if I should have it replaced with render which is simplier for new users
- # 22:00 <ptone> Aut0Exec: works fine - all about load for the most part
- # 22:00 <Aut0Exec> ptone: ok ok thanks bro
- # 22:00 <ptone> I mostly use render myself now - so depending on where in the docs, it might be appropriate as the 'go-to' shortcut of choice
- # 22:00 <Aut0Exec> huh?
- # 22:00 <ptone> Aut0Exec: other conversation
- # 22:00 <Aut0Exec> ohh lol ok
- # 22:00 <Aut0Exec> ptone: so yeah i figure is stress free setup... just keep adding wsgiscripaliases for every project i create
- # 22:00 <Aut0Exec> under same virtualhost
- # 22:00 <Aut0Exec> should be fine
- # 22:00 <Aut0Exec> perhaps about 3 the most
- # 22:00 <ptone> you could do 50 if they were low enough volume - but then there becomes the management headache of it all
- # 22:00 <Aut0Exec> yeah
- # 22:00 <Aut0Exec> i'm just glad i got it going after 2 long hard days of filtering though dozens of methods and tuts
- # 22:00 <Aut0Exec> apparently there isnt a set in stone way of doing things here
- # 22:00 <Aut0Exec> have to go with what works i guess
- # 22:00 <Aut0Exec> docs arent standard to each persons needs
- # 22:00 <Aut0Exec> and docs arent specific enough
- # 22:00 <Aut0Exec> needs more content
- # 22:00 <Aut0Exec> exampels
- # 22:00 <joshuajonah> I use an nginx conf file for every project with a wildcard include in the main nginx config
- # 22:00 <ptone> Linovia: FWIW I can't find any use of render_to_response in docs that explicitly sets a RequestContext
- # 22:00 <Aut0Exec> joshuajonah: meh never used nginx
- # 22:00 <Aut0Exec> joshuajonah: always used apache
- # 22:00 <Linovia> ptone: https://docs.djangoproject.com/en/1.3/topics/auth/#django.contrib.auth.models.User.message_set.create for ex
- # 22:00 <ptone> that one did come up in my ack'ing of trunk docs - let me confirm
- # 22:00 <ptone> Linovia: yup - User messages are gone in 1.4 - replaced by messages framework
- # 22:15 <Aut0Exec> dd
- # 22:15 <polygonpusher> is there a simple tag that will give me the permalink to the very view that is loaded?
- # 22:15 <mattmcc> https://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.HttpRequest.build_absolute_uri
- # 22:15 <Tominator> hi! is there an easy way of calling the full blown overridden delete() when cascading?
- # 22:15 <FunkyBob> umm... call the method?
- # 22:30 <FireBeyond> Somewhat noob question... wanting to develop (or port a PHP app) that doesn't do any local data storage beyond sessions, but instead talks to a webservice. Is it possible to use the logic and benefits of django's modeling, without being intrinsically tied to the ORM? i.e. that my pages create and manipulate local objects but are communicating back and forth with the master server
- # 22:30 <Tominator> alexsdutton: i guess there is no elegant way of doing this without first getting all of those with a query?
- # 22:30 <FunkyBob> FireBeyond: sure
- # 22:30 <FunkyBob> FireBeyond: I've done a couple of sites before that are django based, but use no ORM
- # 22:30 <FunkyBob> FireBeyond: and the CBV are abstract enough you can retarget them fairly cleanly
- # 22:30 <FireBeyond> And in a broad brush stroke, one of the starting points is using and building those models, without the use of "[char|date|etc]Field"s that imply data to be written by a save()?
- # 22:30 <Tominator> another question: do the signals get called when there is a cascaded delete?
- # 22:30 <FireBeyond> ACTION nods
- # 22:30 <FunkyBob> FireBeyond: oh, you want to wrap the ORM about your remote data?
- # 22:30 <FireBeyond> Hmm, not necessarily. I want to find a clean, elegant way to get the benefits of form validation, models and object methods - an intelligent application, not a dumb renderer, that encapsulates some business logic before handing off a relatively sane request to the server
- # 22:45 <rns> anyone know why qs.order_by('year') wouldn't work when my model has a field 'year'?
- # 22:45 <FunkyBob> FireBeyond: well, Forms still work... and deriving them to make your own WSForms .. you could follow the pattern established with ModelForms
- # 22:45 <FunkyBob> rns: what happens when you try?
- # 22:45 <rns> FunkyBob, nothing
- # 22:45 <FireBeyond> ACTION reads up on those.
- # 22:45 <Diranged> Anyone here know much about how django handles sending email? We're experiencing pretty slow email sending (2/second) through our mail server and when we benchmark the mail server itself (not using django) we can send more like 20-30/sec pretty easily..
- # 22:45 <FunkyBob> Diranged: it has a fairly thin wrapper around Python's smtp libs, IIRC
- # 22:45 <FunkyBob> Diranged: are you re-rendering the email per recipient?
- # 22:45 <mattmcc> Templates involved?
- # 22:45 <Diranged> I believe its mostly pre-rendered.. but ive got one of our devs working on profiling the code to figure some of that out
- # 22:45 <FunkyBob> Diranged: also, check if you're retaining the connection, or bringing it up/tearing it down each mail
- # 22:45 <Diranged> we are retaining it..
- # 22:45 <Diranged> (we had to write some code aroudn that..)
- # 23:00 <ptoal> I would like to create a model instance from some of the fields of a form, but not all of them. What's the most succinct way to grab the relevant fields out of the form to pass in the kwargs of the model init?
- # 23:00 <FunkyBob> ptoal: you're not using a ModelForm ?
- # 23:00 <ptoal> I was thinking something like: for field in Model._meta.get_all_field_names...
- # 23:00 <FunkyBob> ptoal: why not just use a ModelForm?
- # 23:00 <ptoal> FunkyBob: Yes, I'm using a ModelForm.
- # 23:00 <FunkyBob> so there's no problem, then
- # 23:00 <ptoal> But I have more data than I need, because I've added other fields.
- # 23:00 <FunkyBob> still no problem
- # 23:00 <ptoal> Also, it's a FormWizard set. :)
- # 23:00 <FunkyBob> why are you seeking answers to a problem you haven't had?
- # 23:00 <ptoal> And I've overridden a bunch of fields.
- # 23:00 <issackelly> ptone: just use Meta: fields = ['fields i want'] on the ModelForm
- # 23:00 <ptoal> So you're saying, "just call the modelform's save()" ?
- # 23:00 <issackelly> ** ptoal
- # 23:00 <FunkyBob> yes
- # 23:00 <ptone> heh
- # 23:00 <FunkyBob> it will only save the fields on the model [except the ones you exclude]
- # 23:00 <issackelly> *** Don't use exclude, explicity whitelist fields you want
- # 23:00 <ptoal> Hm... Okay... Now I have to tease out which one of the forms in form_list is the one I want... :)
- # 23:00 <Tominator> okay... i'm stuck now... can anyone tell me were and how to register a pre_delete signal on a specific instance of a Model in order to execute some stuff on that instance?
- # 23:00 <Tominator> if i get that right i only get the sender
- # 23:00 <Tominator> and in the cascade case I guess thats not the instance itself but some referenced one
- # 23:15 <FunkyBob> Tominator: I'm trying to check the docs... but they're not loading
- # 23:15 <FunkyBob> Tominator: basically, when you register you register the appropriate sender class
- # 23:15 <FunkyBob> https://docs.djangoproject.com/en/1.3/topics/signals/#connecting-to-signals-sent-by-specific-senders
- # 23:15 <Tominator> so is the sender the model where the reference is in or where the reference points to?
- # 23:15 <FunkyBob> if you want to filter to a specific instance of that model, you'll have to filter that yourself
- # 23:15 <FunkyBob> https://docs.djangoproject.com/en/1.3/ref/signals/#django.db.models.signals.pre_delete
- # 23:15 <rythmic> Hi! If I want to create a table (model) which should only ever have one record (row, instance), is there a nicer way to do it than just making an ordinary model and using that single row. Put differently, can I put constraints on a model to only ever allow one instance
- # 23:15 <Tominator> why isn't delete simply called when there is a cascade...
- # 23:15 <Tominator> that would be so much simpler
- # 23:15 <FunkyBob> rythmic: you might want to rethink your schema a little...
- # 23:15 <FunkyBob> Tominator: either because nobody thought of it, or there's a serious issue with it
- # 23:15 <FunkyBob> like calling pre-/post-save on a queryset update() call... can't feasibly do it.
- # 23:15 <rythmic> FunkyBob, I just want some way to persist some application state data that changes quite often. Much like cron job functionality without having cron job privileges on the server
- # 23:15 <FunkyBob> rythmic: how can you not have cron access?
- # 23:15 <FunkyBob> it's a rare server that restricts that
- # 23:15 <FunkyBob> rythmic: there are a few approaches to 'config in DB', if that'd work
- # 23:15 <FunkyBob> Error: Unable to serialize database: 'NoneType' object has no attribute 'natural_key'
- # 23:15 <FunkyBob> lovely...
- # 23:15 <rythmic> FunkyBob, on shared hosting servers I've never had cron job privilege
- # 23:30 <FunkyBob> ah
- # 23:30 <rythmic> FunkyBob, so what about the config in db approaches?
- # 23:30 <ses1984> i was curious about using wget on an url vs. using a browser...in the browser i get redirected to downloading a file, but with wget i just get a 301 moved permanently error
- # 23:30 <drags> ses1984: an http 301 is a redirect
- # 23:30 <drags> wget should follow it by default though
- # 23:30 <ses1984> the url is http://www.djangoproject.com/download/1.3.1/tarball/
- # 23:30 <ses1984> the default is to follow up to 20 redirects, i will try to specify it explicitly though
- # 23:30 <FunkyBob> ses1984: 301 is not an error
- # 23:30 <drags> ses1984: are you sure wget isn't also saving the file to disk after it displays the "301" text?
- # 23:30 <FunkyBob> it's a valid response code... that causes the browse to redirect
- # 23:30 <ses1984> that's right...bad misnomer by me
- # 23:30 <ses1984> i'm getting a 301 code response called index.html
- # 23:30 <ia9371> The admin css isnt working
- # 23:30 <FunkyBob> ia9371: interesting.... care to share more details?
- # 23:30 <ia9371> the admin seems to be working but not the admincss
- # 23:30 <ia9371> like everything shows up but not with the css
- # 23:30 <FunkyBob> ...
- # 23:30 <ia9371> where is the admin css srored?
- # 23:30 <FunkyBob> like... how are you running django? how have you set it up?
- # 23:30 <FunkyBob> etc etc etc
- # 23:30 <ia9371> its on local server
- # 23:30 <ia9371> Production server
- # 23:30 <FunkyBob> using runserver? or something else?
- # 23:30 <ses1984> http://dpaste.com/717607/
- # 23:30 <FunkyBob> I'm going to guess _not_ runserver
- # 23:30 <ia9371> manage.py runserver
- # 23:30 <FunkyBob> ia9371: what have you set STATIC_ROOT to? do you have a URL pattern matching ^/static ?
- # 23:30 <ses1984> also i'm pretty sure i'm not also getting the file...to make sure i wasn't getting something named unexpectedly i mkdir foo, cd foo and wget from there, all i have is the 301 response
- # 23:30 <ses1984> oh shoot i meant to ask this in #linux
- # 23:30 <FunkyBob> ses1984: how old is your wget??
- # 23:30 <ia9371> oh i think i have to set adnin media
- # 23:30 <ses1984> it's from ubuntu 10.04...yeah it's getting a little crusty
- # 23:30 <FunkyBob> ia9371: you should not set STATIC_ROOT to anywhere you have static source files
- # 23:30 <FunkyBob> ia9371: in fact, when developing, it's best to set it to ''
- # 23:30 <Tominator> Finally i understand when and how the signals are called...
- # 23:30 <Tominator> thanks to the shell
- # 23:30 <ses1984> and i'm a retard
- # 23:45 <FunkyBob> ses1984: which simply means you're delayed
- # 23:45 <ia9371> where is the static media
- # 23:45 <ia9371> admin media stored?'
- # 23:45 <Velmont> django-reversion: -- It doesn't seem enough to make a VersionAdmin in admin.py, -- when I'm doing reversion.create_revision() I'm getting exception: RevisionManagementError: There is no active revision for this thread
- # 23:45 <mattmcc> Are you running a script outside the context of your web server?
- # 23:45 <Velmont> mattmcc: Nope, -- it's fastcgi and nginx.
- # 23:45 <Velmont> Hm. I was thinking maybe they weren't registered because they're in the admin-file. -- Does that get run by django?
- # 23:45 <mattmcc> Assuming you're using the admin's autodiscover, the models would get registered, yes.
- # 23:45 <mattmcc> But for example, a management command wouldn't necessarily. There's a note in the docs about it.
- # 23:45 <ia9371> where are the django admin css files located on production server?
- # 23:45 <mattmcc> Wherever you put them. By default, it'd depend on STATIC_ROOT.
← next day
previous day →