admin properties and short_description
Hi, is there a way how to pass a short_description to a property? I have: @property def extend_types(self): return cjson.decode(self.extend_types_data) #extend_types.short_description = 'Something better' with the code uncommented I get: AttributeError: 'property' object has no attribute 'short_description' -- 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.
LogEntry change messages do not do i18n properly
Hi, today I've noticed that my LogEntry change messages output the name of the field and do not respect when it has verbose_name setup (which is translated). I've had a look at admin.options.construct_change_message(), the line responsible is: change_message.append(_('Changed %s.') % get_text_list(form.changed_data, _('and'))) and form.changed_data contains the field names indeed. I've tried to play with forms API, but the have 'label' for what models call 'verbose_name'. Is this a feature of django or is there an easy way to use the i18nlized names of attributes in admin log messages? Thanks, Robert -- 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.
AdminSplitDateTime ValidationError when using 2 or more forms in a wizard
Hi, I am struggling with using AdminSplitDateTime widget on my form for form.DateTimeField. I've modified custom template so it loads correct admin.js and admin.css files. When I have only one Form, I can click and fill and use submit button and everything is cool. When I have 2+ forms in my wizard, it correctly validate on the page where I am using the widget, then moves to next Form. However after the last page when I click submit, I get ValidationError exception. My broken code is at http://github.com/stereoit/django-datetime-wizard Snippets here: forms.py class FirstForm(forms.Form): '''Second part of the form wizard''' note = forms.CharField(widget=forms.Textarea()) datetime_field = forms.DateTimeField(widget=widgets.AdminSplitDateTime) class SecondForm(forms.Form): '''Second part of the form wizard''' note = forms.CharField(widget=forms.Textarea()) class MyWizard(FormWizard): '''Wizard''' def done(self, request, form_list): for form in form_list: print form.cleaned_data return HttpResponseRedirect('/wizard-done/') def process_step(self, request, form, step): print form.cleaned_data print step urls.py urlpatterns = patterns('', (r'^wizard/$', MyWizard([FirstForm, SecondForm])), (r'^wizard-ok/$', MyWizard([FirstForm])), (r'^wizard-done/$', direct_to_template, {'template':'done.html'}), (r'^admin/', include(admin.site.urls)), (r'^my_admin/jsi18n', 'django.views.i18n.javascript_catalog'), ) Excption: Environment: Request Method: POST Request URL: http://127.0.0.1:8001/wizard/ Django Version: 1.1.1 Python Version: 2.6.4 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'wizardy.formulare'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/pymodules/python2.6/django/contrib/formtools/wizard.py" in __call__ 65. if request.POST.get("hash_%d" % i, '') != self.security_hash(request, form): File "/usr/lib/pymodules/python2.6/django/contrib/formtools/wizard.py" in security_hash 148. return security_hash(request, form) File "/usr/lib/pymodules/python2.6/django/contrib/formtools/utils.py" in security_hash 26. value = bf.field.clean(bf.data) or '' File "/usr/lib/pymodules/python2.6/django/forms/fields.py" in clean 390. raise ValidationError(self.error_messages['invalid']) Exception Type: ValidationError at /wizard/ Exception Value: I've looked into /usr/lib/pymodules/python2.6/django/forms/fields.py in clean, line 390 it looks line (null, null) is passed as a Value. Any hints? -- 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.
validate_generic from PYCON 2007
Hi, while reading http://toys.jacobian.org/presentations/2007/oscon/tutorial/#s67 I see this nice validate_generic(request, formclass), but I am curious how to select proper formclass from the URL request? At the moment I thing of maintaining dictionary of avaliable forms and its corresponding names, is this correct approach? many thanks, Robert -- 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 Comments framework
Hi, I tried to add comments app http://docs.djangoproject.com/en/dev/ref/contrib/comments/, now few things works but Preview sometimes acts as Submit when there are no errors and I have no idea how to override Posted screen to include link (or just redirect) to original page. The documentation is kinda sparse and i had to look into source code to see there are some templates I can override. Any good tutorial on new comments framework? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
change dic text based on select box option
Hello, I'm using 0.96 and now I have working form_for_model with custom callback function that creates select drop down box when form is rendered. Great, but I would like to have a under the select box with different text for each selected option (like a help text). How should I do that? thanks Robert Smol --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: mod_python apache2 path problem
Hi, thanks for quick reply. When I did as suggested I received: EnvironmentError: Could not import settings 'settings' (Is it on sys.path? Does it have syntax errors?): No module named settings < so I also changed the PythonPath to PythonPath "['/srv/code/syslog/'] + sys.path" now I receive: > Traceback (most recent call last): File "/srv/code/python/lib/python2.4/site-packages/mod_python/ importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "/srv/code/python/lib/python2.4/site-packages/mod_python/ importer.py", line 1229, in _process_target result = _execute_target(config, req, object, arg) File "/srv/code/python/lib/python2.4/site-packages/mod_python/ importer.py", line 1128, in _execute_target result = object(arg) File "/srv/code/python/lib/python2.4/site-packages/django/core/ handlers/modpython.py", line 177, in handler return ModPythonHandler()(req) File "/srv/code/python/lib/python2.4/site-packages/django/core/ handlers/modpython.py", line 145, in __call__ self.load_middleware() File "/srv/code/python/lib/python2.4/site-packages/django/core/ handlers/base.py", line 29, in load_middleware mod = __import__(mw_module, {}, {}, ['']) File "/srv/code/python/lib/python2.4/site-packages/django/contrib/ sessions/middleware.py", line 2, in ? from django.contrib.sessions.models import Session File "/srv/code/python/lib/python2.4/site-packages/django/contrib/ sessions/models.py", line 51, in ? class Session(models.Model): File "/srv/code/python/lib/python2.4/site-packages/django/db/models/ base.py", line 30, in __new__ new_class.add_to_class('_meta', Options(attrs.pop('Meta', None))) File "/srv/code/python/lib/python2.4/site-packages/django/db/models/ base.py", line 169, in add_to_class value.contribute_to_class(cls, name) File "/srv/code/python/lib/python2.4/site-packages/django/db/models/ options.py", line 53, in contribute_to_class setattr(self, 'verbose_name_plural', meta_attrs.pop('verbose_name_plural', self.verbose_name + 's')) File "/srv/code/python/lib/python2.4/site-packages/django/utils/ functional.py", line 42, in __wrapper__ res = self.__func(*self.__args, **self.__kw) File "/srv/code/python/lib/python2.4/site-packages/django/utils/ translation/trans_real.py", line 255, in gettext _default = translation(settings.LANGUAGE_CODE) File "/srv/code/python/lib/python2.4/site-packages/django/utils/ translation/trans_real.py", line 184, in translation default_translation = _fetch(settings.LANGUAGE_CODE) File "/srv/code/python/lib/python2.4/site-packages/django/utils/ translation/trans_real.py", line 167, in _fetch app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:]) AttributeError: 'module' object has no attribute 'frontend' < frontend is a folder in the syslog folder created by django-admin.py startapp frontend. I still can't figure out why it works on embedded server and not in apache. Robert On Jul 30, 3:36 pm, Anthony DROGON <[EMAIL PROTECTED]> wrote: > Hi Robert, > > I had quite the same problem, it's been solved by setting > DJANGO_SETTINGS_MODULE to "settings" instead of "syslog.settings" in > . > > My current apache2.conf file sets handler to "python-program" instead of > "mod_python", you can also try it that way. > > Hope this helps, > Anthony. > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
mod_python apache2 path problem
Hi, I'm having problem with mod_python. EnvironmentError: Could not import settings 'syslog.settings' (Is it on sys.path? Does it have syntax errors?): No module named settings I've developed small app for viewing syslog messages and it runs fine with following commands: cd /srv/code/syslog/ export DJANGO_SETTINGS_MODULE=syslog.settings export PYTHONPATH=/srv/code/ /srv/code/python/bin/python manage.py runserver I then tried to follow http://www.djangoproject.com/documentation/modpython/ but I do not understand the concept of mysite and projects. Anyway here is what is in my virtualhost: SetHandler mod_python PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE syslog.settings PythonPath "['/srv/code'] + sys.path" PythonDebug On Additional info: ls /srv/code/syslog/ accounts filters frontend __init__.py __init__.pyc manage.py media settings.py settings.pyc site_media templates urls.py urls.pyc Since this is running on RedHat4 I downloaded and compiled python 2.4.4 with ./configure --prefix=/srv/code/python/ mod_python with: ./configure --with-python=/srv/code/python/bin/python and copied django to cp -r django/ /srv/code/python/lib/python2.4/site-packages/ I can run following just fine: $ export PYTHONPATH=/srv/code/ $ /srv/code/python/bin/python Python 2.4.4 (#1, Jul 30 2007, 11:43:39) [GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from django.core.handlers import modpython >>> from syslog import settings >>> I made sure everything is readable by chmod o+r -R syslog Am I missing something? Complete error listing: MOD_PYTHON ERROR ProcessId: 19772 Interpreter:'syslog.telecom.dhl.com' ServerName: 'syslog.telecom.dhl.com' DocumentRoot: '/srv/www/syslog.telecom.dhl.com/htdocs' URI:'/' Location: '/' Directory: None Filename: '/srv/www/syslog.telecom.dhl.com/htdocs/' PathInfo: '' Phase: 'PythonHandler' Handler:'django.core.handlers.modpython' Traceback (most recent call last): File "/srv/code/python/lib/python2.4/site-packages/mod_python/ importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "/srv/code/python/lib/python2.4/site-packages/mod_python/ importer.py", line 1229, in _process_target result = _execute_target(config, req, object, arg) File "/srv/code/python/lib/python2.4/site-packages/mod_python/ importer.py", line 1128, in _execute_target result = object(arg) File "/srv/code/python/lib/python2.4/site-packages/django/core/ handlers/modpython.py", line 177, in handler return ModPythonHandler()(req) File "/srv/code/python/lib/python2.4/site-packages/django/core/ handlers/modpython.py", line 145, in __call__ self.load_middleware() File "/srv/code/python/lib/python2.4/site-packages/django/core/ handlers/base.py", line 22, in load_middleware for middleware_path in settings.MIDDLEWARE_CLASSES: File "/srv/code/python/lib/python2.4/site-packages/django/conf/ __init__.py", line 28, in __getattr__ self._import_settings() File "/srv/code/python/lib/python2.4/site-packages/django/conf/ __init__.py", line 55, in _import_settings self._target = Settings(settings_module) File "/srv/code/python/lib/python2.4/site-packages/django/conf/ __init__.py", line 83, in __init__ raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) EnvironmentError: Could not import settings 'syslog.settings' (Is it on sys.path? Does it have syntax errors?): No module named settings --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms and models unique=True validation
+1 it works, perfect (I just change the self.cleaned_data into self.clean_data). Now when you showed me the trick I was able to track it in docs as well, unfortunately I'm using 0.96 and http://www.djangoproject.com/documentation/0.96/newforms/ is much different to http://www.djangoproject.com/documentation/newforms/ Is there anything coming into django that would provide validation of unique=True out of the box? Anyway thank you very much On Jul 18, 8:42 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > You want to create a BaseForm to specify in your form_for_model call. > You could do something like: > > from django import newforms as forms > > class MyBaseForm(forms.BaseForm): > def clean_myfield(self): > if > MyModel.objects.filter(myfield=self.cleaned_data['myfield']).count(): > raise forms.ValidationError('some error message') > > MyForm = forms.form_for_model(MyModel, form=MyBaseForm) > > ---- > Nathan Ostgard > > On Jul 18, 7:06 am, stereoit <[EMAIL PROTECTED]> wrote: > > > Hi, > > I have model with field that has attribute unique set to True. I know > > newforms are not able to handle such a validation as this is DB > > related. However I read at newforms doc page that it is possible to > > provide method called clean_() that can do custom validation. > > My problem is that method is supposed to access the data via > > self.cleaned_date and I create form by using form_for_model hence I do > > not know how to write such a method. > > > Can anyone point me to right direction or best practice? Handling this > > at form.save() seem not right to me. > > > My idea was to create custom validation method that would try tu pull > > object from DB with set to same as in > > cleaned_data['fieldname'] and if it exists it would raise > > ValidationError. But I have no clue how to do that at the moment. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
newforms and models unique=True validation
Hi, I have model with field that has attribute unique set to True. I know newforms are not able to handle such a validation as this is DB related. However I read at newforms doc page that it is possible to provide method called clean_() that can do custom validation. My problem is that method is supposed to access the data via self.cleaned_date and I create form by using form_for_model hence I do not know how to write such a method. Can anyone point me to right direction or best practice? Handling this at form.save() seem not right to me. My idea was to create custom validation method that would try tu pull object from DB with set to same as in cleaned_data['fieldname'] and if it exists it would raise ValidationError. But I have no clue how to do that at the moment. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
admin utilites in front end view
Hi, I'm trying to provide end users with a view into DB (syslog viewer), well actually I'm trying to imitate Admin part. I have pagination working, but is there a way how to use the filter bar and search form from admin part (I love them) in fronted view? I've searched groups and posts seems to be talking about change list and new version of admin part, but posts were from 2005-6. Any hints appreciated. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---