Re: get_FOO_display

2011-12-12 Thread Mike Dewhirst
On 13/12/2011 5:21pm, kenneth gonsalves wrote: On Tue, 2011-12-13 at 17:16 +1100, Mike Dewhirst wrote: THINGS = ( (0, 'Thing Zero'), (1, 'Thing One'), ) what happens when you do: THINGS = ( ('0', 'Thing Zero'), ('1', 'Thing One'), ) By golly it worked! Mus

Re: Decorator aware Django

2011-12-12 Thread Russell Keith-Magee
On Tue, Dec 13, 2011 at 8:49 AM, Bernardo wrote: > One thing the project I was working had and I liked was lots of > decorators on top of controllers (what you people call views - and > makes sense) > Something like that: > > #- > > @require_permission('login') > @expos

Re: get_FOO_display

2011-12-12 Thread kenneth gonsalves
On Tue, 2011-12-13 at 17:16 +1100, Mike Dewhirst wrote: > THINGS = ( (0, 'Thing Zero'), > (1, 'Thing One'), ) what happens when you do: THINGS = ( ('0', 'Thing Zero'), ('1', 'Thing One'), ) -- regards Kenneth Gonsalves -- You received this message because you

get_FOO_display

2011-12-12 Thread Mike Dewhirst
I'm getting a puzzling error trying to follow the dev docs here ... https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.get_FOO_display I syncdb'd a simple test model to eliminate everything except the essentials with ... class SimpleTest(models.Model): THI

Decorator aware Django

2011-12-12 Thread Bernardo
I've been working lately (not my choice!) with Pylons and the terrible Genshi as template system. The thing is: for the next project I wanted to use something better and the first thing I could think of was Django. I spent the last weaks reading documentation (FAQs, installation, templates, models

Re: How to change the representation of newline?

2011-12-12 Thread Germán
Has anybody solved this issue? On Dec 14 2006, 2:47 pm, "Aidas Bendoraitis" wrote: > I ran out of ideas. :) Maybe somebody else has any thoughts regarding new > lines? > > Good luck with Django! > Aidas Bendoraitis [aka Archatas] > > On 12/14/06, zhongke chen wrote: > > > > > > > > > firefox sh

Re: Django Upload Image Help

2011-12-12 Thread Mike Dewhirst
On 13/12/2011 5:25am, cmc wrote: write_info = "name: %s\n caption: %s\n source: %s\n more_info: %s\n\n" % photo.name, caption, source, more_info and I've always had to put parentheses around the values on the right hand side of the % like this ... write_info = "name: %s\n caption: %

Re: Django Upload Image Help

2011-12-12 Thread Reinout van Rees
On 12-12-11 19:25, cmc wrote: I am trying to use django to upload images but its not working as expected. Here is what I'm working with Ehm, you're not telling us what goes wrong or unexpected :-) There's one thing that I see in your code that might be a problem: #handle_uploaded_image.py

Django Upload Image Help

2011-12-12 Thread cmc
I am trying to use django to upload images but its not working as expected. Here is what I'm working with #handle_uploaded_image.py def handle_uploaded_image(photo, caption, source, more_info): photo_dir = '%s/uploaded_photos/Not_Published/%Y/%m/%d' % settings.MEDIA_ROOT photo

Re: Redirect from get_queryset() in a class view?

2011-12-12 Thread Nan
I'm not sure, not having explored CBVs yet, but yes, I suspect you'll want to either decorate or override the method that usually returns the HttpResponse. On Dec 12, 1:50 pm, Eli Criffield wrote: > I like the raise exception idea, but where do i catch it? > In a decorator? > Overwrite get() ?

Re: Redirect from get_queryset() in a class view?

2011-12-12 Thread Eli Criffield
I like the raise exception idea, but where do i catch it? In a decorator? Overwrite get() ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/KMhk4RFokUAJ. T

Re: Redirect from get_queryset() in a class view?

2011-12-12 Thread Nan
I'd recommend against doing that, as it's a strong violation of MVC principles. Instead you should either catch the ModelName.DoesNotExist exception in a custom (or inherited, or generic- view-wrapping) view, or raise a custom exception in your get_queryset method and catch that exception instead

Re: Redirect from get_queryset() in a class view?

2011-12-12 Thread Dan Gentry
I faced a similar situation where I had to check for valid input data used to build the query in get_queryset(). My solution was to use a decorator around the dispatch() function, but I think it could also be used within that function. I chose dispatch() because it acts like a traditional view fu

Re: converting from function based views to class based views

2011-12-12 Thread Dan Gentry
I can't test this, but the code below may do what you want. (I learned this stuff from Reinout's blog posts) # urls.py (r'^tags/(?P[a-zA-Z0-9_.-]+)/$', djangoblog.tag_views.TagDetailListView.as_view()) # views.py from django.views.generic import ListView class TagDetailListView(ListView):

Re: Django Forms and Twitter Bootstrap - Add fieldset, div wrapper and CSS labels to Django Forms?

2011-12-12 Thread Tomek Paczkowski
Check out this little tool: http://pypi.python.org/pypi/django-widget-tweaks Here's how I use it: https://github.com/oinopion/twitz/blob/master/templates/statuses/_status_update_form.html -- You received this message because you are subscribed to the Google Groups "Django users" group. To view

Re: Django Forms and Twitter Bootstrap - Add fieldset, div wrapper and CSS labels to Django Forms?

2011-12-12 Thread Ezequiel Bertti
See this example: https://github.com/ebertti/django-registration-bootstrap have a example using django-registration On Mon, Dec 12, 2011 at 07:37, Lukas Vinclav wrote: > Hi, > > I am using Twitter Bootstrap in Django for a long time. Here are > directions how to achieve correct result. > > 1.

Re: Django Forms and Twitter Bootstrap - Add fieldset, div wrapper and CSS labels to Django Forms?

2011-12-12 Thread Lukas Vinclav
Hi, I am using Twitter Bootstrap in Django for a long time. Here are directions how to achieve correct result. 1. Create new file for displaying forms in templates directory(e.g. forms.html) 2. In forms.html write the form displaying logic. This is just an example. You have to set bootstrap's c

Best approach to code an inventory system

2011-12-12 Thread sebastien piquemal
HI ! We currently have an inventory system for our employees. It contains laptops, phones, but also ergonomic chairs, fridges or software licenses ... So very different stuff that admins can create/read/ update/delete. After doing a version completely based on admin interface, I gave up cause it

Re: working with forms , problem !!!

2011-12-12 Thread Alagappan
Adding the csrf context processor would fix it. Refer to https://docs.djangoproject.com/en/dev/ref/contrib/csrf/ for more details. As suggested, you can add your own render_to_response() wrapper, if you are likely to use it often. -- *Regards,* *Alagappan Ramu (http://alagappan.co.in) * -- You