Saint Petersburg Django meetup!
Hello, my fellow Django users! I'd like to invite you a meetup of Django users in Saint Petersburg, Russia, this Saturday. We think that the growing more than ever community of developers who use Django in Petersburg is overdue to meet, drink some tea and talk about the future. If you live in Saint Petersburg or going to be visiting SPb on Saturday, please come and meet us. The meeting will take place at "HomeWork", Ulitsa Rubinshteyna, 15/17, ap. 259. We're going to start at 15:30, Saturday, 16th of July 2011. For more information, please take a look at http://vkontakte.ru/event28601307. If you don't use this website, you can also read more at http://pep8.ru/event/2/post/2 . Please take a look at one of these webpages to avoid problems with getting into the venue. Our page at Lanyrd: http://lanyrd.com/2011/djangotea/ Please help us spread the word: tell your friends and colleagues about our meeting. If you have any problems, you can ask in this thread or contact me directly: v...@whitescape.com. Thank you. Looking forward to see you at the meeting! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No get_absolute_url in Django admindocs
Hello, get_absolute_url() methods for any of my models do not show up in admin.docs. Is it a bug or a feature? The source of this behavior is what guard "len(inspect.getargspec(func) [0]) == 1" [1] does not work. I think it is because of some get_absolute_url() hackery in Django [2]. I'd also want to know how are things going with admindocs in general. I'm trying to use them a lot to help our front-end developers, but there are caveats like this and functionality could be better. Maybe if I knew about status of this app and what's going to happen with it (big changes / only support / deprecation?) I could help a little bit. Thank you. [1] http://code.djangoproject.com/browser/django/trunk/django/contrib/admindocs/views.py#L242 [2] http://code.djangoproject.com/browser/django/trunk/django/db/models/base.py#L253 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: login_required and new class based views
Thank you, I didn't know that! -- Best Regards, Valentin Golev Lead Developer r00, http://r00.ru http://valyagolev.net +7 921 789 0895, avaiable 12:00-18:00 MSK 2010/10/19 Łukasz Rekucki <lreku...@gmail.com>: > On 19 October 2010 21:21, Valentin Golev <m...@valyagolev.net> wrote: >> Thank you! >> >> Does python's super really works the way like in the last option? > Yes, it should call dispatch() from the next class in MRO. So if you > place it at the start, like this: > > class MyView(LoginRequiredMixin, TemplateView): > pass > > It should work as expected. > >> >> -- >> Best Regards, >> Valentin Golev >> Lead Developer >> r00, http://r00.ru >> >> http://valyagolev.net >> +7 921 789 0895, avaiable 12:00-18:00 MSK >> >> >> >> 2010/10/19 Łukasz Rekucki <lreku...@gmail.com>: >>> On 19 October 2010 19:06, Valentin Golev <v.go...@gmail.com> wrote: >>>> Hello, >>>> >>>> I'm trying to start using new class based views from the trunk. >>>> >>>> I need to rewrite a view which is decorated >>>> django.contrib.auth.decorators.login_required. >>>> >>>> How should I go with that? >>> There are couple of options. >>> >>> 1) decorate the final view (for use in urls.py): >>> >>> decorated_view = login_required(MyView.as_view) >>> >>> In this option, you lose the ability to subclass the decorated view. >>> >>> 2) decorate the dispatch method. You need to turn login_required into >>> a method decorator first (Django should probably provide a tool for >>> this). Here[1] is an example how to do this. >>> >>> class MyDecoratedView(MyView): >>> >>> �...@on_method(login_required): >>> def dispatch(self, *args, **kwargs): >>> # do any extra stuff here >>> return super(MyDecoratedView, self).dispatch(*args, **kwargs) >>> >>> 3) Make a class decorator, that does the above, so you could do: >>> >>> @on_dispatch(login_required) >>> class MyDecoratedView(MyView): >>> pass >>> >>>> >>>> I was going to write something like LoginRequiredMixin, but I have no >>>> idea how to do this. I need to run my code before .dispatch(), but I >>>> also have to call the old dispatch, but since Mixin aren't inherited >>>> from View, I can't just override method and use super(). >>> >>> This is option #4. You can just do: >>> >>> class LoginRequiredMixin(object): >>> >>> def dispatch(self, *args, **kwargs): >>> bound_dispatch = super(LoginRequired, self).dispatch >>> return login_required(bound_dispatch)(*args, **kwargs) >>> >>> >>> [1]: http://www.toddreed.name/content/django-view-class/ >>> >>> -- >>> Łukasz Rekucki >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-us...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > > > > -- > Łukasz Rekucki > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: login_required and new class based views
Thank you! Does python's super really works the way like in the last option? -- Best Regards, Valentin Golev Lead Developer r00, http://r00.ru http://valyagolev.net +7 921 789 0895, avaiable 12:00-18:00 MSK 2010/10/19 Łukasz Rekucki <lreku...@gmail.com>: > On 19 October 2010 19:06, Valentin Golev <v.go...@gmail.com> wrote: >> Hello, >> >> I'm trying to start using new class based views from the trunk. >> >> I need to rewrite a view which is decorated >> django.contrib.auth.decorators.login_required. >> >> How should I go with that? > There are couple of options. > > 1) decorate the final view (for use in urls.py): > > decorated_view = login_required(MyView.as_view) > > In this option, you lose the ability to subclass the decorated view. > > 2) decorate the dispatch method. You need to turn login_required into > a method decorator first (Django should probably provide a tool for > this). Here[1] is an example how to do this. > > class MyDecoratedView(MyView): > > �...@on_method(login_required): > def dispatch(self, *args, **kwargs): > # do any extra stuff here > return super(MyDecoratedView, self).dispatch(*args, **kwargs) > > 3) Make a class decorator, that does the above, so you could do: > > @on_dispatch(login_required) > class MyDecoratedView(MyView): > pass > >> >> I was going to write something like LoginRequiredMixin, but I have no >> idea how to do this. I need to run my code before .dispatch(), but I >> also have to call the old dispatch, but since Mixin aren't inherited >> from View, I can't just override method and use super(). > > This is option #4. You can just do: > > class LoginRequiredMixin(object): > > def dispatch(self, *args, **kwargs): > bound_dispatch = super(LoginRequired, self).dispatch > return login_required(bound_dispatch)(*args, **kwargs) > > > [1]: http://www.toddreed.name/content/django-view-class/ > > -- > Łukasz Rekucki > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
login_required and new class based views
Hello, I'm trying to start using new class based views from the trunk. I need to rewrite a view which is decorated django.contrib.auth.decorators.login_required. How should I go with that? I was going to write something like LoginRequiredMixin, but I have no idea how to do this. I need to run my code before .dispatch(), but I also have to call the old dispatch, but since Mixin aren't inherited from View, I can't just override method and use super(). Decorating the whole View class doesn't seem like a good idea, either. Am I missing something? Thank you very much! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django.db.utils.DatabaseError: value too long for type character varying(50)
Hello, I'm trying to deploy my Django application with PostgreSQL. While trying to insert an object to the database, I'm getting the following error: django.db.utils.DatabaseError: value too long for type character varying(50) My application were working fine on SQLite. I guess it has something to do with encoding (my data in in Cyrillic). I thought Django should truncate in on the application level, but it obviously doesn't. What can I do (except for truncating data by myself every time)? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
FormWizard and fields which allow only one validation
Hello! I've been using SuperCaptcha for Django for some time and everything was OK. But one day I was stupid enough and tried to use it with FormWizard. I think it's a bug and I could not invent a workaround for it (except for not using the FormWizard). The problem is, FormWizard validates every form every time. But after the first validation of CaptchaField the captcha become out-of-date, so the second validation fails with ValidationError. It's very simple to reproduce, just create two forms, add a captcha field to the first and create a wizard with these forms. I just thought you want to know. And maybe you know a solution for it. - Valentin Golev - http://valyagolev.net/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
custom locale directory
Hello! I'm developing a project with two different sites, divided by language. Maybe I was terribly wrong, but now my directory structure looks like: /ruapp/settings.py # SITE_ID =1 /ruapp/manage.py /enapp/settings.py # SITE_ID = 2 /enapp/manage.py /common/urls.py /common/ # almost every other file /common/templates/ # templates with {% trans %} /locale/ # with locales ru-ru and en-us, generated by calling makemessages from the root of all this structure How to tell django about the locale? It does not seem like it will find the /locale/ folder by itself -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Filtering manager, customized by user
Hi there! I have a model, smth like this: class Action(models.Model): def can_be_applied(self, user): #whatever return True and I want to override its default Manager. But I don't know how to pass the current user variable to the manager, so I have to do smth like this: [act for act in Action.objects.all() if act.can_be_applied(user)] How do I get rid of it by just overriding the manager? Thanks. - Valentin Golev - http://valyagolev.net/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.