May 7, 2012
← next day
previous day →
- # 00:00 <fission6> i am using reverse in a view and passing in a url pattern name but its not resolving
- # 00:00 <gawry> Does anyone knows how can i make a reference to a user from the users collection in Django (with Django-MongoDB)?
- # 00:00 <fission6> put a key on each side
- # 00:00 <SmileyChris> fission6: you're using {% load url from future %} ?
- # 00:00 <fission6> SmileyChris: i am using reverse in a redirect view to define self.url
- # 00:00 <gawry> fission6: but what field type should i use in the model?
- # 00:00 <harold> https://github.com/overshard/pinry/tree/master/pinry
- # 00:00 <harold> ^ is this thing easy/simple enough for a noob to take apart and study from, or maybe too complicated?
- # 00:00 <fission6> gawry: anything you want = maybe use the user id and jsut make that a field in the mongo document
- # 00:00 <SmileyChris> fission6: so it's not resolving in the view?
- # 00:00 <SmileyChris> fission6: most common case is that it's part of an app's urls and your root urlconf include() ended in '$'
- # 00:00 <fission6> well i can hit the full url
- # 00:00 <fission6> i just cant seem to pass the right namespace for it to resolve
- # 00:00 <SmileyChris> fission6: obviously i'm shooting in the dark without details
- # 00:00 <SmileyChris> harold: seems clean enough code to study
- # 00:00 <fission6> well i think the key issue is that the urlname is in another apps url patterns then the app with the view which contains the reverse
- # 00:00 <SmileyChris> harold: doing is probably better than just viewing though :)
- # 00:00 <SmileyChris> fission6: that doesn't matter
- # 00:00 <fission6> url(r'^create/$', register_a_new_user, name="register_user"), this is my url pattern, an in a view i am doing url = reverse('register_user')
- # 00:00 <SmileyChris> fission6: is that urlconf namespaced?
- # 00:00 <SmileyChris> kinabalu: dpaste the code in the parent template which isn't working for you
- # 00:00 <fission6> i dont believe so, it is included into the root url as url(r'^users/', include('userprofiles.urls')),
- # 00:00 <s_khalsa> hi
- # 00:15 <SmileyChris> s_khalsa: welcome
- # 00:15 <s_khalsa> thanks
- # 00:15 <s_khalsa> do you know anything about the microframework 'Bottle'?
- # 00:15 <fission6> SmileyChris: is that enough to make sense of the url issue
- # 00:15 <SmileyChris> fission6: seems pretty odd - if it were me I'd be looking around in the urlresolvers._ns_resolver_cache dict to see what's up
- # 00:15 <SmileyChris> or _callable_cache
- # 00:15 <SmileyChris> s_khalsa: only as much as the name and a cursory glance
- # 00:15 <fission6> SmileyChris: i am getting this btw "The included urlconf %s doesn't have any patterns in it" % self.urlconf_name)
- # 00:15 <SmileyChris> what's %s
- # 00:15 <s_khalsa> oh ok, I am building a small website and I was debating between Django and Bottle. I was just wondering how scalable Bottle might be
- # 00:15 <fission6> its my ROOT_URLCONF
- # 00:15 <kinabalu> SmileyChris: http://dpaste.com/743902/
- # 00:15 <SmileyChris> kinabalu: so this is in a base template?
- # 00:15 <kinabalu> SmileyChris: yes.
- # 00:15 <SmileyChris> kinabalu: and you're rendering the child template with a RequestContext?
- # 00:15 <SmileyChris> kinabalu: ps: you should also use {{ STATIC_URL }} rather that '/static/'
- # 00:15 <fission6> yea this is very weird, i get the same error if i try to just import the urls
- # 00:15 <kinabalu> SmileyChris: thanks for the STATIC_URL bit .. i'll change that ...
- # 00:15 <SmileyChris> fission6: weird stuff happens if there's a syntax error in one of your views
- # 00:15 <kinabalu> SmileyChris: I'm doing render_to_response in the views.py...
- # 00:15 <SmileyChris> kinabalu: with RequestContext? (protip, cool kids just use the render shortcut instead)
- # 00:15 <brusca> hey, I was wondering if its whether its a good practise or not to have a separate view for handling postdata. Like in the polls tutorial example. Wouldnt it be easier to use one view and check if postdata is present?
- # 00:15 <kinabalu> SmileyChris: i was just doing this one liner - return render_to_response('content/books.html')
- # 00:15 <michelem> hello folks
- # 00:15 <SmileyChris> kinabalu: then you'll have an empty context with no reference to user
- # 00:15 <SmileyChris> kinabalu: if you use a RequestContext, it populates your base context from the default context processors
- # 00:15 <kinabalu> SmileyChris: weird, because i have a user object in the child template. is there a doc explaining the RequestContext and how to send it along?
- # 00:15 <SmileyChris> kinabalu: the child template is probably rendered correctly
- # 00:15 <fission6> SmileyChris: check this if you can http://dpaste.org/qfRP4/
- # 00:15 <kinabalu> SmileyChris: do i have to add anything to RequestContext or just pass it with the render?
- # 00:15 <SmileyChris> fission6: paste the full files, not the line you think is the problem
- # 00:15 <michelem> we have a huge performance gap between the staging server and the production server. The only visible difference is 1) production runs on SSL 2) production queries transoceanic-remote db instead of local
- # 00:15 <fission6> It all has to do with line 2, using reverse() to set a url
- # 00:15 <SmileyChris> michelem: obviously a remote db is going to be the difference
- # 00:15 <michelem> by "huge difference" I mean half second vs 8 seconds for the same page.
- # 00:15 <fission6> it has to do with CBV and using reverse
- # 00:15 <SmileyChris> fission6: ooooh
- # 00:15 <SmileyChris> fission6: you need reverse_lazy
- # 00:15 <michelem> SmileyChris: when I query it from "shell", that only amounts to some 300ms, can't explain all that gap unless django does lots of back and forth
- # 00:15 <fission6> ok whats the situation here?
- # 00:15 <fission6> nice worked.
- # 00:15 <fission6> thnak SM
- # 00:15 <SmileyChris> fission6: you can't use reverse until the full urlresolver cache is built, and you'll be including the view in your urlconf
- # 00:15 <SmileyChris> so it's a badly reported circular import
- # 00:15 <SmileyChris> it'd be nice if reverse caught this (maybe in debug mode only to avoid extra load)
- # 00:15 <SmileyChris> michelem: well, you're assuming a single query then, aren't you?
- # 00:15 <fission6> interesting
- # 00:30 <michelem> SmileyChris: I make 2-3 explicit queries from the views, that's why I'm asking if django breaks down each into many, perhaps for lazy evaluation.
- # 00:30 <SmileyChris> michelem: maybe. Hard to tell by just talking to you ;)
- # 00:30 <SmileyChris> michelem: tried django-debug-toolbar?
- # 00:30 <michelem> SmileyChris: thanks for the pointer, i'll look into that
- # 00:30 <michelem> some query multiplication is definitely going on, because if I force the remote db on the staging server, huge timings occur again
- # 00:30 <kinabalu> SmileyChris: so this - return HttpResponse(t.render(c))
- # 00:30 <SmileyChris> michelem: usually solved by some smart use of select_related (and on 1.4, maybe prefetch_related)
- # 00:30 <kinabalu> SmileyChris: appears to have worked :)
- # 00:30 <SmileyChris> kinabalu: it would, if c is a requestcontext ;)
- # 00:30 <nanonyme> kinabalu, isn't that a bit overkill if you don't tweak the HttpResponse?
- # 00:30 <kinabalu> SmileyChris: yes.
- # 00:30 <kinabalu> nanonyme: no idea.
- # 00:30 <SmileyChris> kinabalu: simplest: return render(request, 'content/books.html')
- # 00:30 <nanonyme> kinabalu, Django afaik implicitly wraps strings you return from views as HttpResponse.
- # 00:30 <kinabalu> SmileyChris: NICE
- # 00:30 <SmileyChris> nanonyme: erm, no
- # 00:30 <kinabalu> nanonyme: no, i got an error when trying that
- # 00:30 <nanonyme> SmileyChris, it doesn't? It looks that way anyway...
- # 00:30 <SmileyChris> you're required to return a response
- # 00:45 <nanonyme> Hrm.
- # 00:45 <nanonyme> Aww, must've been dreaming.
- # 00:45 <nanonyme> (or must've been using certain decorators that do that too much)
- # 00:45 <SmileyChris> yeah, i'd guess that :)
- # 00:45 <SmileyChris> although maybe you have very geeky dreams
- # 00:45 <fission6> SmileyChris: whats the graceful way to search for a model instance and handling no result? using get()
- # 00:45 <nanonyme> get_object_or_404 is used quite a bit
- # 00:45 <fission6> yea that could work
- # 00:45 <Stormlifter> So I'm trying to override "get_form()" so that I can select forms based on a variable I pass to it. Is that the best way or should I do it some other way?
- # 00:45 <Stormlifter> http://dpaste.org/jxGQM/ trying to do that, but I can't seem to get it to work.
- # 00:45 <nanonyme> Ooh, I didn't know get_object_or_404 also accepted querysets and managers.
- # 00:45 <nanonyme> get_list_or_404 sounds convenient as well.
- # 01:00 <Stormlifter> Any help would be appreciated, I'm at my end of knowledge here.
- # 01:00 <pimpaa> hey guys
- # 01:00 <pimpaa> where can I find docs about get_apps
- # 01:00 <pimpaa> and get_models?
- # 01:00 <kinabalu> wow, it looks like there's 1,001 ways to do an <li class="active"> with django, heh
- # 01:15 <SmileyChris> kinabalu: i wrote this in 2009, but it's still working brilliantly for me :) http://djangosnippets.org/snippets/1729/
- # 01:15 <kinabalu> SmileyChris: looks brilliant :)
- # 01:15 <fission6> "hoiw do i render a URLField as a link in the list_display for admin
- # 01:15 <SmileyChris> fission6: make an admin method and use that, like the docs show
- # 01:15 <SmileyChris> *modeladmin method
- # 01:15 <fission6> ok
- # 01:30 <ardian_> Hi when starting the server I am getting this error http://dpaste.org/LeFOu/
- # 01:30 <ardian_> I even tried to delete the pyc and start it again same thing
- # 01:30 <kinabalu> SmileyChris: nav.py works beautifully :)
- # 01:30 <SmileyChris> kinabalu: great
- # 01:30 <kinabalu> SmileyChris: so easy to do, just a drop in really
- # 01:30 <SmileyChris> kinabalu: yep, i (and my designers) like how it works in the parent, allowing children to override it then call block.super
- # 01:45 <kinabalu> SmileyChris: yup, i like the simplicity. i'd love if Django had a nicer way to handle this, but that's a template solution that works great :)
- # 01:45 <SmileyChris> kinabalu: keeping it entirely in the template layer is a plus imo
- # 01:45 <kinabalu> SmileyChris: have you ever tried the other templating layers out there? i wonder if they have anything unique to say about it
- # 01:45 <SmileyChris> it's not something i'd expect built in to the template language
- # 02:00 <fission6> SmileyChris: so you have a recommendation for managing content from the backend, ive beenusing django-flatblocks
- # 02:00 <SmileyChris> fission6: haven't needed it in any recent projects
- # 02:00 <SmileyChris> looking at the flatblocks code, this always makes me :-/ return u"%s" % (self.slug,)
- # 02:00 <fission6> but is it good to use, like i have a project where there is lots of little configureableportions
- # 02:00 <kinabalu> SmileyChris: is prepopulate_from gone in Django?
- # 02:00 <fission6> what about a live settings app
- # 02:00 <kinabalu> TypeError: __init__() got an unexpected keyword argument 'prepopulate_from'
- # 02:15 <SmileyChris> kinabalu: it's part of the modeladmin now
- # 02:15 <SmileyChris> kinabalu: for quite some tmie
- # 02:15 <kinabalu> SmileyChris: hrmm
- # 02:15 <fission6> SmileyChris: do you use any livesettings type module
- # 02:15 <SmileyChris> fission6: no, it's a bad idea
- # 02:15 <kinabalu> SmileyChris: i'm assuming that means that you can't use it in the models regularly?
- # 02:15 <SmileyChris> kinabalu: it doesn't belong in the models code
- # 02:15 <kinabalu> SmileyChris: ahh, i was just going to implement this snippet on site - http://djangosnippets.org/snippets/286/
- # 02:15 <fission6> SmileyChris: how do you configure things then?
- # 02:15 <kinabalu> SmileyChris: and they're using it :/
- # 02:15 <SmileyChris> kinabalu: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.prepopulated_fields
- # 02:15 <SmileyChris> fission6: per-deployment configuration files
- # 02:15 <fission6> ok
- # 02:15 <fission6> and finally, has anyone had experience printing mailing labels, envelopes using their django orm?
- # 02:15 <fission6> curious what solutions are acheivable
- # 02:15 <digitalcakestudi> I have an issue with modelforms
- # 02:15 <digitalcakestudi> models.DateField() renders in the admin as a date chooser but in the template is renders out as a plain input
- # 02:15 <fission6> its a js widget
- # 02:15 <digitalcakestudi> I thought it would inherit the same widget from the admin
- # 02:15 <digitalcakestudi> I have made a simple ModelForm were the model point to the main model and thats all
- # 02:15 <digitalcakestudi> and in my view I must form = MyModelForm and {% form.as_p %}
- # 02:15 <digitalcakestudi> must = just*
- # 02:15 <digitalcakestudi> so were would I tell it to use the same js as the admin
- # 02:15 <fission6> look at how the admin does it, all the code is at your finger tips
- # 02:15 <fission6> short answer is JS in your template
- # 02:15 <digitalcakestudi> thanks
- # 02:30 <digitalcakestudi> so comparing my form markup to the admin, I noticed that the admin wraps all the inputs in a div, were as as_p wraps all in a p tag. It also looks as if the jquery is looking for the div with the proper id. My question is there a as_div or what have you?
- # 02:30 <pimpaa> hey guys
- # 02:30 <pimpaa> how can i create a django test that should fail?
- # 02:45 <pimpaa> @expectedFailure decorator?
- # 02:45 <mattmcc> assertRaises?
- # 02:45 <pimpaa> ok
- # 02:45 <digitalcakestudi> So I got the form loops to output the div wrappers I need but how do I see if the form field is of vDateField or diffrent?
- # 02:45 <Stormlifter> How do I accept a variable in a Node? Like I can take {% my_tag and bob %} and use tokens[2] to get 'bob', but what if I want bob as a variable from the template.
- # 02:45 <Stormlifter> parser.compile_filter(tokens[2]) < I thought that, but that's not right.
- # 02:45 <FunkyBob> Stormlifter: it's close
- # 02:45 <Stormlifter> Close is good :)
- # 02:45 <Stormlifter> Did I miss something?
- # 02:45 <FunkyBob> in your parser function you need to do that... then in your tag render, you need to bob = bob.resolve(context)
- # 02:45 <Stormlifter> Oh okay.
- # 02:45 <digitalcakestudi> I'm using a {% for field in form %} , how would I see all the available key names of field? I'm looking for the one that would output the proper class for the widget such as vDateField?
- # 02:45 <Stormlifter> Hey FunkyBob, do you think you could lend me a hand with this? http://dpaste.org/bSVzi/
- # 02:45 <Stormlifter> I feel like i'm close, but I keep messing something up.
- # 02:45 <Stormlifter> That's two different attempts to get multiple forms to work with Django's comments.
- # 02:45 <Stormlifter> I've noticed that when i try to "get_form" by myself it is different. When it's "get_form(context)" it outputs html, but otherwise I get a class.
- # 02:45 <Stormlifter> Line 146 and 148
- # 03:00 <tsumego> Dear #Django, started coding with Django a couple weeks ago and excited to ask my first question!
- # 03:00 <tsumego> I have my first form, view, & template setup. I've successfully rendered the form and can get it to redirect to a followup page. There are three possible followup pages depending on the answers someone input in the form, & I'd like to route the user based on their input.
- # 03:00 <tsumego> Here's my code: http://dpaste.org/0E6Q6/
- # 03:00 <tsumego> I'm getting a syntax error for line 6.
- # 03:00 <Stormlifter> You forgot your :
- # 03:00 <Stormlifter> And the end of a "if statement" you have to end it with a :
- # 03:00 <Stormlifter> Otherwise Python thinks the line continues on the next line.
- # 03:00 <Stormlifter> tsumego, that should be it.
- # 03:00 <tsumego> Adjusted the line and still getting syntax error. it now reads...
- # 03:00 <tsumego> if data['question1'] == 'n':
- # 03:00 <Stormlifter> DId you save, update your code, are you using django develop server or apache (if apache, be sure to restart it)
- # 03:00 <tsumego> saved, using django develop server
- # 03:00 <Stormlifter> Well that's bonky :)
- # 03:00 <Stormlifter> I mean if that's all there is then I'm pretty confused.
- # 03:00 <Stormlifter> Do some classic debug.
- # 03:00 <tsumego> Ahh, my mistake. The syntax error is now 2 lines down where I tried the same thing with elseif data['question2'] == 'n':
- # 03:00 <FunkyBob> 'elif'
- # 03:00 <digitalcakestudi> :|
- # 03:00 <Stormlifter> Yeah python is elif
- # 03:00 <tsumego> HO HO HO! Excellent. Thank you very much.
- # 03:15 <tsumego> I am so happy, guys. thanks again.
- # 03:15 <tsumego> off to dinner!
- # 03:15 <makism_> hi, i installed django-cms, then i was going to create a new site, before doing that i deleted the example.com site, then logged out, when i tried to login again i got this: DoesNotExist at /admin/ Site matching query does not exist. how can i fix it?
- # 03:15 <textchimp> hi, i want to set the list_display field of my model in admin.py to use as one of the fields the full title returned by the "def __unicode__(self):" method of my model (instead of just a straight field from the model), how do i specify that?
- # 03:30 <makism_> textchimp: hi , can you help me please? i just started with django-cms, once i deleted example.com site i became unable to login or do anything!
- # 03:30 <digitalcakestudi> how do I print the attrs of a form field in a template?
- # 03:30 <textchimp> makism_ not sure, you might have to look at your urls.py file? what does the django-cms documentation tell you to add to that?
- # 03:30 <makism_> textchimp: i did exactly as documentation stated and all was great until i deleted the example.com site, now there are no sites but i didn't know that will break everything!
- # 03:30 <textchimp> can you put the example.com site back? i'm not sure where you deleted it from
- # 03:30 <makism_> from django admin panel, there is a default site named example.com, but now admin panel is inaccessable textchimp :(
- # 03:30 <textchimp> makism_, do you have MySQL access to the server? or whatever DB it's using?
- # 03:30 <makism_> textchimp: yes i do, btw it seems my problem is related to having django-cms as well.. its similar to this http://stackoverflow.com/questions/2674615/django-cms-malfunction-site-matching-query-does-not-exist except that i did not create any sites yet
- # 03:30 <makism_> textchimp: what can i do from the DB?
- # 03:30 <textchimp> makism, on my installation of django there's a table called django_site, i think that's where example.com was deleted from. try adding it again manually?
- # 03:30 <makism_> textchimp: thanks !
- # 03:45 <digitalcakestudi> I must be on the global mute list here
- # 03:45 <textchimp> no one's awake
- # 03:45 <mlavin> digitalcakestudi: did you have a question?
- # 03:45 <digitalcakestudi> Yeah, I have been trying to figure out how to output the default widget class of a form field such as {{form.css_class}}
- # 03:45 <mlavin> I don't think most widget have default classes on them...what problem are you trying to solve?
- # 03:45 <digitalcakestudi> field.field.widget.__class__.__name__ is basicly what I want but in template tag
- # 03:45 <mlavin> digitalcakestudi: you could check out https://github.com/kmike/django-widget-tweaks
- # 03:45 <mlavin> lets you change the widget class in the template
- # 03:45 <digitalcakestudi> I'm trying to change the default one, I'm just trying out put it http://dpaste.org/0cvbi/
- # 04:00 <digitalcakestudi> look at line 2
- # 04:00 <digitalcakestudi> I dont think that should require a 3rd party lib
- # 04:00 <digitalcakestudi> I thought it wold be simple but I dont know what the variable is.
- # 04:00 <FunkyBob> you want to change the way a widget is rendered.... but not in the code?
- # 04:00 <digitalcakestudi> I dont want to change anything, I just want it to display the default widget class for the field
- # 04:00 <FunkyBob> display it where? and why?
- # 04:00 <mlavin> digitalcakestudi: when you iterate the fields you get BoundFields
- # 04:00 <FunkyBob> mlavin: +1
- # 04:00 <digitalcakestudi> mlavin: I dont understand?
- # 04:00 <mlavin> digitalcakestudi: so it should be field.field.widgets.attrs.class I believe
- # 04:00 <digitalcakestudi> ah thanks
- # 04:00 <FunkyBob> digitalcakestudi: when iterating a form for its fields, they get wrapped to make life easier for the template
- # 04:00 <digitalcakestudi> field.field.widgets.attrs.class didnt work but that sounded right
- # 04:00 <mlavin> digitalcakestudi: but again I don't believe widgets have default classes
- # 04:00 <FunkyBob> digitalcakestudi: so... where do you want to display this, and why?
- # 04:00 <mlavin> what makes you think they do?
- # 04:00 <digitalcakestudi> well I'm just copying what I see in the admin
- # 04:00 <digitalcakestudi> I have the js loaded in from the admin to use the widgets like date chooser
- # 04:00 <FunkyBob> Admin does a lot of work on forms
- # 04:00 <mlavin> digitalcakestudi: the admin has custom widgets. are you using those in your form?
- # 04:00 <digitalcakestudi> yes
- # 04:00 <digitalcakestudi> It will work if I set the proper class
- # 04:00 <digitalcakestudi> such as vDateField
- # 04:00 <FunkyBob> digitalcakestudi: please please please.... start by explaining the problem you're trying to solve... not the solution you're trying to fix
- # 04:00 <digitalcakestudi> I made a modelform, when I render a model.DateFeild I dont get the same widget that you would in the admin
- # 04:00 <FunkyBob> correct
- # 04:00 <FunkyBob> [actually, I have the same issue currently :)]
- # 04:00 <FunkyBob> the field carries its own details about what extra media it needs... and admin collects that as it builds the form
- # 04:00 <FunkyBob> then the admin templates use that
- # 04:00 <digitalcakestudi> I thought it would just convert the form field as shown here https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#field-types
- # 04:00 <mlavin> digitalcakestudi: sorry I had a typo. it's widget singular not plural (field.field.widget.attrs.class)
- # 04:00 <FunkyBob> digitalcakestudi: but that can't include extra CSS or JS files
- # 04:00 <mlavin> and using the admin widgets outside the admin is covered here in this question: http://stackoverflow.com/questions/38601/using-django-time-date-widgets-in-custom-form
- # 04:00 <digitalcakestudi> I have all the js and css loaded, its just a matter of setting the class on the form field its self
- # 04:00 <mlavin> but I wouldn't recommend doing it
- # 04:00 <FunkyBob> digitalcakestudi: then why not look at how Admin does it? :)
- # 04:00 <FunkyBob> fortunately, i'm doing it as part of a page in admin
- # 04:00 <digitalcakestudi> so looking at the fieldset.html in the django/contrib/admin/templates/admin/includes/fieldset.html I seen were it sets the class but it does not work for me. field-{{ field.field.name }}
- # 04:00 <FunkyBob> again... admin does a lot of work on the form...
- # 04:00 <digitalcakestudi> also mlavin I tried field.field.widget.attrs.class too
- # 04:00 <FunkyBob> so, the fielset sets only a class of the field's name...
- # 04:15 <mwuh0> Anyone know why I would get "ImportError cmsplugin_filer_file: No module named cmsplugin_filer_file
- # 04:15 <digitalcakestudi> yeah
- # 04:15 <mwuh0> even though django-filer is installed
- # 04:15 <mwuh0> and in INSTALLED_APPS
- # 04:15 <digitalcakestudi> so I tried field.field.attrs and I got the dict for the attrs and most only have the {'maxlength': '50'} for the chars but nothing else
- # 04:15 <digitalcakestudi> sorry field.field.widget.attrs
- # 04:15 <digitalcakestudi> but field.field.widget shows the object for the widget so I know I should be able to find the class variable in there.
- # 04:15 <mlavin> digitalcakestudi: looks like your widget doesn't have a class attr. can you paste the form/
- # 04:15 <mwuh0> I have django-cms installed also here is settings.py: http://dpaste.org/LFM0t/
- # 04:15 <mlavin> ?
- # 04:15 <digitalcakestudi> my model is dead simple http://dpaste.org/TAD83/
- # 04:15 <mlavin> digitalcakestudi: this is using the default widget not the admin widget
- # 05:00 <digitalcakestudi> So I have final figured out how to set the class on the DateField but it makes using modelfields point less. basicly if I had a model with date = models.DateField() I would have to also set the field in the ModelForm to date = forms.DateField(widget=forms.TextInput(attrs={'class':'vDateField'}))
- # 05:00 <mlavin> digitalcakestudi: you could add the attr in the form __init__ without redefining the field
- # 05:00 <FunkyBob> digitalcakestudi: if you want to use the admin widgets... you should use the admin widgets...
- # 05:00 <digitalcakestudi> using this as an example could you show me? http://dpaste.org/TAD83/
- # 05:00 <FunkyBob> AdminDateWidget et al
- # 05:00 <digitalcakestudi> assuming I have the admin media loading in the header
- # 05:00 <digitalcakestudi> hot dam I think I found it 'date': AdminDateWidget()
- # 05:00 <mlavin> digitalcakestudi: an example of what? adding the class or using the admin widgets?
- # 05:00 <digitalcakestudi> I was asking about the __init__
- # 05:15 <mlavin> digitalcakestudi: http://dpaste.org/kaVpI/
- # 05:15 <digitalcakestudi> thanks mlavin
- # 05:15 <digitalcakestudi> I take thats the most common way people assign a class to their fields when using modelform?
- # 05:15 <mlavin> I couldn't tell you what most people do
- # 05:15 <digitalcakestudi> oh man this took way longer then I would have thought but its kinda simple widgets = { 'date': AdminDateWidget(), }
- # 05:15 <digitalcakestudi> it would be nice if django just added some css class to each corresponding form so that you can omit having to add your own class unless you need to
- # 05:15 <digitalcakestudi> form field*
- # 05:30 <FunkyBob> digitalcakestudi: the fact forms render HTML is really quite secondary to their function
- # 05:30 <FunkyBob> and many people [myself included] feel it should be separated out
- # 05:30 <digitalcakestudi> how do you mean separated out? like making a whole new parser for html?
- # 05:30 <FunkyBob> parser?
- # 05:30 <FunkyBob> why would it need a HTML parser?
- # 05:30 <s_khalsa> hi
- # 05:30 <FunkyBob> I mean the role of rendering a form should be separate [though closely tied] to the Form classes
- # 05:30 <digitalcakestudi> it would be the other way around were it form object get parsed in to html
- # 05:30 <s_khalsa> I have a question about django, is anyone around?
- # 05:30 <Ronald_Reagan> Just ask the question
- # 05:30 <s_khalsa> thx. I am using the staticfiles app to serve some css for a webpage. When I chnage the css, the chnage is not reflected on the webpage
- # 05:30 <s_khalsa> chang*
- # 05:30 <s_khalsa> e*
- # 05:30 <FunkyBob> digitalcakestudi: don't you mean _rendered_ into HTML?
- # 05:30 <FunkyBob> s_khalsa: correct... you need to run "collectstatic" to copy it all to your STATIC_ROOT
- # 05:30 <digitalcakestudi> I'm still learning python/django
- # 05:30 <s_khalsa> oh ok
- # 05:30 <s_khalsa> what should STATIC_ROOT be set to?
- # 05:30 <digitalcakestudi> would this work for ImageFields? MyModelForm(request.POST or None, request.FILES)
- # 05:30 <s_khalsa> whereever my static folder is?
- # 05:30 <digitalcakestudi> I'm getting the This field is required error
- # 05:30 <FunkyBob> s_khalsa: it should be set to where your web server serves your static media from
- # 05:30 <s_khalsa> ok thanks,ill try it out
- # 05:30 <FunkyBob> digitalcakestudi: did you remember to set enctype on the form tag?
- # 05:30 <FunkyBob> s_khalsa: are you using runserver ?
- # 05:30 <s_khalsa> yes
- # 05:30 <FunkyBob> then that's irrelevant
- # 05:30 <FunkyBob> it will search for your static media according to the staticfiles finders configured
- # 05:30 <FunkyBob> by default, that's : static/ inside any app dir, and any dir listed in STATICFILES_DIRS
- # 05:30 <s_khalsa> hmm
- # 05:30 <FunkyBob> where are your static media?
- # 05:30 <s_khalsa> in the app's folder
- # 05:30 <FunkyBob> so myapp/static/....?
- # 05:30 <s_khalsa> this is my settings
- # 05:30 <s_khalsa> http://pastebin.com/k6pUHLhe
- # 05:30 <s_khalsa> yes
- # 05:30 <s_khalsa> yeah it's in folders under myapp/static
- # 05:30 <digitalcakestudi> enctype="multipart/form-data" ?
- # 05:30 <FunkyBob> just amking sure you're not confusing 'app' for 'project'?
- # 05:30 <s_khalsa> no app, not projrect
- # 05:30 <FunkyBob> s_khalsa: don't set STATIC_ROOT
- # 05:30 <s_khalsa> ok
- # 05:30 <FunkyBob> and what you'v set STATIC_URL to doesn't make sense
- # 05:30 <s_khalsa> yeah this is some boilerplate stuff
- # 05:30 <FunkyBob> yes, but it's WRONG
- # 05:30 <FunkyBob> you appear to be giving a filesystem path to STATIC_URL
- # 05:30 <s_khalsa> right
- # 05:45 <FunkyBob> well.. it's not a path... it's a URL
- # 05:45 <s_khalsa> ok i've got rid of static_root and static_url and the staticfiles app
- # 05:45 <s_khalsa> will it work without the statiffiles app?
- # 05:45 <FunkyBob> ...
- # 05:45 <FunkyBob> Django will work just fine
- # 05:45 <FunkyBob> but have you considered fixing your config?
- # 05:45 <FunkyBob> just set STATIC_URL = '/static/'
- # 05:45 <FunkyBob> set STATIC_ROOT = '' for now
- # 05:45 <s_khalsa> ok
- # 05:45 <s_khalsa> still no change
- # 05:45 <FunkyBob> it would really help if you read the staticfiles docs, too
- # 05:45 <s_khalsa> ok
- # 05:45 <s_khalsa> I will
- # 05:45 <FunkyBob> did that boilerplate thing tell you to add stuff to your urls?
- # 05:45 <s_khalsa> not really. I will probably just thow it out.
- # 05:45 <FunkyBob> if it did, find who wrote it and beat them with a clue-by-for for a week or so
- # 05:45 <FunkyBob> ok
- # 05:45 <s_khalsa> haha yeah, well shame on my for using it
- # 05:45 <s_khalsa> I am trying to get django set up with bootsrap
- # 05:45 <FunkyBob> and you have no other URLs that might match r'^static/'?
- # 05:45 <s_khalsa> nope
- # 05:45 <s_khalsa> is there an easier way to add my js and css files to my app than staticfiles?
- # 06:00 <FunkyBob> s_khalsa: what's so hard about it?
- # 06:00 <FunkyBob> add it to your installed apps... put your static files in static/ dirs... and it works
- # 06:00 <s_khalsa> haha well if i read the doc, probably nothing
- # 06:00 <s_khalsa> yes i did that
- # 06:00 <s_khalsa> but the changes arent showing up
- # 06:00 <FunkyBob> so... you still haven't read the docs?
- # 06:00 <s_khalsa> here is my project https://github.com/Satshabad/django-bootstrap-app
- # 06:00 <s_khalsa> I looked them over
- # 06:00 <FunkyBob> you REALLY shouldn't put .pyc files in your repo
- # 06:00 <FunkyBob> ever
- # 06:00 <s_khalsa> it was just to put it somewhere i could show you, i'll remove them later
- # 06:00 <Ronald_Reagan> I thought github autogenerated a .gitignore that removed .pyc files :3
- # 06:00 <Ronald_Reagan> *ignored
- # 06:00 <s_khalsa> yeah, i accidentally skipped the step
- # 06:00 <s_khalsa> whoops
- # 06:00 <s_khalsa> anyway, so even though I have deleted the old css file, the page still uses it, rather than the newone
- # 06:00 <s_khalsa> is it storing the old one somewhere?
- # 06:00 <s_khalsa> thanks for your help so far btw
- # 06:00 <s_khalsa> i really appreciate it
- # 06:00 <s_khalsa> hmmm when i run python manage.py runserver --nostatic everything still works the same...
- # 06:15 <FunkyBob> s_khalsa: can you show your template.... a sample of one using a CSS or JS file?
- # 06:15 <FunkyBob> or show a link tag from a rendered page
- # 06:15 <s_khalsa> sure, http://pastebin.com/M2BpHAH0
- # 06:15 <s_khalsa> that's from a template in projectname/templates
- # 06:15 <FunkyBob> ...
- # 06:15 <FunkyBob> so... you never read the part about using {{ STATIC_URL }}
- # 06:15 <FunkyBob> have you at least done the simple 4-part tutorial in the docs?
- # 06:15 <s_khalsa> this one https://docs.djangoproject.com/en/dev/howto/static-files/?
- # 06:15 <s_khalsa> i am going through it
- # 06:15 <FunkyBob> relative urls in templates is hazardous, at best
- # 06:15 <s_khalsa> sorry just got started with django today
- # 06:15 <s_khalsa> ok so what is STATIC_URL I am having trouble understanding from the docs
- # 06:15 <s_khalsa> it's the url to the static files, to the static files of my app?
- # 06:15 <s_khalsa> and does STATICFILES_DIRS need to point at the static files in myproject/myapp/static or somehwere else?
- # 06:15 <jaddison> s_khalsa: If you follow the directions at https://docs.djangoproject.com/en/dev/howto/static-files/ you should be fine.
- # 06:15 <s_khalsa> OK thanks, i'll try it out
- # 06:45 <ariqs> how is the django book?
- # 06:45 <ariqs> is it worth reading?
- # 06:45 <mattmcc> It's a bit dated.
- # 06:45 <ariqs> I feared as much
- # 06:45 <ariqs> did the people working on version 2.0 just sort of give up?
- # 07:00 <sejo> nanonyme: I'm trying to use django on huge databases, but right now I'm looking at doing all raw queries :?
- # 07:00 <FunkyBob> why?
- # 07:00 <FunkyBob> why raw queries, I mean
- # 07:00 <sejo> FunkyBob: because right now a lot of counts are done (even when I don't do count())
- # 07:00 <sejo> and with a 32Million records.. that is slow
- # 07:00 <sejo> and it makes the admin unusable
- # 07:00 <FunkyBob> using pagination?
- # 07:00 <FunkyBob> which DBMS?
- # 07:00 <FunkyBob> yeah... pagination does count.... how else could it work?
- # 07:00 <message144> Any ideas on why the regex pattern `url(r'(?u)^([^\W_][\w\.]*)/$', 'foo.bar')` worked in django 1.3.1, but not in 1.4 ?
- # 07:00 <FunkyBob> crazy...
- # 07:00 <message144> It seems django 1.4 doesnt like the `(?u)` regex modifier syntax. Any suggestions?
- # 07:00 <mattmcc> It's just standard Python regex.
- # 07:00 <message144> mattmcc, The URL pattern I gave matches "http://example.com/adm" in django 1.3.1 and does not match it in django 1.4 where as if you remove the modifier it does match in django 1.4
- # 07:00 <FunkyBob> what does (?u) do?
- # 07:00 <message144> FunkyBob, it is the unicode modifier for python regex
- # 07:00 <message144> I would assume this has something to do with the new localization/i18n url stuff in django 1.4, but I cannot figure out exactly what it would be.
- # 07:15 <message144> Interesting.. it seems 1.4 doesnt like any modifiers. not even `(?i)`
- # 07:15 <phrozen_> hello, how to get information usingdjango14 python26 how much days is between last_modification of object which is datetime object with tz_info UTC and current date?
- # 07:15 <sejo> FunkyBob: yeah I know but it don't need it. Now the only option is not showing those objects in the admin panel
- # 07:15 <phrozen_> ok nvm
- # 07:15 <FunkyBob> sejo: which DBMS?
- # 07:15 <mattmcc> On a decent backend, a full-table count() wouldn't take that long for 32M records. However, if you enable a bunch of list_filters or search_fields that don't have appropriate indexing behind them, that'll get painfully slow pretty easily.
- # 07:15 <FunkyBob> mattmcc: iirc, PG actually does better when you've applied some filters [depending on the filters] since it can bypass the MVCC and rely on indices
- # 07:15 <FunkyBob> http://wiki.postgresql.org/wiki/Slow_Counting
- # 07:15 <mattmcc> Right, if the indexes are there.. :)
- # 07:15 <message144> ah figured it out. django trying to be overly clever.. sigh
- # 07:15 <sejo> FunkyBob: Tried with mysql and postgresql
- # 07:15 <sejo> well the normal tablescan is doable, it's when I get subsets of it (and yes the searchfields are indexed)
- # 07:30 <harshada> hello guys
- # 07:30 <FunkyBob> hi
- # 07:30 <FunkyBob> sejo: interesting... would love to see some of the EXPLAINs from that :)
- # 07:30 <harshada> when i run the command "./manage.py shell" it should drop to ipython interactive shell but it drops to normal python interactive shell
- # 07:30 <FunkyBob> harshada: why should it drop into ipython?
- # 07:30 <harshada> when you install ipython django "/.manage.py shell" drops in ipython automatically
- # 07:30 <anuvrat> harshada: how about running ipython manage.py shell ?
- # 07:30 <FunkyBob> harshada: what happens if you use "python manage.py shell" ?
- # 07:30 <harshada> FunkyBob: it drops me into normal interative shell
- # 07:30 <sejo> FunkyBob: I'll show you some then :P
- # 07:30 <harshada> FunkyBob: anuvrat actually I can not import ipdb , in my code
- # 07:30 <harshada> when I import ipdb, i get the error "cannot import name decorator"
- # 07:30 <anuvrat> harshada: sorry ... I use bpython .. no idea about ipython :(
- # 07:30 <harshada> anuvrat: its almost the same i guess
- # 07:30 <FunkyBob> I use python... works for me :)
- # 07:30 <FunkyBob> there's some stuff Magus- had setup so his normal python had half of what ipython had, anyway
- # 07:45 <harshada> FunkyBob: ipdb is importing in my settings.py file but not in custom middleware.. whats wrong happend in them.. any idea??
- # 07:45 <fangsterr> hey i'm having a problem with incoming requests
- # 07:45 <fangsterr> for some reason, the HTTP_AUTHORIZATION data gets stripped from my requests. any ideas?
- # 07:45 <FunkyBob> harshada: no idea... I've never used ipdb
- # 07:45 <harshada> FunkyBob: I think I have to identify execution steps in between settings.py and middleware.. that will solve my problem.. its my project specific.. somewhere i did something that y its not importing ipython inside project
- # 07:45 <FunkyBob> harshada: middleware only applies to a request...
- # 07:45 <mykul> FunkyBob, i think you can have response middleware as well
- # 07:45 <FunkyBob> mykul: which is only involved in the request/response cycle
- # 08:00 <zhangxiao> my view inherites ListView. however my queryset needs to use a GET argument. ListView.get_queryset() seems to have no way to access the GET args. What's the best approach for me?
- # 08:00 <mattmcc> zhangxiao: self.request
- # 08:00 <zhangxiao> mattmcc: ah, ok... THANKS!
- # 08:15 <FunkyBob> zhangxiao: also self.args and self.kwargs for them
- # 08:15 <pratz> hey guys
- # 08:15 <pratz> I am trying multilsite with django
- # 08:15 <zhangxiao> FunkyBob: I think self.args and self.kwargs are for the args in the URL path?
- # 08:15 <FunkyBob> in the urlpattern ..yes
- # 08:15 <zhangxiao> FunkyBob: k, thanks :)
- # 08:15 <FunkyBob> [don't forget the optional dict of extra kwargs]
- # 08:15 <pratz> I have three settings file 1) settings.py 2) pythonevent_settings.py and 3) djangoevent_settings.py and their corresponding SITE_ID are 1,2 and 3 respectively
- # 08:15 <pratz> I run with any settings I always get SITE_ID as 1
- # 08:15 <zhangxiao> a new question.. is there a way to get an _empty_ model query object? without triggering a SQL query
- # 08:15 <pratz> ex - ./manage.py runserver --settings=pythonevent_settings.py, when i check the SITE_ID is 1 instead of 2
- # 08:15 <pratz> same when i run djangevent_settings.py
- # 08:15 <pratz> also when i check os.environ I get the correct settings in DJANGO_SETTINGS_MODULE
- # 08:15 <pratz> any ideas why this is not working ?
- # 08:15 <bmispelon> zhangxiao: I think you can do YourModel.objects.none()
- # 08:15 <bmispelon> zhangxiao: https://docs.djangoproject.com/en/dev/ref/models/querysets/#none
- # 08:15 <zhangxiao> bmispelon: Thanks! didn't see that :p
- # 08:15 <cheshair> Hi! I have two models: Order and OrderItem, the latter having a FK to the former (an order is composed by multiple items). Now, given an order I want to retrieve all of its items and iterate over them. Is "order.orderitem_set.values()" the right way to go?
- # 08:15 <FunkyBob> zhangxiao: .none() ?
- # 08:15 <zhangxiao> FunkyBob: yep, thanks. Didn't see that in docs... i should be more careful... :p
- # 08:30 <FunkyBob> np
- # 08:30 <pratz> FunkyBob: any ideas on my above statement ?
- # 08:30 <FunkyBob> pratz: it shouldn't have the .py on the end
- # 08:30 <FunkyBob> it's a python import string
- # 08:30 <FunkyBob> also... it should be a fully qualified import... s o "myproject.foo_settings"
- # 08:30 <pratz> FunkyBob: sorry that is just a typo, i have not included the .py
- # 08:30 <m0hsin> I m running my django app on apache with WSGI in Bitnami VM
- # 08:30 <m0hsin> i m getting 500 internal server error
- # 08:30 <pratz> FunkyBob: tried with fully qualified name but still the same issue
- # 08:30 <pratz> m0hsin: check apache logs for more error details
- # 08:30 <pratz> FunkyBob: killme dude, there were two variable "SITE_ID" in each settigns file and the default was always 1
- # 08:45 <FunkyBob> ACTION readies the sacrificial knives
- # 08:45 <omederos> Hello... any good tutorial with a few examples of how to start using django-south?
- # 08:45 <FunkyBob> omederos: other than what's in the docs?
- # 08:45 <gmcquillan> Are people still using django-granular-permissions?
- # 08:45 <FunkyBob> gmcquillan: never heard of it
- # 08:45 <gmcquillan> row-based permissions for user objects.
- # 08:45 <gmcquillan> Hasn't been updated for 3 years.
- # 08:45 <FunkyBob> last one of those I used was guardian
- # 08:45 <gmcquillan> FunkyBob: Ah, nice. I'll check that out.
- # 09:00 <omederos> FunkyBob: I'll take a look at it.
- # 09:00 <FunkyBob> omederos: wait... you can asking here _before_ you even looked at the docs??
- # 09:00 <omederos> FunkyBob: no, I have the tutorial page opened (http://south.aeracode.org/docs/tutorial/index.html) and also the documentation, but I was asking more for a blog post. I was about to collect info to read
- # 09:00 <yillkid> Hi all, I want to add the "user profile" data to UserAdmin class, how should I do? I want to add some field to list_display. thanks
- # 09:00 <FunkyBob> yillkid: you need to unregister the normal UserAdmin class, and register your own extended version
- # 09:00 <yillkid> FunkyBob: But if I will modify "/usr/share/pyshared/django/contrib/auth/admin.py" directly, still need to do that ?
- # 09:00 <gmcquillan> yillkid: don't do that.
- # 09:00 <gmcquillan> Make a model which inherits from Profile and register *THAT* model in your admin.
- # 09:00 <FunkyBob> gmcquillan: close... make one that inherits from UserAdmin :)
- # 09:00 <FunkyBob> otherwise, spot on :)
- # 09:00 <FunkyBob> is it common in the PHP world to fix things by editing the package code?
- # 09:00 <FunkyBob> I ask because a surprising number of people think it's a sensible solution
- # 09:00 <pratz> how can i override sites framework save method ?
- # 09:00 <gmcquillan> I don't think so. My guess is that PHP has more than its share of new programmers.
- # 09:00 <pratz> here http://test.com:8000/admin/sites/site/add/
- # 09:00 <pratz> when i click save here , i want to do something more actions
- # 09:00 <pratz> how can i do that ?
- # 09:15 <FunkyBob> pratz: depends on what you want it to do
- # 09:15 <FunkyBob> you could use pre- and post-save signals
- # 09:15 <pratz> FunkyBob: on click of save i want to create a few new files
- # 09:15 <pratz> FunkyBob: can you provide me a link to pre and post save signals
- # 09:15 <FunkyBob> look for "signals" in the docs
- # 09:15 <FunkyBob> it's in the contents page
- # 09:15 <pratz> FunkyBob: where normally that pieace of code should lie ?
- # 09:15 <pratz> FunkyBob: i mean in models.py or views.py or anywhere else ?
- # 09:30 <yillkid> FunkyBob: Hi ... I want to refer thik link: http://stackoverflow.com/questions/1463398/djangohow-to-including-inline-model-fields-in-the-list-display right ?
- # 09:30 <FunkyBob> yillkid: I generally don't trust anything I find on SO
- # 09:30 <FunkyBob> yillkid: step 1 -- read the Admin docs
- # 09:30 <FunkyBob> oddly enough, it covers how to add inline models, and what you can show in the list display
- # 09:30 <yillkid> FunkyBob: ok thank you :)
- # 10:00 <m0hsin> I m running django app with WSGI on apache
- # 10:00 <m0hsin> i m getting no module found project.settings in error log
- # 10:00 <m0hsin> i also added projects & project directory to sys.path but invain :(
- # 10:00 <m0hsin> can somebody help what i should do to overcome this error
- # 10:00 <m0hsin> ?
- # 10:00 <FunkyBob> m0hsin: when you say "WSGI" ... you mean mod_wsgi ... right?
- # 10:00 <FunkyBob> are you using django 1.3 or 1.4?
- # 10:00 <GrahamDumpleton> m0hsin: Note that Apache runs your code as user other than you. Stuff must be readbale/accessilble to the Apache user.
- # 10:00 <FunkyBob> m0hsin: for 1.3, you should only be adding the dir above your project dir... for 1.4, you should only be adding your workspace dir
- # 10:00 <m0hsin> i m using 1.4
- # 10:00 <FunkyBob> the you should only ever add the outer-most dir to your pythonpath / sys.path
- # 10:00 <FunkyBob> that is, the dir that manage.py is in
- # 10:00 <m0hsin> ok
- # 10:00 <m0hsin> still getting the same error
- # 10:00 <m0hsin> import os, sys
- # 10:00 <m0hsin> #sys.path.append('/opt/bitnami/apps/django/django_projects')
- # 10:00 <m0hsin> sys.path.append('/opt/bitnami/apps/django/django_projects/hp1')
- # 10:00 <m0hsin> os.environ['DJANGO_SETTINGS_MODULE'] = 'hp.settings'
- # 10:00 <m0hsin> import django.core.handlers.wsgi
- # 10:00 <m0hsin> application = django.core.handlers.wsgi.WSGIHandler()
- # 10:00 <m0hsin> this is my django.wsgi
- # 10:00 <GrahamDumpleton> m0hsin: If you are using Django 1.4, you should be using the generated wsgi.py file.
- # 10:00 <m0hsin> inside hp1 is hp & manage.py and settings.py is in hp
- # 10:00 <namfonos> i ran this command "export DJANGO_SETTINGS_MODULE=myproject.settings" and i would like to undo it. how would i go about this
- # 10:00 <GrahamDumpleton> m0hsin: See https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/
- # 10:00 <zxq9> namfonos: In the system shell (Bash?)
- # 10:15 <namfonos> how?
- # 10:15 <zxq9> namfonos: unset DJANGO_SETTHINGS_MODULE
- # 10:15 <zxq9> namfonos: But that export won't be persistent anyway unless you have it set in a script somewhere. Exports don't survive beyond their instance.
- # 10:15 <zxq9> namfonos: s/SETTHINGS/SETTINGS/
- # 10:15 <FunkyBob> heh... SET THINGS! :)
- # 10:15 <m0hsin> GrahamDumpleton: i follow instructions now i m getting 403 forbidden
- # 10:15 <m0hsin> Permission access denied
- # 10:15 <Baribal> Hi. Does {% if <boolean variable> or <boolean variable> %} work as I'd expect from Python? 'Cause Im working on a bit of code that I can't get to work for the life of me, and this is pretty much the last straw.
- # 10:15 <FunkyBob> Baribal: it ought
- # 10:15 <FunkyBob> Baribal: what are your variables?
- # 10:15 <Baribal> Two booleans, one False, one True.
- # 10:15 <FunkyBob> really real booleans?
- # 10:15 <FunkyBob> or just boolean-ish?
- # 10:15 <Baribal> Good thinking, gimme a minute..
- # 10:15 <FunkyBob> does your view put them in the context? or are they from a context processor?
- # 10:15 <Baribal> View, though I'm not sure what a context processor would be. Middleware?
- # 10:15 <Baribal> <type 'bool'>
- # 10:15 <Baribal> So that's out.
- # 10:30 <FunkyBob> whee... that was fun... now have a CSV Import mixin for Admin
- # 10:30 <stormlifter> What's the best way to set initial data for a subclass of a non-ModelForm
- # 10:30 <FunkyBob> stormlifter: initial
- # 10:45 <pushkal> Hi everyone! I need some help with the {% csrf_token %} error. I have put it inside the <form> but still I'm getting the CSRF verification failed error
- # 10:45 <h0axify> Hello guys, In my views.py I have return HttpResponse(datetime.now() + timedelta(days=1)), but after a few days later I see that my datetime.now() is incorrect. Why?
- # 10:45 <bmispelon> h0axify: what does the view look like?
- # 11:00 <h0axify> bmispelon: Never mind, it's all correct now, I had troubles with timezone, so I use datetime.utcnow()!
- # 11:00 <ralphje_> weird: one of our django-crons crashed two days ago in transaction.commit() with django.db.transaction.TransactionManagementError: Transaction managed block ended with pending COMMIT/ROLLBACK
- # 11:00 <ralphje> http://dpaste.com/744099/
- # 11:00 <ralphje> any clue why this would happen?
- # 11:00 <FunkyBob> does your operation inside the transaction only read?
- # 11:00 <ralphje> let's check
- # 11:15 <ralphje> no, there's a save just before the .commit
- # 11:15 <FunkyBob> ok
- # 11:15 <ralphje> FunkyBob: could it be that the database was too busy with an optimize or some other heavy duty thing and fail with transactions?
- # 11:15 <FunkyBob> ralphje: which DBMS are you using?
- # 11:15 <ralphje> mysqldb
- # 11:15 <ralphje> (innodb)
- # 11:15 <FunkyBob> yeah, well... who the fuck knows :)
- # 11:15 <ralphje> :)
- # 11:30 <ralphje> FunkyBob: Hmm, internally, Django keeps track of the _dirty flag and the exception is raised when the _dirty flag is True, however, with a .commit(), it should be set to False
- # 11:30 <anandjeyahar> hi guys how do i configure logging if i deploy django with mod_wsgi on apache setup?
- # 11:30 <kyrix> im serving django with gunicorn behind nginx. im getting a: upstream prematurely closed connection while reading response header from upstream. when handling large uploads. any ideas?
- # 11:45 <kyrix> nvm, found answer
- # 11:45 <FunkyBob> kyrix: nginx has body size limits?
- # 11:45 <FunkyBob> or you just took too long to generate the response?
- # 11:45 <kyrix> FunkyBob, size limits are fine, im testing a higher proxy_read_timeout right now
- # 11:45 <FunkyBob> ah
- # 11:45 <FunkyBob> kyrix: what sort of data are you emitting?
- # 11:45 <kyrix> video.
- # 11:45 <kyrix> FunkyBob, up to 1 GB.
- # 12:00 <FunkyBob> ah
- # 12:00 <FunkyBob> can't stream it?
- # 12:00 <FunkyBob> in fact, can't just get nginx to handle that?
- # 12:00 <kyrix> FunkyBob, yes it will in version 2 :)
- # 12:00 <FunkyBob> heh
- # 12:00 <FunkyBob> otherwise, i'd say switch to handing a generator or iterator to response
- # 12:00 <FunkyBob> much faster response, and far lighter on the resources
- # 12:00 <t0by> Hi, how can I have more than one foreignkey to the same model? Suppose e.g. I have a shoe_right attribute and a shoe_left attribute, which must be foreign keys to the model Shoe (because walking around with two different shoes makes perfect sense to the loons I am writing code for). I tried adding to_fieldand related_name, but I still get <myclass> has more than 1 ForeignKey to <otherclass>.
- # 12:00 <kyrix> FunkyBob, i just have to survive one more week and then ill refactor it so that nginx handles all of it.
- # 12:00 <FunkyBob> t0by: this is covered quite nicely in the docs.... just set the related_name to something unique.
- # 12:00 <FunkyBob> no need to set to_field
- # 12:00 <FunkyBob> kyrix: :)
- # 12:00 <t0by> FunkyBob, I've done that.
- # 12:00 <FunkyBob> t0by: what is issuing that error?
- # 12:00 <t0by> Wait, you mean in the ForeignKey() or in the to_field?
- # 12:00 <t0by> Yellow page of Death
- # 12:00 <t0by> Do you please have a link handy?
- # 12:00 <m0hsin> I've django app in written in python 2.7 django 1.3 and i my app to bitnami vm with environment of django 1.4 python 2.6
- # 12:00 <m0hsin> now i m running it on apache
- # 12:00 <m0hsin> i m getting following error
- # 12:00 <m0hsin> ImportError: Could not import settings 'hp.settings' (Is it on sys.path?): No module named hp.settings
- # 12:00 <FunkyBob> t0by: wait... what are y ou doing with to_field and why?
- # 12:00 <FunkyBob> m0hsin: most likely your pythonpath is wrong
- # 12:00 <t0by> FunkyBob, i have a Loon class, it has left_shot = ForeignKey(Shoes, to_field="fielda", related_name="shoe_l"), right_shoe = ForeignKey(Shoes, to_field="fieldb", related_name="shoe_r").
- # 12:00 <t0by> Nevermind
- # 12:00 <t0by> it is the other way around, actually
- # 12:00 <t0by> I have a Shoe class which has left_foot = FOreignKey (Dude, to_field="left_foot", related_name="leftshoe"), right_foot = FOreignKey (Dude, to_field="right_foot", related_name="rightshoe"),
- # 12:00 <m0hsin> FunkyBob: i done following in my django.wsgi:
- # 12:00 <m0hsin> sys.path.append('/opt/bitnami/apps/django/django_projects/hp1')
- # 12:00 <m0hsin> os.environ['DJANGO_SETTINGS_MODULE'] = 'hp.settings'
- # 12:00 <t0by> but I get "Shoe has more than 1 ForeignKey to Dude"
- # 12:15 <FunkyBob> m0hsin: so your settings file is /opt/bitnami/apps/django/django_projects/hp1/hp/settings.py ?
- # 12:15 <m0hsin> yea
- # 12:15 <FunkyBob> m0hsin: who owns all of those dirs? does the user django is running as have permission?
- # 12:15 <pratz> FunkyBob: I want to do an action only when the object is created first time ?
- # 12:15 <pratz> FunkyBob: what should i use ?
- # 12:15 <FunkyBob> post-save signal
- # 12:15 <pratz> FunkyBob: I did that, but when we modify the object , even then this is called
- # 12:15 <pratz> FunkyBob: I want only when the object is created for the first time
- # 12:15 <FunkyBob> I see you didn't read the docs well
- # 12:15 <anandjeyahar> hi guys, how do i go about debugging the django_auth_ldap. backend. i have set up logging in the backend module. and i can see the ldap_settings being imported. But no other log messages from the backend model(authenticate method).
- # 12:15 <FunkyBob> pratz: like, even looking at the list of arguments the post-save signal passes
- # 12:15 <Nirvo> Hi! How can I add links to external sites in django? I'am getting 324 (net::ERR_EMPTY_RESPONSE) while using httpResponseRedirect.
- # 12:15 <anandjeyahar> instead i get incorrect username or password error. Am beginning to doubt the admin app itself
- # 12:15 <FunkyBob> Nirvo: umm... why not just have links in your HTML?
- # 12:15 <FunkyBob> Nirvo: you want your own views to direct people away?
- # 12:15 <pratz> FunkyBob: god dammmmmm, sorry
- # 12:15 <m0hsin> FunkyBob: I have all rights to that folder
- # 12:15 <FunkyBob> Nirvo: what are you passing to the redirect response?
- # 12:15 <FunkyBob> m0hsin: and the ones above it?
- # 12:15 <FunkyBob> m0hsin: also, I didn't ask if _you_ had rights
- # 12:15 <FunkyBob> m0hsin: I asked if the user Django is running as does
- # 12:15 <Nirvo> url and permanent true
- # 12:15 <FunkyBob> Nirvo: too vague... _exactly_ what are you passing
- # 12:15 <Nirvo> 'https:"//www.djangoproject.com', permanent=True
- # 12:15 <m0hsin> FunkyBob:you mean the Ubuntu user that is running the django instance?
- # 12:15 <FunkyBob> m0hsin: I mean the task that's running Django
- # 12:15 <FunkyBob> Nirvo: without the " I hope...
- # 12:30 <Nirvo> yes was a typo :)
- # 12:30 <m0hsin> yup that user have rights Funky Bob
- # 12:30 <FunkyBob> m0hsin: to every dir from /opt/ down?
- # 12:30 <FunkyBob> m0hsin: which user ?
- # 12:30 <wfq> hi guys
- # 12:30 <m0hsin> Funky Bob user has not rights from opt to django folder
- # 12:45 <FunkyBob> m0hsin: yeah, well... that probably explains why it can't read it
- # 12:45 <m0hsin> i gave the rights
- # 12:45 <m0hsin> still the same
- # 12:45 <m0hsin> result :(
- # 12:45 <Pratz_> Hi, the static files in my app are not displaying if I set DEBUG to False. Any leads?
- # 12:45 <t0by> funkybob, do you please have any relevant links regarding the "more than 1 foreignkey" thing? I'm going crazy.
- # 12:45 <t0by> Pratz_, "This helper function will only be operational in debug mode and..."
- # 12:45 <t0by> https://docs.djangoproject.com/en/dev/howto/static-files/
- # 12:45 <Pratz_> t0by: checking...thanks
- # 13:00 <Pratz_> t0by: I did ensure the first 3 steps given in "Deploying static files in a nutshell." What I need to do for " configuring your webserver of choice to serve the files in STATIC_ROOT at STATIC_URL."
- # 13:00 <Pratz_> t0by: I am currently trying via ./manage.py runserver
- # 13:00 <t0by> "Configuring your webserver blabhalbh" refers specifically to a proper webserver (e.g., Apache) instead of Django's development server.
- # 13:00 <Pratz_> t0by: Any quick tip if I need it on shared Apache hosting for FCGI?
- # 13:00 <t0by> Pratz_, I don't know a thing about FCGI
- # 13:00 <t0by> But if you are using Apache all you do is adding something like
- # 13:00 <Pratz_> t0by: No problem. Thanks. For the moment I have done it via .htacess (don't know if it is the right way).
- # 13:00 <antris> anyone know of a simple blogging engine tailored for coders? I'd like to have Markdown posts with live preview and code syntax hilighting.
- # 13:00 <t0by> Alias /media "/home/blahblah/yourproject/media"
- # 13:00 <t0by> to your configuration file
- # 13:00 <t0by> It's a webserver- specific thing anyway
- # 13:00 <pratz> Pratz_: your app is served by apache and not by django development server
- # 13:00 <Pratz_> pratz: Hmmm. I don't have access to Apache conf.
- # 13:15 <pratz> Pratz_: then you have to request your admin guys
- # 13:15 <Pratz_> pratz: .htacess way can lead to any issues?
- # 13:15 <pratz> Pratz_: I have not tried that before, so I do not know ( but properbly not a good way I guess )
- # 13:15 <Pratz_> pratz: Thanks. I will try to talk to system admin.
- # 13:15 <pratz> Pratz_: welcome
- # 13:15 <wfq> hi guys
- # 13:15 <wfq> in php I could detect if an user was already logged in by just querying the $_SESSION ['username']. Can I do the same with Djano? For example, in my login method, can I just say if request.session.get('username',False) provided that when the user first logged I did a request.session['username'] = True?
- # 13:15 <t0by> How many pratz are there? :-|
- # 13:15 <jpic> hi all, i can't find any ManyToManyField in model._meta.fields, i've tried to find them using tab completion but failed ... any idea please ? I'm trying to get the list of M2M fields of a model class
- # 13:15 <t0by> How do I get a custom label for the header of a StackedInline?
- # 13:30 <t0by> jpic, I think I know
- # 13:30 <t0by> but I can't precisely recall
- # 13:30 <t0by> manytomany are somewhere else
- # 13:30 <t0by> let me try
- # 13:30 <t0by> uhm
- # 13:30 <t0by> ._meta.many_to_many?
- # 13:30 <t0by> btw
- # 13:30 <t0by> forget about tab completion
- # 13:30 <jpic> eeek thanks
- # 13:30 <t0by> dict() is the way
- # 13:30 <jpic> thanks for the heads up
- # 13:30 <jpic> t0by: the header of a row of a stackedinline is the __unicode__ of the object of that row
- # 13:30 <jpic> the header of the whole stackedinline is changeable in modeladmin.fieldsets
- # 13:30 <t0by> modeladmin.fieldsets
- # 13:30 <starta> how can I add a new column to a table that I created it before(I want to update(add or remove acolumn or create new table )
- # 13:30 <t0by> starta, South is your best friend
- # 13:30 <t0by> jpic, thanks
- # 13:30 <starta> t0by: what do u mean?
- # 13:30 <joelcox> starta: http://pypi.python.org/pypi/South :)
- # 13:30 <isei> I am a beginner programmer who wants to learn making web pages with Django, is http://www.djangobook.com/ a good place to start?
- # 13:30 <t0by> isei, the django tutorial itself is also very good.
- # 13:30 <t0by> mind you
- # 13:30 <isei> alrighty :-)
- # 13:30 <isei> Thank you! I'll start there
- # 13:30 <t0by> you have to have a grasp of databases and oo programming
- # 13:30 <t0by> if you don't, learn it first
- # 13:30 <t0by> or you'll find it difficult to join the dots.
- # 13:30 <isei> databases, do you mean SQL syntax?
- # 13:30 <t0by> no, syntax is the only think you won't need.
- # 13:30 <t0by> concepts, yes.
- # 13:30 <isei> concepts, okay
- # 13:30 <t0by> no big deal, though
- # 13:30 <isei> I think I can do it heh i'll give it a shot :)
- # 13:30 <isei> excellent information t0by tytyty!
- # 13:30 <t0by> jpic, sorry, but i dont' declare inlines in modeladmin.fieldsets - i declare them in modeladmin.inlines
- # 13:30 <t0by> do you have an example?
- # 13:30 <t0by> thanks
- # 13:30 <t0by> jpic, not, not of a row
- # 13:30 <t0by> (sorry
- # 13:30 <t0by> nevermind
- # 13:30 <t0by> i'm an idiot)
- # 13:45 <molavy1> hi
- # 13:45 <molavy1> i have 2 problem
- # 13:45 <molavy1> first on syncdb return this
- # 13:45 <molavy1> http://dpaste.com/744147/
- # 13:45 <starta> joelcox: tnx. does have any other way?(u 've recommanded south)
- # 13:45 <molavy1> second whether i add more app on setting that show "Congratulations page"
- # 13:45 <joelcox> starta: You can clear out the entire database and sync again or add the column manually, but South is the preferable way.
- # 13:45 <starta> It has complex way to do
- # 13:45 <joelcox> starta: But I'm not too familiar with Django, so you might want to consult others.
- # 13:45 <starta> ok tnx
- # 13:45 <molavy1> any idea?
- # 13:45 <starta> guys! how can I add a new column to a table that I created it before(I want to update(add or remove acolumn or create new table ) I want the simplest way :)
- # 13:45 <kyrix> starta, use south
- # 13:45 <starta> kyrix: what is the problem with delete the db and create a new one and then syndb... ???I 'd like to know :)
- # 14:00 <starta> kyrix: tnx :(
- # 14:00 <kyrix> starta, you loose all your data :)
- # 14:00 <starta> kyrix: wow yes u 're right,I have some saved data!! :)
- # 14:00 <carrerasrodrigo> starta: you can try django-evolution http://code.google.com/p/django-evolution/
- # 14:15 <molavy1> first on syncdb
- # 14:15 <molavy1> http://dpaste.com/744147/
- # 14:15 <tktiddle> Im having trouble deploying my django application, i think nginx isn't finding the wsgi application, as I always get a "TemplateDoesNotExist no 500.html found" error.. can someone please have a look at this setup? https://gist.github.com/91625bbbf9225314ff93
- # 14:15 <ironfroggy> tktiddle: TemplateDoesNotExist is a django exception, so nginx is obviously passing the request on to django properly
- # 14:30 <tktiddle> Ok, but there is a 500.html template in the project So i think its finding django OK but not finding the wsgi application, if that makes sense
- # 14:30 <tktiddle> Is there something simple I can put in my wsgi.py to test if it is being found by wsgi?
- # 14:30 <GrahamDumpleton> tktiddle: http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Displaying_Request_Environment
- # 14:45 <wfq> guys, how could I know whether a user has already logged in? I can guess I have to query the Sessions table?
- # 14:45 <easytiger> if i have a legacy database i'm supporting, cannot i not use it with the django inspectdb/orm if there isn't an ID column? i'm getting ... (1054, "Unknown column 'EN_20120424.id' in 'field list'")
- # 15:00 <easytiger> just delete that line?
- # 15:00 <easytiger> hmm. the insepctdb model doesnt have an id column either. wth
- # 15:00 <molavy1> hi
- # 15:00 <molavy1> i have problem on syncdb
- # 15:00 <molavy1> http://dpaste.com/744147/
- # 15:15 <wfq> how could I synchronize just one of the two databases I have got? Shouldn't this be something like python manage.py syncdb --database=default?
- # 15:15 <wfq> it keeps inspecting the two databases. I just want to syncrhonize in one
- # 15:15 <nikhil_> what are the requirements when you use an apps/ directory in the top level of your project to keep your app folders in? how do you get Django to 'understand' that you apps are in that directory?
- # 15:15 <hell_razer> is any good module for protecting admin against brute force attack?
- # 15:15 <molavy1> there is no idea?
- # 15:30 <wfq> does anyone know why on earth I am gettin this exception when syncdb? http://dpaste.com/744199/
- # 15:30 <carrerasrodrigo> wfq: did you specify the max_length??
- # 15:30 <bmispelon> wfq: are you trying to use a TextField as a primary key or as an index?
- # 15:30 <wfq> bmispelon, I am using a textfield as unique element and the max_length is set to 10
- # 15:30 <bmispelon> wfq: try using a CharField instead
- # 15:30 <bmispelon> it could be that mysql doesnt support having text fields in UNIQUE
- # 15:30 <wfq> bmispelon,hmm but that is such a big problem because I just realized that that model is not to be created in my Mysql db. It is just a model that I use to query a Postgresql db that I have got in another server. Son in fact, when I do syncdb I do not want that model to be picked!
- # 15:30 <wfq> so I can guess I have no other alternative than defining routers?
- # 15:30 <bmispelon> wfq: i have no idea. I've only ever had one db on my projects.
- # 15:30 <wfq> sugar! I definitely have to... or just comment out the model for the moment which is a terrible think to do as a software engineer :)
- # 15:30 <bmispelon> wfq: one hack that might work is to create an empty table with the same name in your mysql database
- # 15:30 <bmispelon> then django wouldnt try and create it with syncdb
- # 15:30 <bmispelon> but that's ugly
- # 15:30 <wfq> done, just commeted it out while syncdbing ... I don't have much time now for diving into database routers
- # 15:30 <wfq> thanks guys
- # 15:45 <molavy1> i really set engine on django settings
- # 15:45 <molavy1> but on syncdb return
- # 15:45 <molavy1> http://dpaste.com/744147/
- # 15:45 <zhangxiao> In template, how can I refer to an object's attribute by the attr's name?
- # 15:45 <bmispelon> molavy1: paste your settings file
- # 15:45 <molavy1> http://dpaste.com/744215/
- # 15:45 <solvik> Hi! since i've upgraded to django 1.4 i often have this an error after login : http://pastie.org/private/guohukobjfdvil08ntguug
- # 15:45 <solvik> does anyone experienced that too ?
- # 15:45 <molavy1> any idea?
- # 15:45 <molavy1> can be it from permission?
- # 15:45 <bmispelon> molavy1: I don't see how the settings file you pasted could throw the error. Something else is wrong.
- # 15:45 <molavy1> how can i solve this problem?
- # 15:45 <bmispelon> molavy1: are you sure you're importing the right settings file?
- # 15:45 <bmispelon> try putting a blatant syntax error in it for example and see if it breaks.
- # 15:45 <molavy1> yes
- # 16:00 <molavy1> i use python manage.py shell and import setting and settings.DATABASES and it return same file
- # 16:00 <bmispelon> molavy1: in shell, do "from django.conf import settings; print settings.DATABASES"
- # 16:00 <molavy1> {'default': {'ENGINE': 'django.db.backends.dummy', 'TEST_MIRROR': None, 'NAME': '', 'TEST_CHARSET': None, 'TIME_ZONE': 'UTC', 'TEST_COLLATION': None, 'OPTIONS': {}, 'HOST': '', 'USER': '', 'TEST_NAME': None, 'PASSWORD': '', 'PORT': ''}}
- # 16:00 <wfq> how can I prevent multiple logins from the same user?
- # 16:00 <bmispelon> molavy1: which version of django are you using?
- # 16:00 <molavy1> 1.4
- # 16:00 <bmispelon> molavy1: where did you put your settings file?
- # 16:00 <molavy1> in same folder manage.py urls.py in main project folder
- # 16:00 <bmispelon> molavy1: that doesn't seem right. manage.py and urls.py should not be in the same folder.
- # 16:00 <bmispelon> your settings.py should be in the same folder as urls.py
- # 16:00 <bmispelon> did you use the createproject command?
- # 16:00 <molavy1> no, pydev project wizard
- # 16:00 <bmispelon> ACTION sighs
- # 16:00 <bmispelon> molavy1: i suspect pydev is using an old version of django
- # 16:00 <sirfilip> morning
- # 16:00 <bmispelon> molavy1: try using the createproject command, like they do in the tutorial
- # 16:15 <nikhil_> i'm getting AttributeError: 'module' has no object 'urls', on the following urlconf (line15): http://dpaste.com/744224/
- # 16:15 <nikhil_> can anyone help pleasE?
- # 16:15 <nikhil_> *please
- # 16:15 <crazydiamond> Hi. I'm creating custom field, that contains filename and must delete file when it gets deleted. Can anyone suggest, where (which procedure of Field object) is best place to add deletion code?
- # 16:15 <nikhil_> I'm sure i have a apps.karma folder, and there is a urls.py file in it
- # 16:15 <molavy1> bmispelon,thanks a ton , that take 2 hour time ,
- # 16:15 <fcurella> nikhil_: try with: `from django.conf.urls.defaults import patterns, include, url`
- # 16:15 <molavy1> i solve this problem by : yum remove Django; that was django1.3
- # 16:15 <molavy1> then go into django1.4 folder and again python setup.py install
- # 16:15 <nikhil_> molavy1, are you talking to me?
- # 16:15 <zyltoid> easy_install :D
- # 16:15 <molavy1> then copy all app to temporary folder and create project again and paste them from temp folder into project
- # 16:15 <molavy1> nikhil_, no, bmispelon
- # 16:15 <molavy1> and it work well
- # 16:15 <molavy1> bmispelon,thank again
- # 16:15 <bmispelon> molavy1: no problem
- # 16:15 <bmispelon> in the future, consider using virtualenv
- # 16:15 <bmispelon> it's a great tool to isolate python environments
- # 16:15 <fcurella> nikhil_: the difference is that you import `url` from `defaults`, not from `urls`
- # 16:15 <fcurella> nikhil_: you could also use `from django.conf.urls.defaults import *`
- # 16:15 <molavy1> sure,thanks again
- # 16:15 <medecau> so guys I am trying to learn django and I am following the tutorial
- # 16:15 <medecau> but when it tells me to 'python manage.py sql pools'
- # 16:15 <medecau> it returns an error
- # 16:15 <medecau> Error: App with label pools could not be found. Are you sure your INSTALLED_APPS setting is correct?
- # 16:15 <medecau> is this a known error with a workaround?
- # 16:30 <nikhil_> how does one enable the django debug-toolbar?
- # 16:30 <fcurella> medecau: shouldn't it be 'polls' instead of `pools`?
- # 16:30 <medecau> fcurella: i'm going to search the project for that mispelling
- # 16:30 <medecau> fcurella: thanks
- # 16:30 <nikhil_> sigh, why doesn't the debug tool bar appear anywhere? :/
- # 16:45 <abisson> Hi guys! Quick question: So I saw that we can access a logged in user's information in a template using this https://docs.djangoproject.com/en/dev/topics/auth/#authentication-data-in-templates ... now what about a model? For example, I want to pass in the first_name of the user to the constructor of a model I created and redefined it's init.
- # 16:45 <tompaw> Guys, what's the industry standard for testing Django apps? Django's TestCase? Or maybe an external solution?
- # 17:00 <crazydiamond> Hi. I'm creating custom field, that contains filename and must delete file when it gets deleted. Can anyone suggest, where (which procedure of Field object) file can be deleted?
- # 17:00 <fcurella> crazydiamond: take a look at the `delete` method of `FileField`: https://docs.djangoproject.com/en/1.4/ref/models/fields/#django.db.models.FieldFile.delete
- # 17:00 <crazydiamond> fcurella: thanks for help, but this is not FileField's (Field descendant's) but FieldFile's (File descendant's) method
- # 17:00 <crazydiamond> so, FieldFile is value of FileField (thing, returned by it's "to_python" method), as basestring is value of CharField
- # 17:15 <fcurella> crazydiamond: sorry about that. Yu should be able to access the FieldFile directly from the field, as in `myinstance.photo.delete()`
- # 17:30 <mercutio22> Hi. I see the project structure changed a bit in django 1.4. I know I can customize the settings.py file to store my static files almost anywhere, but where is the recommended place to put my static file folder? besides manage.py or inside the sibling folder named after the project?
- # 17:30 <briancra_> I need to use {{ STATIC_URL }} inside a model field. Can I get that to be parsed?
- # 17:30 <NotARealPerson> *briancra_ it will not
- # 17:30 <briancra_> so let me explain my issue then
- # 17:30 <NotARealPerson> {{ X }} is only redered in the template
- # 17:30 <NotARealPerson> *rendered
- # 17:30 <briancra_> I have blog post field, inside it I want to refer to an image
- # 17:30 <briancra_> but I don't want to type an absolute path
- # 17:30 <briancra_> Moreover, the image itself is a related field of the post model
- # 17:30 <briancra_> well
- # 17:30 <fcurella> briancra_: you can import the settings using ``from django.conf import settings`` and the unse ``settings.STATIC_URL``
- # 17:30 <briancra_> related model
- # 17:30 <briancra_> I do
- # 17:30 <briancra_> that's why I want to use STATIC_URL
- # 17:30 <briancra_> heh
- # 17:30 <NotARealPerson> When you update an image you set the path so you can just link to your image {{ STATIC_URL}}{{ object.image }}
- # 17:30 <briancra_> I need to refer to the image inside a model field
- # 17:30 <briancra_> not inside the template
- # 17:30 <briancra_> because the model field is the content of the page
- # 17:30 <singingwolfboy> in my templates, when I'm rendering a form, I often do "{{form.field.errors}}{{form.field.label_tag}}{{form.field}}". How can I write a templatetag or some other shortcut so that I only have to specify `form.field` once?
- # 17:30 <briancra_> https://docs.djangoproject.com/en/dev/howto/custom-template-tags/
- # 17:30 <digitalcakestudi> has the IRC nick server been running slow?
- # 17:30 <singingwolfboy> briancra_: does this already exist anywhere? I can write my own custom templatetag, but I'm a bit surprised that no one else would of already solved this problem
- # 17:30 <digitalcakestudi> How do I use the USStateField in the admin?
- # 17:30 <singingwolfboy> briancra_: OK, thanks for the pointer :)
- # 17:30 <briancra_> so people probably just write it and go on
- # 17:30 <digitalcakestudi> USStateField bing from django.contrib.localflavor.us.forms.USStateField
- # 17:30 <digitalcakestudi> being*
- # 17:30 <briancra_> sorry I don't have a better answer :)
- # 17:45 <briancra_> singingwolfboy if you don't care about html structure, there's always https://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs#displaying-a-form-using-a-template
- # 17:45 <singingwolfboy> briancra_: I do care about HTML structure, but thank you
- # 17:45 <digitalcakestudi> using state = USStateField() in my model does not render the field in the admin or in my modelform
- # 18:00 <EDevil> Is is possible to only register an applications URLs in the urlconf if that application is listed in the INSTALLED_APPS setting?
- # 18:00 <ejd> EDevil: if 'app' in settings.INSTALLED_APPS: urlpatterns += patterns(...)
- # 18:00 <EDevil> ejd: I guess that will do. :) Thanks.. I just think that django should automatically include an application urls.py when it is present in the INSTALLED_APPS.
- # 18:15 <ejd> EDevil: True, but could cause trouble if you only wanted to use one part of a third-party app and not the urls
- # 18:15 <ejd> Explicit vs. implicit and all that :)
- # 18:15 <EDevil> ejd: Ok, I see your point.
- # 18:15 <majd> Good afternoon #django - i have a modelformset created in a formwizard. I explicitly set modelformset_factory(Address, formset=PickupDropoffAddressFormset, extra=2, max_num=2)
- # 18:15 <majd> when the formwizard is rendered, it's actually rendered 10 times, resulting in 20 Address forms
- # 18:15 <majd> i have no idea why this is happening...
- # 18:15 <majd> Any thoughts on what could be causing this?
- # 18:30 <lobius> Is there any data field model containing all 50 states of the United States of America or do I need to manually enter that if I want to restrict input on the form?
- # 18:30 <lobius> Or is that a view issue?
- # 18:30 <zxq9> lobius: You would either want a database preload if you have a model that represents states, or you would want to write an iterable (tuple or list, or dictionary that you make a list from, whatever) as a constant somewhere that your model (maybe model.State or something) uses as its argument to "choices=" on a models.CharField.
- # 18:30 <ejd> lobius: https://docs.djangoproject.com/en/1.4/ref/contrib/localflavor/#django.contrib.localflavor.us.models.USStateField
- # 18:30 <zxq9> lobius: The choice of implementation is completely up to you. There is probably something already in the local flav's somewhere. There is one of Japanese prefectures, anyway.
- # 18:30 <lobius> Checking the link.
- # 18:30 <lobius> :-)
- # 18:30 <zxq9> lobius: Ah, ejd already found one for you. Anyway, this may or may not fit the way you want to represent states.
- # 18:30 <zxq9> lobius: The decision how you want to represent states is a LOT more important than whether or not someone has already written out 50 or so tuples for you already.
- # 18:30 <crazydiamond> what's best way to check that string contains characters other than spaces, tabs, line feeds etc?
- # 18:30 <zxq9> crazydiamond: regex?
- # 18:30 <lobius> Two letters. I have this line in my models.py:
- # 18:30 <lobius> state_abbreviation = models.CharField(max_length = 200).us_states.US_STATES does that look right?
- # 18:30 <crazydiamond> zxq9: but what?
- # 18:30 <crazydiamond> zxq9: okay. I'll do it by myself
- # 18:30 <ejd> lobius: try this `state_abbreviation = us.models.USStateField()`
- # 18:30 <zxq9> crazydiamond: Something like "import re; if re.search(r'something', test_string):; do stuff;" or whatever. You could also either do a negation in the regex itself or negate the if statement if you want it that way -- pick whichever grammar is most readable for your situation.
- # 18:30 <lobius> ejd: thanks
- # 18:30 <ejd> lobius: sure thing
- # 18:30 <crazydiamond> zxq9: but why http://dpaste.org/BPZFA/ no result?
- # 18:30 <zxq9> crazydiamond: Anyway, playing with regex stuff in the shell is sort of fun anyway, so see if you can find 3 ways of getting the correct answer for yourself -- and by that moment you'll really understand regex's well enough to probably not forget it.
- # 18:30 <zxq9> crazydiamond: Because you asked if 'abc' is a null string == '', and its not.
- # 18:30 <lobius> So having "us." in front of "models." is okay? That signifies localization?
- # 18:30 <crazydiamond> zxq9: so, result was None?
- # 18:30 <zxq9> crazydiamond: The ^ always means the beginning of the line. The $ always means the end of the line. So r'^goo' matches 'goo' and 'goober' but not 'you are goofey'
- # 18:30 <ejd> lobius: Sure. But you could also do `from django.contrib.localflavor.us.models import USStateField`
- # 18:30 <zxq9> crazydiamond: I prefer re.search for this sort of thing, btw.
- # 18:30 <zxq9> crazydiamond: Also, match and search return Match objects, not just T/F.
- # 18:45 <zxq9> crazydiamond: Because you can get more than a single hit in a body of text, so there is more to a Python regex than T/F.
- # 18:45 <zxq9> crazydiamond: Try this: "import re; res = re.match(r'^goo', 'goofey'); dir(res)" to see the methods res now has.
- # 18:45 <crazydiamond> zxq9: I guess that I need something like r'^[\t\s\n]*$'
- # 18:45 <zxq9> crazydiamond: You're on the right track now.
- # 18:45 <zxq9> crazydiamond: You could skip the ^ and $, though. They are redundant in this case; obviously everything you're searching for is included in the test string, so...
- # 18:45 <zxq9> crazydiamond: There are shortcuts for whitespace/non-whitespace (whitespace negated) etc so this problem is pretty easy to lick.
- # 18:45 <crazydiamond> zxq9: thanks for help! btw, may be you know, how to hook moment, when file in FileField gets deleted?
- # 18:45 <lobius> ejd: http://bpaste.net/show/0caaUZ67bSJ7ozeyRANS/
- # 18:45 <zxq9> crazydiamond: http://docs.python.org/library/re.html and http://docs.python.org/howto/regex.html are great resources. It takes a minute for it to sink in, but they are golden.
- # 18:45 <zxq9> crazydiamond: How to hook moment? I'm not sure what you mean?
- # 18:45 <zxq9> crazydiamond: Like what is the scenario
- # 18:45 <ejd> lobius: Looks good; then just `state_abbreviation = USStateField()` in the model definition
- # 18:45 <crazydiamond> i.e. in what procedure file get's deleted, when we are deleting instance
- # 18:45 <crazydiamond> *gets
- # 18:45 <lobius> Got it. Thank you.
- # 18:45 <zxq9> crazydiamond: hrm. Depends on what you are doing. "FileField" is just a string that holds the location in the file system where the file is. Deleting FileField has no effect on the file itself unless you make it that way on your own.
- # 18:45 <zxq9> crazydiamond: If you need to know the exact moment, then you explicitely delete the file yourself in your view code (or probably a utility function you call from the view)
- # 18:45 <zxq9> crazydiamond: Unless I'm misunderstanding your question. On the other hand, you could just store files directly in Postgres. That's actually not a bad thing with Postgres, which is contrary to MySQL experience, so a lot of people are scared to do that -- but it doesn't hurt (and makes backup really easy, just remember to vacuum/do db maintenance)
- # 18:45 <crazydiamond> I think it's better to store in FS :) i.e. there is pre_save method https://docs.djangoproject.com/en/1.3/howto/custom-model-fields/#preprocessing-values-before-saving , but no "pre_delete" there. Generally I want to develop a field or just a widget, that will give ability not just to add image, but to crop it before adding (with tool like jCrop)
- # 18:45 <zxq9> crazydiamond: So long as it isn't a *TON* of tiny files, then db vs FS you won't notice a difference -- but if it is a ton of little ones, the db is a significantly better option.
- # 18:45 <zxq9> crazydiamond: Anyway, the deletion of a file should be your choice, so you should code it into the view logic yourself. Then you have complete control over it.
- # 18:45 <zxq9> crazydiamond: I wrote a front-end for imagemagic a long time ago I call from my Django code to do stuff, and actually that utility deletes the raw uploaded image for me, then passes back the new full path and that gets saved in FileField. Deletion is all handled in a deletion view handler. I don't recall anything more automagic than this for deletions from Django.
- # 19:00 <lobius> ejd: do I use us.forms.USStateField in my view?
- # 19:00 <easytiger> is there a quick way in a template to print every value in a row?
- # 19:00 <zxq9> crazydiamond: Anyway, I wouldn't *want* framework code to do deletions for me.
- # 19:00 <easytiger> without manually specifying the fieldnames?
- # 19:00 <zxq9> easytiger: A row's values could contain M2M relation fields, and this would fail, so not exactly.
- # 19:00 <arni> Hi. Im using ModelForm, and want to update a record. Since the id of the ModelForm object I edit dont go to the template, and is not sent with the POST, when a user press update, how can I know what object i am modifying?
- # 19:00 <easytiger> zxq9: its just for debug reasons. thanks though.
- # 19:00 <iiie> arni: why doesn't the id of the Model go to the template?
- # 19:00 <ejd> lobius: Maybe. What are you trying to do?
- # 19:00 <zxq9> easytiger: You could get a list of its attributes and loop through them. Some of the output would probably be meaningless but that wouldn't hurt in your debug case (might even be what you're looking for)
- # 19:00 <zxq9> easytiger: I do most of that sort of exploration from the shell or from psql, though. This is particularly helpful if you are having to work with a (bad) data model inherited from someone else that has a lot of mysteries worked into it.
- # 19:00 <arni> iiie: I dont know. As far as I can tell it is not designed to go that way. So I am wondering if my design is "wrong". I can post my code in a sec.
- # 19:00 <easytiger> zxq9: that's exaactly my situation
- # 19:00 <easytiger> zxq9: thatnls will do that
- # 19:00 <lobius> ejd: this is part of my models.py: http://bpaste.net/show/JBZi00QjXRo1RX8klXnW/ I want the user to enter data regarding the client in a form. After the form is submitted, a record will be created in the database and a printable page with that data will come up. Wrote a web application years ago to do this but now I am compelled to rewrite the code because it is the last piece of ASP code we use and its holding up more efficient ways
- # 19:00 <arni> iie: http://dpaste.org/2dc7Y/
- # 19:00 <zxq9> easytiger: If the situation is particularly dire I opt for a cup of coffee, a giant printout of whatever formed the model (big printoout of the OML parts of the SQL or models.py if it was from Django originally, etc.) and some time poking between a psql session and a manage.py shell session side by side.
- # 19:00 <lobius> In my humble opinion, an MVT rewrite will allow for really long term maintainability of this code.
- # 19:00 <easytiger> zxq9: its not too bad. just have 5/6 tables
- # 19:00 <kklimonda> hmm, how to filter users on some field from their profile?
- # 19:00 <iiie> arni: you're switching your fields around, ClanName has clanId, but also id (an autofield) you're setting one with the other in your view
- # 19:00 <ejd> lobius: For this form, are you using https://docs.djangoproject.com/en/1.4/topics/forms/modelforms/ or something else?
- # 19:00 <arni> iee: I am using id, the autofield to identify the records
- # 19:00 <lobius> This sounds about right.
- # 19:00 <iiie> arni: clanId is not the primary key of your model; can you post the form section of your template?
- # 19:00 <ejd> lobius: If you want users to fill out forms that map (at least closely) 1:1 with models, ModelForms *should* be what you're after
- # 19:00 <zxq9> easytiger: If you get some weird situations, there is also this: https://docs.djangoproject.com/en/1.4/faq/models/
- # 19:00 <arni> iiie: http://dpaste.org/OQnOd/
- # 19:00 <crazydiamond> iiie: hi. may be you know the answer. I want to make a field class, based on CharField to make it hold name of the file (I'll take care of adding ). But I want my file to be deleted when model instance gets deleted. How do I do that? I see, that there is pre_save method in Field class, where I can do needed things when creating or editing happens, but there is no "pre_delete" or something.
- # 19:00 <lobius> ejd: this goes into models.py or views.py? Yes, it's 1:1.
- # 19:00 <easytiger> zxq9: cheers
- # 19:15 <arni> iiie: I added the html from the page as well, as it is rendered. I would assume it should be a hidden field with id or something in there.
- # 19:15 <iiie> arni: the form part should work; it's going to /addClan/ though (and your post in edit has pass -- I assume this is just a partial paste); if you look in the rendered html does it have a hidden field id?
- # 19:15 <iiie> arni: right
- # 19:15 <arni> iiie: new url http://dpaste.org/7fmLe/
- # 19:15 <iiie> crazydiamond: I'm pretty sure there is pre and post delete, but queryset update and delete won't call the signals or run the model delete method
- # 19:15 <crazydiamond> iiie: yes, these are signals, but I meant "pre_delete" method of the Field class, which is called anyway, isn't it?
- # 19:15 <crazydiamond> i.e. pre_save
- # 19:15 <crazydiamond> https://docs.djangoproject.com/en/1.3/howto/custom-model-fields/#preprocessing-values-before-saving this one
- # 19:15 <crazydiamond> in FileField case, FieldFile object has delete() metod, but from where is it called - I don't know
- # 19:15 <iiie> crazydiamond: to my knowledge there isn't a mechanism for that
- # 19:15 <crazydiamond> iiie: okay. thank you
- # 19:15 <arni> this guy have the same issue at me, but no answers :/ http://stackoverflow.com/questions/9563350/getting-modelform-to-insert-hidden-field-for-id-preventing-duplicate-instance-o
- # 19:15 <iiie> crazydiamond: hm, well if FileField does it can you extend FieldField rather than CharField?
- # 19:15 <crazydiamond> iiie: but I want only small part of it's functional (will deal with files myself, except for deletion). I think that CharField is pretty easy, and FileField is complex. So implementing it may cause problems
- # 19:15 <crazydiamond> so, I'll do more research in FileField's code :)
- # 19:15 <iiie> crazydiamond: then like you're saying look at filefield and copy it's layout and test (reporting back would be appreciated)
- # 19:15 <iiie> arni: agreed that's the same problem, but I don't know what could do that
- # 19:15 <arni> iiie: is modelform supposed to add a hidden field as id? or is it designed to take the id parameter from the url?
- # 19:15 <iiie> arni: modelform is just a form, it should have all fields (non-editable hiddent) (unless it has exclude or fields in the meta class)
- # 19:30 <Naglik> hello everyone
- # 19:30 <abisson> mmmm when I have a class definition like this: class PictureCreateView(CreateView): ... It needs a querySet right? which I define like this: model = Picture
- # 19:30 <abisson> could I say form_class = Picture instead?
- # 19:30 <abisson> Doesn't seem to work
- # 19:30 <arni> thanks a lot for clearing things up for me iiie
- # 19:30 <RobOakes> Morning everyone, I'm just getting started with Django and had a database API question.
- # 19:30 <RobOakes> Is there a simple way to retrieve a list of values for a particular field in a table?
- # 19:30 <RobOakes> For example, I'm writing a plugin for Calibre to synchronize the database with a cloud library application. I need to iterate over a very large collection of items looking for a particular ID.
- # 19:30 <RobOakes> If the ID is in the cloud database, I'd just like to skip it. It seems like Python's if object.id in list: would be a good way to do this. (Open to recommendations.)
- # 19:30 <gasull> With a CheckboxSelectMultiple widget, how do I preselect some of the checkboxes?
- # 19:30 <RobOakes> I can't figure out how to create said list without first retrieving the entire database, iterating over the collection to collect ids, and then checking the ids against that.
- # 19:30 <caleb_smith> RobOakes: Use exclude() possibly with an in clause...
- # 19:30 <caleb_smith> things = Things.objects.exclude(field_name_id__in=list_of_ids)
- # 19:30 <RobOakes> Oh, that's a good idea ...
- # 19:30 <caleb_smith> here, list_of_ids would be the list of ids that you want to exclude from the list. You are right in wanting to do it in the DB rather than retrieve all and do it in python
- # 19:45 <srj55> I want to monitor a twitter steam, and keep a list of all mentions/hashtags and counts. I was thinking of just using a dictionary, and then storing this in a text field as a json strucutre. However, I will be adding to this in realtime (every few sec), so I would have to keep reading the field, converting it to a Python Dict, update, and dumps(). Is this very efficient, or is there a better way?
- # 19:45 <ulbed> hi when i'm trying to run django with apache i get the exception 'unable to open database file' how can i fix it?
- # 19:45 <ulbed> i had an relative path in the settings and i replaced it with the absolute one, but it still shows the relative one in apache
- # 19:45 <RobOakes> I'll give that a try. That will help find both the books in the database that need to synced to Calibre and those in Calibre that need to be synced to the database.
- # 20:00 <wfq> hi guys
- # 20:00 <wfq> isn't raw available if using is used: models.MyModel.using("mydatabase").raw("sql here?")
- # 20:00 <wfq> oops, it is raw.using rather than using.raw
- # 20:00 <wfq> :)
- # 20:00 <nanonyme> wfq, ew :(
- # 20:00 <abisson> Design question: If I have a Company object and a AmazonStorage Object. Now, each Company will have its own AmazonStorage. Where should I put the FK. In Company or StorageObject?
- # 20:00 <abisson> How is a good rule of thumb for that?
- # 20:00 <abisson> What**
- # 20:00 <exicer> Hey guys, I'm having some trouble getting staticfiles to work. Namely, I'm trying to link to a css file, and it isn't working.
- # 20:00 <exicer> Any ideas what kind of thing I might have done wrong ?
- # 20:00 <crazydiamond> iiie: I'm figuring out interesting thing. When I delete model with FileField, file don't gets deleted
- # 20:15 <crazydiamond> iiie: neither when I change (upload other file instead of existing)
- # 20:15 <crazydiamond> exicer: what do you mean "link to"?
- # 20:15 <exicer> ah wrong word, I am trying to use a seperate css file as my css
- # 20:15 <exicer> rather than it just being in the html.
- # 20:15 <crazydiamond> okay. but where is your CSS file?
- # 20:15 <crazydiamond> in the filesystem
- # 20:15 <exicer> in the apps /static/ direcotry
- # 20:15 <crazydiamond> hmm... have you launched python manage.py collectstatic?
- # 20:15 <exicer> I thought that this wasn't necessary? Until I deploy ?
- # 20:15 <crazydiamond> I don't know exactly, but I think that it's needed anyway
- # 20:15 <crazydiamond> e.g. my Grappelli admin was unstyled unless I done this command
- # 20:15 <crazydiamond> *until
- # 20:15 <wfq> guys
- # 20:15 <wfq> who do I get the value return from models.MyModel.raw("select now() as datetime")?
- # 20:15 <wfq> *how
- # 20:15 <wfq> it is bloody tellin me Raw query must include the primary key when I try to do b[0-
- # 20:15 <wfq> *fuck sake: b[0]
- # 20:15 <wfq> where the first object should be?
- # 20:30 <wfq> is there any way where I can see what the rawqueryobject's structure is? this is just ridiculous
- # 20:30 <ulbed> hi when i'm trying to run the django tutorial with apache i get the exception 'unable to open database file' how can i fix it?
- # 20:30 <ulbed> i had an relative database path in the settings and i replaced it with the absolute one, but it still shows the relative one in apache
- # 20:30 <reenignEesreveR> my pendulum of decision is swinging between putting all the CSS info of a form in the form widget or putting it right in HTML and manually rendering every field of the form.
- # 20:30 <reenignEesreveR> What is the preferred django aproach?
- # 20:30 <reenignEesreveR> if i put all CSS related info using widgets/attr in python code, it'll couple the backend with frtonend's intricacies
- # 20:30 <reenignEesreveR> however if i bring everything to .html, i'll have to laboriously type a lot of maxlength attributes etc.
- # 20:30 <reenignEesreveR> any middle way?
- # 20:30 <iiie> wfq: models.MyModel.objects.raw(....) needs to select from the table for MyModel so that the ORM can return an object, which is the expected usage using the ORM
- # 20:30 <wfq> iiie, is there any way to overcome this please?
- # 20:30 <iiie> ulbed: sqlite? does the apache user have write access to the file and parent directory?
- # 20:30 <adoven> wfq: I'm guessing you could fake it by doing models.MyModel.objects.raw('select 1 as id, now() as datetime')
- # 20:30 <iiie> wfq: if you want a database cursor, use the cursor not through models
- # 20:30 <adoven> but yeah, use a cursor like iiie suggests
- # 20:30 <wfq> adoven, iiie what do you mean by cursor? Could you please point me out any doc?
- # 20:30 <wfq> ah you mean this: https://docs.djangoproject.com/en/dev/topics/db/sql/#connections-and-cursors
- # 20:30 <iiie> wfq: looks right yes
- # 20:30 <iiie> reenignEesreveR: class attributes on forms is okay, CSS should be able to pick and make changes without changing the backend (python) code
- # 20:45 <reenignEesreveR> iiie ... lets say my designer has given me this sliced HTML piece: <input type="text" name="pick-up" id="pick-up" class="auto-hint" title="Address" />
- # 20:45 <reenignEesreveR> this `title="Address"` portion is only going to be a used on normal site ... desktop version is not going to use it
- # 20:45 <reenignEesreveR> so in that case i'd like to have one form usable in two templates
- # 20:45 <iiie> reenignEesreveR: override in the template http://pypi.python.org/pypi/django-widget-tweaks
- # 20:45 <reenignEesreveR> thats really really nice!
- # 20:45 <reenignEesreveR> is there anything closer which is built-in in django ?
- # 20:45 <reenignEesreveR> asking just out of curiosity
- # 20:45 <reenignEesreveR> because im finding django getting in my way here
- # 20:45 <iiie> reenignEesreveR: you're wanting two different templates but without two different templates; (can of worms time) how would one make a system that didn't couple the attributes to the form fields work? (without making everyone always write out all the HTML)
- # 20:45 <reenignEesreveR> hmm....
- # 20:45 <reenignEesreveR> right
- # 20:45 <reenignEesreveR> but isn't that annoying with django's builtin feature set???
- # 20:45 <iiie> reenignEesreveR: I am unaware of a way to change attributes on a form built in to django without sub-classing or monkey patching the form
- # 20:45 <reenignEesreveR> and surely monkey patching still must be done in python, not possible in templates
- # 20:45 <iiie> reenignEesreveR: right, sub-classing and monkey patching the form class or instance, it's all in python (the package -- and similar are the only things I've seen to make the change in the template; though of course they are python too)
- # 20:45 <sirfilip> night guys
- # 20:45 <reenignEesreveR> i think this widget tweaks is a perfect match for me. Thanks a lot :-)
- # 21:00 <reenignEesreveR> iiie, have you ever considered jinja?
- # 21:00 <iiie> reenignEesreveR: I have considered, but never ran with it
- # 21:00 <reenignEesreveR> right
- # 21:00 <easytiger> whats the difference between dajax and dajax-ice?
- # 21:15 <wfq> hi guys
- # 21:15 <Efrin> hey
- # 21:15 <Efrin> whats up ;)?
- # 21:15 <wfq> who is it possible that this: http://dpaste.com/744374/ shows the wrong datetime and when I run the query within the database the time is the right one?
- # 21:15 <wfq> this is making me go crazy
- # 21:15 <hamms> are your system and database set to different timezones?
- # 21:15 <wfq> this is completely crazy. My web handles to database. If I used the the function above for querying my local database the time is right. If I do it with the remote database, the time is wrong but "select now() as datetime" on such databse returns the right time. Now if I print datetime.now() on the console, the time is bloody wrong as well while on the local system, date actually provides the
- # 21:15 <wfq> right time. wtf?
- # 21:15 <wfq> I think the datetime returned by the remote database is not understood by python somehow and return the default current time which is wrong!
- # 21:15 <wfq> "2012-05-07 20:06:37.443+01" -->indeed I don't think python can deal with this?
- # 21:30 <wfq> the problem is cursor.fetchone returns already a datetime object. Is there a way of taking such entry raw?
- # 21:30 <ulbed> hi when i'm trying to run the django tutorial with apache i get the exception 'unable to open database file' after some force refreshs (ctrl+f5) how can i fix it? i had a relative path name before but now i have changed it to an absolute path in my settings.py... however on the error page the path is still relative
- # 21:30 <apollo13> restart apache
- # 21:30 <wfq> my goodnes!!! but why?!
- # 21:30 <wfq> wtf is going on?
- # 21:30 <apollo13> wfq: those comments help noone ;)
- # 21:30 <wfq> "2012-05-07 20:13:53.853" --> is there anything wrong that datetime to be converted to datetime?
- # 21:30 <ulbed> ah restarting solved but didn't know that the *.pyc weren't refreshed when the source changes
- # 21:30 <wfq> don't understand a thing
- # 21:30 <wfq> is there anyway to access the cursor data manually so that python doesn't convert to datetime a string such the one shown above?
- # 21:30 <apollo13> no
- # 21:30 <apollo13> just assume that the conversion is correct and the error is on your side
- # 21:30 <yaderv> Hi, I'm following this tutorial https://docs.djangoproject.com/en/1.4/intro/tutorial01/#the-development-server but I got this error http://fpaste.org/7dZp/ with the command python manage.py runserver
- # 21:30 <yaderv> what can I do?
- # 21:30 <wfq> so what is going on then? there is no other intervention that the code I showed
- # 21:30 <apollo13> yaderv: hmm that looks more like a system issue then django
- # 21:45 <apollo13> yaderv: are you using fedora?
- # 21:45 <wfq> apollo13, are you around?
- # 21:45 <apollo13> wfq: no
- # 21:45 <wfq> now() does return the correct time
- # 21:45 <wfq> but when that is made from python, it doesn't
- # 21:45 <apollo13> yes it does
- # 21:45 <wfq> how do you know?
- # 21:45 <wfq> apollo13, see this: datetime.datetime(2012, 5, 7, 14, 27, 12, 530192)
- # 21:45 <apollo13> cause you'd be the first one where its wrong ;)
- # 21:45 <wfq> this is what datetime.now() shows which is wrong as I have got now 20:35
- # 21:45 <wfq> the server shows the right time
- # 21:45 <yaderv> apollo13, yes I do
- # 21:45 <celloflax> Hi, i need to inser a search field in admin. The filter is composed from 2 datefields that rapresent if some locations (model) is free or not in a period.. There is a way to do it in django 1.4?
- # 21:45 <wfq> nevertheless, select now() in the databse shows the right datetime
- # 21:45 <crisisking> wfq, is your database on a separate machine
- # 21:45 <wfq> crisisking, yes it is but it provides the right time. I did the select now() from there and it works ok
- # 21:45 <apollo13> yaderv: can you try another system?
- # 21:45 <apollo13> wfq: do you know what timezones are?
- # 21:45 <wfq> yes, europe=london
- # 21:45 <apollo13> lol
- # 21:45 <wfq> echo $TZ prints nothing
- # 21:45 <crisisking> wfq, can you run "date" from the shell on the machine that's generating the wrong time?
- # 21:45 <soidexe> hey there! Can anybody help me with problem described here: http://stackoverflow.com/questions/6963491/django-csrf-for-both-http-and-https How can I fix it without removing "fastcgi_param HTTPS on" ?
- # 21:45 <wfq> crisisking, it is the right time: you will see. let me try
- # 21:45 <wfq> Mon May 7 20:30:26 BST 2012
- # 21:45 <apollo13> that's wrong!!!!!
- # 21:45 <apollo13> ;)
- # 21:45 <wfq> if I do cat /etc/sysconfig/clock I have got: ZONE="Europe/London"
- # 21:45 <wfq> why is that wrong?
- # 21:45 <apollo13> well yes so it's currently 19:30
- # 21:45 <exicer> BST
- # 21:45 <apollo13> (utc beeing the only relevant time ;))
- # 21:45 <wfq> but anyway, that is completely different from getting the datetime from the database. Python should return a datetime object with the time established at the machine where the remote databse is as I am just doing a select now() query
- # 21:45 <apollo13> soidexe: that's a security feature
- # 21:45 <wfq> but why on earth it keeps showing the same wrong datetime as if I was doing datetime.now()?
- # 21:45 <apollo13> if you post to https you have to come from https
- # 21:45 <wfq> I don't understand it
- # 21:45 <soidexe> apollo13: ah, got it. It seems I have another kind of error: the referrer is https and it still fails
- # 21:45 <soidexe> apollo13: https, but another host
- # 21:45 <soidexe> apollo13: "Forbidden (Referer checking failed - https://apps.facebook.com/vkubiki/?fb_source=bookmark_apps&ref=bookmarks&count=0&fb_bmpos=2_0 does not match https://www.dicefield.com/.): /facebook.html"
- # 21:45 <apollo13> well yeah obviously, csrf is to protect from that ;)
- # 21:45 <crisisking> wfq: in your settings.py file, what is the TIME_ZONE set to?
- # 21:45 <apollo13> let's bet it's something AMERICA*
- # 21:45 <crisisking> probably chicago
- # 21:45 <crisisking> that's the default
- # 21:45 <soidexe> apollo13: how can I go around that? I already set @csrf_exempt @requires_csrf_token decorators for the view
- # 21:45 <wfq> crisisking, it is empty
- # 21:45 <apollo13> soidexe: uhm @csrf_exempt should be enough to let facebook post to the view
- # 21:45 <crisisking> empty as in TIME_ZONE = ''? or just not present?
- # 21:45 <wfq> TIME_ZONE = ""
- # 22:00 <rns> how does django handle race conditions? For example, if 2 users are using the same account and submit the same form at the same time with different data, what happens?
- # 22:00 <soidexe> apollo13: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#unprotected-view-needs-the-csrf-token
- # 22:00 <apollo13> rns: one wins
- # 22:00 <wfq> crisisking, just realized that if I get into python console without the django context I actually get the righttime
- # 22:00 <apollo13> rns: django doesn't handle it at all
- # 22:00 <wfq> * time
- # 22:00 <soidexe> apollo13: "There may be some views that are unprotected and have been exempted by csrf_exempt, but still need to include the CSRF token."
- # 22:00 <apollo13> wfq: both times are right
- # 22:00 <apollo13> it's just a matter of display, and you should only rely on utc
- # 22:00 <wfq> apollo13, I know both are right
- # 22:00 <wfq> actually as soon as I changed django's timezone to europe/london and went back to the console with django's context the time is right
- # 22:00 <apollo13> but please, don't use datetime.now at all
- # 22:00 <molavy1> i have problem on nignx django config
- # 22:00 <molavy1> nginx config:
- # 22:00 <molavy1> http://dpaste.com/744403/
- # 22:00 <molavy1> django setting file:
- # 22:00 <molavy1> http://dpaste.com/744404/
- # 22:00 <lobius> Both can't be true: http://bpaste.net/show/hCaT0pNGcndK5LsMmvFH/ I think the postal code field has the wrong description. It would be a violation of DRY. Can anybody enlighten me on what the difference is?
- # 22:00 <molavy1> nginx error file: http://dpaste.com/744405/
- # 22:00 <molavy1> what is best way i configure django and nginx
- # 22:00 <wfq> bloody hell that was the error. For whatever reason the remote machine had a different timezone (time in the future) so when I tried to get the time, I was getting the present time within the local machine which corresponded to the default timezone set by Django
- # 22:00 <wfq> at last! after 5 hours! This is what I call efficiency
- # 22:00 <molavy1> and why i can't show static file with above config ,what error say?
- # 22:00 <molavy1> any idea?
- # 22:00 <apollo13> wfq: if you just would use utc all your problems would vanish
- # 22:00 <red5> i need to filter combo box's content on admin based on user's authorization. how i do it ?
- # 22:00 <red5> is it possible?
- # 22:00 <ASUChander> Is there a model already in existance for PostgreSQL's information_schema.* tables/views?
- # 22:00 <apollo13> red5: yes, just override the queryset method
- # 22:00 <apollo13> ASUChander: of course not
- # 22:00 <molavy1> what is wrong in this config:
- # 22:00 <molavy1> nginx config: http://dpaste.com/744403/ django setting file : http://dpaste.com/744404/ nginx error file: http://dpaste.com/744405/
- # 22:00 <ASUChander> apollo13: I understand the "not", though I'm not certain why you would assume it's so obvious (the "of course") ? Seems like it would be a useful thing to have...
- # 22:00 <celloflax> Is it possible to add a custom search_fileld in django admin
- # 22:00 <celloflax> ?
- # 22:00 <apollo13> ASUChander: not really, first of all it's database specific and secondly which information do you require in a normal webapp
- # 22:00 <red5> apollo13: is there any possibility to filter one specific field ?
- # 22:00 <apollo13> (btw I ment it's surely not in django core, no idea if it's somewhere else)
- # 22:00 <apollo13> red5: yes, override queryset
- # 22:00 <ASUChander> apollo13: The standard isn't database specific, actually...
- # 22:00 <brixtonasias> Good day everyone. Anyone experienced with running Django in/on Heroku? I'm interested in how the workflow looks - testing locally (how to configure things) and then pushing to live, how do you handle this?
- # 22:00 <nanonyme> urf
- # 22:00 <apollo13> ASUChander: the sql standard? right but the implementation of it is ;)
- # 22:00 <Pio> i have a script that im using to migrate mysql -> postgres, and the first thing I do is blah.objects.all().delete() on each model to clear the target postgres database
- # 22:00 <mlavin> lobius: US postal service areas includes Compact of Free Association locations as well as US states and territories https://github.com/django/django/blob/master/django/contrib/localflavor/us/us_states.py#L136
- # 22:00 <Pio> and when i do this, on our dev server im running out of memory
- # 22:00 <apollo13> that sounds a bit odd, .delete shouldn't use much memory
- # 22:00 <ASUChander> apollo13: Yeah, the underlying module would need to provide some level of abstraction.
- # 22:15 <Pio> so i tried to make a stepped delete that would delete in chunks of 1000 or whatever, but i get assertionerror: Cannot use 'limit' or 'offset' with delete.
- # 22:15 <apollo13> did you change DEBUG to False?
- # 22:15 <nanonyme> apollo13, actually it does with downright insane object counts
- # 22:15 <red5> apollo13: i saw one example using 'formfield_for_foreignkey' method
- # 22:15 <Pio> the memory consumption is high because its cascading the deletes across foreign keys
- # 22:15 <molavy1> there is no idea?
- # 22:15 <apollo13> nanonyme: the queryset method as opposed to object.delete()?
- # 22:15 <nanonyme> also, have to remember to shut the server down before running that command
- # 22:15 <red5> apollo13: is it another alternative ?
- # 22:15 <apollo13> ah crap, .delete checks foreignkeys too? that's ugly
- # 22:15 <Pio> oh, yeah, i could iterate and then delete each item individually
- # 22:15 <nanonyme> ie only Django shell running just in case
- # 22:15 <apollo13> Pio: well there is a easy workaround
- # 22:15 <easytiger> anyone dajaxice? i'm getting "Error: No module named dajaxice" when i run collectstatic
- # 22:15 <Pio> rather than using querset
- # 22:15 <Pio> that is actually 'good enough' for my purposes
- # 22:15 <lobius> mlavin: figured out how to get around it. It's a confusing name but it's all good now.
- # 22:15 <apollo13> just call TRUNCATE on the table
- # 22:15 <Pio> since this is just a one-off
- # 22:15 <red5> apollo13: i've tried but doesn't works
- # 22:15 <apollo13> Pio: btw why don't you use a clean database?
- # 22:15 <Pio> syncdb doesnt create a 100% empty database
- # 22:15 <mlavin> lobius: yes the names are not obvious
- # 22:15 <apollo13> Pio: well the few items it creates should hardly kill your memory
- # 22:15 <Pio> yep
- # 22:15 <Pio> well
- # 22:15 <apollo13> odd
- # 22:15 <Pio> thats a good point.. wtf
- # 22:15 <Pio> now i have to go look at this again heh
- # 22:15 <apollo13> you are sure you are not dumping your production db or so?
- # 22:15 <Pio> i also was havign partially completed migrations that i was clearing out so sometimes there was a lot of data
- # 22:15 <Pio> but there was also times when there was not.. so somethings weird..
- # 22:15 <jr_jacob> URGENT- We are looking for a Django professional -Solr,haystack - for next few hours to fix some problems on our Django project.Anyone interested, please send me msg for details on private..
- # 22:15 <Pio> i think thats all it is, it OOMs when i delete partially completed earlier runs, but that doesnt matter cause if i drop/recreate/resyncdb it doesnt
- # 22:15 <Pio> thanks for pointing that out apollo13 :)
- # 22:15 <jr_jacob> URGENT- We are looking for a Django professional -Solr,haystack - for next few hours to fix some problems on our Django project.Anyone interested, please send me msg for details on private..
- # 22:15 <apollo13> jr_jacob: enough
- # 22:15 <gamingdroid> anyone use an ajax based login with auth?
- # 22:15 <molavy1> there is no idea?
- # 22:15 <jturo> Hi there, I've got a simple helloWorld unit test, it involves no database connectivity and and yet it takes forever, any ideas how can i find out what the issue is?
- # 22:15 <jr_jacob> anyone avaliable or interested?
- # 22:30 <jfilipe> anyone using robot framework with django?
- # 22:30 <gamingdroid> is there a way to dump all the variables in a request context from within a template?
- # 22:30 <apollo13> {% debug %} probably
- # 22:30 <apollo13> not sure what it does though, you'll have to look it up
- # 22:30 <gamingdroid> apollo13: thanks, it gave me "Outputs a whole load of debugging information, including the current context and imported modules.", he he he
- # 22:30 <wfq> is the session renew with any request to the server?
- # 22:30 <apollo13> ?
- # 22:45 <wfq> well I mean when an user logs in, how does this renew his session? I can guess the session counter is reset to 0 with any request (via ajax or not) that the user does to the server?
- # 22:45 <apollo13> session counter?
- # 22:45 <apollo13> if you want to reset the timeout you either have to do it manually or set SESSION_SAVE_EVERY_REQUEST=True
- # 22:45 <PKKid> jr_jacob, Are you Mr. Kaplan-Moss or his understudy? :D
- # 22:45 <apollo13> loool
- # 22:45 <apollo13> PKKid: jacobkm is the jacob km
- # 22:45 <wfq> apollo13, thanks
- # 22:45 <PKKid> apollo13, lol thx. :D
- # 22:45 <PKKid> also true.
- # 22:45 <PKKid> but hisunderstudy might? :D
- # 22:45 <apollo13> wouldn't be long there then
- # 22:45 <jturo> Hi there, I've got a simple helloWorld unit test, it involves no database connectivity and and yet it takes forever, any ideas how can i find out what the issue is?
- # 22:45 <apollo13> jturo: define forever, throw cprofile at it and or gdb
- # 22:45 <jturo> what's cprofile
- # 22:45 <jturo> ?
- # 22:45 <jturo> python performance analisis
- # 22:45 <jturo> interesting
- # 22:45 <jturo> @apollo13 thanks that's enough to get me going. This irc chat is excellent unlike kohana's! :)
- # 22:45 <PKKid> Well, it didn't take much to please that guy. :D
- # 23:00 <riley526> Has anyone seen this error before when running `./manage.py runserver` with a url specified? "Error: [Errno 8] nodename nor servname provided, or not known"
- # 23:00 <tktiddle> Does anyone use uwsgi with nginx? can you help me with my config?
- # 23:00 <riley526> A plain `./manage.py runserver` works fine.
- # 23:15 <iiie> Don't know what a url specified with runserver would be, IP and port, but URL?
- # 23:15 <sll> hello, I would some tips to use WSGIDaemonProcess in order to fix processes and threads parameters for a LAN with 25 clients. The app lets search and filter about 3000 video titles and play them. Thank you ;)
- # 23:15 <iiie> tktiddle: we can try, dpaste (I do run uwsgi with nginx -- that's not a guarantee that I'll be able to fix it)
- # 23:15 <kinabalu> SmileyChris: you authored the easy_thumbnails for django I see ... wow :)
- # 23:15 <SmileyChris> kinabalu: yay for leaving my silly versioning behind! :)
- # 23:30 <kinabalu> SmileyChris: silly versioning? :) it looks like you have your hands everywhere in django
- # 23:30 <SmileyChris> kinabalu: it was up to version 1.0.0-alpha-eleventybillion1
- # 23:30 <SmileyChris> kinabalu: so i threw that away and called yesterdays release 1.0
- # 23:30 <SmileyChris> kinabalu: but yeah, I'm a commoner around these parts
- # 23:30 <SmileyChris> hamms: http://djangopackages.com/grids/g/forums/
- # 23:30 <molavy1> i have lot of problem about config django and nginx , that take about 3 hour without success
- # 23:30 <iiie> sll: what do you see as your bottleneck? are the "large files" run through django or by the same apache or through their own apache instance? (things to think about) are the large files created live? if they're stored files use the sendfile header and don't have django do the heavy lifting. if your wsgi daemon is the bottleneck up the processes to the number of simultaneous processes you want; the easy win is handoff transfer if you can
- # 23:30 <hamms> yeah, I found that and am playing with DjangoBB now. Just wondering if anyone had any opinions on any of these
- # 23:30 <SmileyChris> it would be nice if someone made a pretty vanilla-like board
- # 23:30 <molavy1> there is no easy way that i can't start django nginx
- # 23:30 <molavy1> ?
- # 23:30 <SmileyChris> hamms: personally I despise the standard "forum" look. Signatures, name and icon and "score" at the side... ugh
- # 23:30 <iiie> molavy1: what do you have so far? how are you running django? wsgi, fastcgi?
- # 23:30 <kinabalu> SmileyChris: haha, everything is alpha until it's not, which is never :)
- # 23:30 <hamms> SmileyChris: amen. We're probably going to completely retemplate DjangoBB if we go that route
- # 23:30 <SmileyChris> hamms: maybe you could make the prodigal app :D
- # 23:30 <molavy1> fastcgi
- # 23:30 <SmileyChris> rly?
- # 23:30 <molavy1> python manage.py runfcgi host=127.0.0.1 port=8082 daemonize=false
- # 23:30 <SmileyChris> people still use that?
- # 23:30 <molavy1> and this is my nginx config file
- # 23:30 <kinabalu> SmileyChris: so is south a very commonly used module? i'm assuming yes
- # 23:30 <molavy1> http://dpaste.com/744449/
- # 23:30 <SmileyChris> kinabalu: yep, it's nearly mandatory if you're going to work with third party apps
- # 23:30 <iiie> molavy1: alright, so I take it that the fastcgi stops from time to time. What are you using to run the management command? (I like supervisor)
- # 23:30 <gamingdroid> I cannot find the urls.py file that is included by admin.site.urls (the admin)?
- # 23:30 <Ronnie> i have a problem in firefox when i want to view the page source of my django development site. when im on a page that requires login and view the page source on firefox i get the source of the login page. Looks like firefox is nog sending cookie information when loading page source. Has anyone had this problem too?
- # 23:30 <gamingdroid> it doesn't appear to be in django.contrib.admin.py
- # 23:30 <gamingdroid> Ronnie: FF appears to work fine for me with page source and being logged in
- # 23:30 <SmileyChris> gamingdroid: django.contrib.admin.sites
- # 23:30 <molavy1> iiie,how can create stable nginx config for my django app, static file don't show up
- # 23:30 <SmileyChris> gamingdroid: it's a property of the site class
- # 23:30 <Ronnie> hmm strange. which version of firefox + os do you have?
- # 23:30 <iiie> Ronnie: I've seen that before yes, I don't know how I got around it (I don't recall what browser it was on, but it was a while back now)
- # 23:45 <SmileyChris> FYI, i see there's a new Django podcast started -- http://3rdaverad.io/shows/django-podcast/episodes/episode-1/
- # 23:45 <iiie> molavy1: I'd take out root from the /static/ location, and put break at the end (you've built or collected static right?)
- # 23:45 <Ronnie> i usually work with firebug, so im not needing page source. but i wanted to validate my html through the w3c validator. but thats somehow impossible now. ill try chrome for a minute
- # 23:45 <gamingdroid> Ronnie: I'm on CentOS 6.5 with FF 10.0.3
- # 23:45 <Ronnie> im on ubuntu 11.10 with FF 12. i think it happend in one of the firefox upgrades (could be around version 10)
- # 23:45 <molavy1> what mean collect static ,all static file's are in static folder
- # 23:45 <iiie> molavy1: sorry, and remove the location in location you don't need it to be by extension everything in static is static
- # 23:45 <molavy1> ?
- # 23:45 <gamingdroid> What is the proper place to set the 'from_email' for the password reset email as part of django.contrib.auth? I set it in the urlpattern, but that seems like the wrong place.
- # 23:45 <iiie> molavy1: command depends on version https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#collectstatic
- # 23:45 <iiie> gamingdroid: https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email might be what you're after
- # 23:45 <iiie> molavy1: it pulls all the static media into one directory (or symlinks -- I recommend symlinks)
- # 23:45 <gamingdroid> iiie: thanks, but that is for a site-wide default. I need specifically for the password reset for django.contrib.auth. I'm thinking maybe load it from settings and then set it in urls.py. Not so elegant, but hopefully you can load settings at that point...
- # 23:45 <iiie> gamingdroid: you can (I do it a fair amount)
- # 23:45 <abisson> hey guys! How can we quickly display the other classes that uses the current model I am seeing in the admin panel? [Inlines are too much information]
- # 23:45 <abisson> no...?!
- # 23:45 <abisson> lol
- # 23:45 <Zilly> Does anyone run Django on EC2? How many requests per second can a micro instance handle?
- # 23:45 <abisson> Zilly: I have played a bit with Micro on EC2
- # 23:45 <abisson> They are very slow
- # 23:45 <abisson> Small is a huge increase over micro
- # 23:45 <Zilly> abisson, awesome! Is there a good way to test how much it'll handle?
- # 23:45 <abisson> and still dirt cheap
- # 23:45 <abisson> Zilly: Not that I know of...
- # 23:45 <Zilly> abisson, yeah, it is super cheap. I'm just trying to figure out if it's better to use AWS or to try to host myself.
- # 23:45 <kinabalu> abisson: I haven't checked prices on instances on EC2 in a while, they've dropped significantly in prices?
- # 23:45 <sll> iiie: I think "bottleneck" is more clear in response time when search to show result list, than serving video files. Files are stored directly and apache serves them.
← next day
previous day →