define "_default_manager" and the admin-interface
Hello, At the moment I am reading the "Practical Django Projects" - Book written by James Bennett. On page 120 there is a admonition about using Default Managers. Above this paragraph there is the explanation about the Default Manager und Entry.objects.all() and Entry.live.all(). It seems clear to define the live-Manager first, so it's the Default Manager. But I noticed that the admin interface also uses this Default Manager. If I mark an Entry as HIDDEN or DRAFT I have no possibility to take it LIVE with the admin interface, because the live-Default Manager don't return this type of entries What do you think? What's good practice in relation to the Default Manager? ~ Bernd --~--~-~--~~~---~--~~ 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: to_field in admin
thanks for your help. the patch works great. cheers. chr --~--~-~--~~~---~--~~ 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: imports
On Thu, 2008-08-28 at 21:41 -0700, lingrlongr wrote: [...] > Has something changed? Nothing popped out at me on the Backwards- > incompatible changes. Nothing should have changed that caused this if your code was correct earlier. The best way to work out where the problem is simple to start bisecting the subversion checkouts until you find the problem case. You know that the current checkout, r8693 is bad. So, suppose r8600 is good. Then try r8647 (halfway in between). If that's good, move forwards halfway again, otherwise, move back halfway. Keep repeating and you'll eventually hit the revision that caused the problem. Even if r8437 was the last good revision (256 revisions ago), this will take a maximum of 8 tests to find the version that changed things, so it's quite efficient. Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
imports
I had all my imports for my apps relative to the app, not the project. Since my last SVN checkout this evening, everything on the site I'm working on is broken. I would get an error stating (app after app) that the module app_name.models (etc) could not be found. The import syntax was: from app_name.models import MyModel So when I made them... from project_name.app_name.models import MyModel The error would clear and the next import with that style would fail. So, I saw some posts relating to gettext this evening, but those were related to "from xxx.xxx import *" style imports. So I don't think that's related... Another note... this is only when using Apache/mod_python. If I run the manage.py runserver from my webhost, the site works with the original imports I had. Has something changed? Nothing popped out at me on the Backwards- incompatible changes. Keith --~--~-~--~~~---~--~~ 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: Django new comments framework error
Did you delete the .pyc files from the django source? Another approach would be to go into /django/contrib/ and delete the comments directory, then do an 'svn up' to restore it. Then you'll be sure to get a fresh copy. That is what worked for me. But if you haven't used the comment system before then there shouldn't even be any pyc files in there, so I don't know what is going on. On Aug 28, 2:57 am, Mark <[EMAIL PROTECTED]> wrote: > Hi, > > Updated to 8613 with the release of Django 1.0 Beta 2 and saw the > addition of commenting framework - tried to add it and am getting a > similar error to above. > > On Aug 27, 3:54 pm, Slavus <[EMAIL PROTECTED]> wrote: > > > Here is the solution: > > You'll get this if you still have stale pyc files left over from the > > old comment system. Delete 'em and your code will work. > > I tried this (even though I did not use the old commenting system). > > Here is the exception information... > > Environment: > > Request Method: GET > Request URL:http://localhost/apps/buildboard/builddetails/80/ > Django Version: 1.0-beta_1-SVN-unknown > Python Version: 2.5.1 > Installed Applications: > ['django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'django.contrib.admin', > 'django_apps.buildboard', > 'django_xmlrpc', > 'django.contrib.comments'] > Installed Middleware: > ('django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.middleware.doc.XViewMiddleware') > > Template error: > In template c:\_tools\python251\lib\site-packages\django\contrib > \comments\templates\comments\form.html, error at line 2 > Caught an exception while rendering: Reverse for ' post_comment at 0x0158BEF0>' not found. > 1 : {% load comments %} > > 2 : > > 3 : {% for field in form %} > > 4 : {% if field.is_hidden %} > > 5 : {{ field }} > > 6 : {% else %} > > 7 : > 8 : {% if field.errors %} class="error"{% endif %} > > 9 : {% ifequal field.name "honeypot" %} > style="display:none;"{% endifequal %}> > > 10 : {% if field.errors %}{{ field.errors }}{% endif %} > > 11 : {{ field.label_tag }} {{ field }} > > 12 : > > Traceback: > File "c:\_tools\python251\lib\site-packages\django\core\handlers > \base.py" in get_response > 86. response = callback(request, *callback_args, > **callback_kwargs) > File "c:\_tools\python251\lib\site-packages\django\contrib\auth > \decorators.py" in __call__ > 67. return self.view_func(request, *args, **kwargs) > File "c:\_projects\django_apps\..\django_apps\buildboard\views.py" in > build_details > 309. print t.render(c) > File "c:\_tools\python251\lib\site-packages\django\template > \__init__.py" in render > 176. return self.nodelist.render(context) > File "c:\_tools\python251\lib\site-packages\django\template > \__init__.py" in render > 756. bits.append(self.render_node(node, context)) > File "c:\_tools\python251\lib\site-packages\django\template\debug.py" > in render_node > 71. result = node.render(context) > File "c:\_tools\python251\lib\site-packages\django\contrib\comments > \templatetags\comments.py" in render > 158. formstr = render_to_string(template_search_list, > {"form" : self.get_form(context)}, context) > File "c:\_tools\python251\lib\site-packages\django\template\loader.py" > in render_to_string > 107. return t.render(context_instance) > File "c:\_tools\python251\lib\site-packages\django\template > \__init__.py" in render > 176. return self.nodelist.render(context) > File "c:\_tools\python251\lib\site-packages\django\template > \__init__.py" in render > 756. bits.append(self.render_node(node, context)) > File "c:\_tools\python251\lib\site-packages\django\template\debug.py" > in render_node > 81. raise wrapped > > Exception Type: TemplateSyntaxError at /apps/buildboard/builddetails/ > 80/ > Exception Value: Caught an exception while rendering: Reverse for > '' not found. > > Original Traceback (most recent call last): > File "c:\_tools\python251\lib\site-packages\django\template > \debug.py", line 71, in render_node > result = node.render(context) > File "c:\_tools\python251\lib\site-packages\django\template > \__init__.py", line 876, in render > return func(*resolved_vars) > File "c:\_tools\python251\lib\site-packages\django\contrib\comments > \templatetags\comments.py", line 245, in comment_form_target > return comments.get_form_target() > File "c:\_tools\python251\lib\site-packages\django\contrib\comments > \__init__.py", line 50, in get_form_target > return >
Re: Issues for run "runserver" command.
I have installed python2.5 on RH3L-AS4 successfully. And already installed Django1.0-beta2 successfully. After i create a project test, when i use python manage.py runserver to start the dev server, the log shows error during the starting process: File "manage.py", line 11, in execute_manager(settings) File "/usr/workspace/python25/lib/python2.5/site-packages/django/ core/management/__init__.py", line 334, in execute_manager utility.execute() File "/usr/workspace/python25/lib/python2.5/site-packages/django/ core/management/__init__.py", line 295, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/workspace/python25/lib/python2.5/site-packages/django/ core/management/base.py", line 77, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/workspace/python25/lib/python2.5/site-packages/django/ core/management/base.py", line 87, in execute translation.activate('en-us') File "/usr/workspace/python25/lib/python2.5/site-packages/django/ utils/translation/__init__.py", line 73, in activate return real_activate(language) File "/usr/workspace/python25/lib/python2.5/site-packages/django/ utils/translation/__init__.py", line 43, in delayed_loader return g['real_%s' % caller](*args, **kwargs) File "/usr/workspace/python25/lib/python2.5/site-packages/django/ utils/translation/trans_real.py", line 209, in activate _active[currentThread()] = translation(language) File "/usr/workspace/python25/lib/python2.5/site-packages/django/ utils/translation/trans_real.py", line 198, in translation default_translation = _fetch(settings.LANGUAGE_CODE) File "/usr/workspace/python25/lib/python2.5/site-packages/django/ utils/translation/trans_real.py", line 181, in _fetch app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:]) File "/usr/workspace/python25/lib/python2.5/site-packages/django/ contrib/admin/__init__.py", line 1, in from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL File "/usr/workspace/python25/lib/python2.5/site-packages/django/ contrib/admin/options.py", line 5, in from django.contrib.contenttypes.models import ContentType File "/usr/workspace/python25/lib/python2.5/site-packages/django/ contrib/contenttypes/models.py", line 1, in from django.db import models File "/usr/workspace/python25/lib/python2.5/site-packages/django/db/ __init__.py", line 16, in backend = __import__('%s%s.base' % (_import_path, settings.DATABASE_ENGINE), {}, {}, ['']) File "/usr/workspace/python25/lib/python2.5/site-packages/django/db/ backends/sqlite3/base.py", line 26, in raise ImproperlyConfigured, "Error loading %s module: %s" % (module, e) django.core.exceptions.ImproperlyConfigured: Error loading sqlite3 module: No module named pysqlite2 But in /usr/workspace/python25/lib/python2.5/site-packages/django/db/ backends/sqlite3/base.py, there says "Python 2.5 and later use the sqlite3 module in the standard library." So, i have no idea about this issue. Does anyone have expirence on this? I'll be very appreciate your help. BTW, the server has a python2.3.4 already installed, i use python2.5 command file directly to run the server. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Issues for run "runserver" command.
I have installed python2.5 on RH3L-AS4 --~--~-~--~~~---~--~~ 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: Modify settings.py file through admin?
On Thu, 2008-08-28 at 19:47 -0700, Dana wrote: > Hey All, > > Been trying to modify the settings.py file through admin using > something along the lines of: > > settings.py file: > -- > from config.models import SiteSetting > > > config= SiteSetting.objects.get(pk=1) > TIME_ZONE = config.timezone > -- Your suspicions are correct you can't do that. Anything that requires using Django itself cannot be done in the settings file. The reason is because almost anything in Django requires access to the settings file for things like the list of available languages, the database engine/name/user to use, etc. If you try to do anything inside settings that uses Django and hence requires settings, there's a chicken-and-egg problem. Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Modify settings.py file through admin?
Hey All, Been trying to modify the settings.py file through admin using something along the lines of: settings.py file: -- from config.models import SiteSetting config= SiteSetting.objects.get(pk=1) TIME_ZONE = config.timezone -- 'config' is the app I created to control the settings values (for example, timezone). This is failing and trowing a 'cannot import gettext' error on the development server, which leads me to believe you cannot modify the settings.py file? Or am I doing something wrong? I know my model is correct and if I comment out my setting.py code above, it syncdbs fine, runs in admin and is editable. So I guess my question to you all is how can I modify the settings.py file, if at all? One other related question, how can I make a model that only has one entity so i don't need to run: SiteSetting.objects.get(pk=1) but can run SiteSetting.timezone instead? Is it possible? Is there a better way around this? Thanks for any help you can offer! Cheers, Dana --~--~-~--~~~---~--~~ 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: cannot import name ugettext_lazy
> No, it wasn't. I'm really not making this up: ugettext_lazy() has been > in trunk since July 4 last year! Bizarre. Okay. I will take your word for it. I am fairly new to Django so I am not excusing the fact that it might simply be ignorance on my part how everything works and the location of the functions. I will download the latest from SVN, try again, and let you know how I make out. Thanks again for your information. Wayne --~--~-~--~~~---~--~~ 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: cannot import name ugettext_lazy
On Thu, 2008-08-28 at 19:20 -0700, Wayne Dyck wrote: > > Well, it's int django/utils/translation/__init__.py. Specifically: > > > > http://code.djangoproject.com/browser/django/trunk/django/utils/trans... > > It looks like it was just checked in a little while ago. I will > download the latest from SVN and try that. No, it wasn't. I'm really not making this up: ugettext_lazy() has been in trunk since July 4 last year! It was added to __all__ a few hours ago, but that is irrelevant to the question you asked, as I indicated in my reply to Karen. If you're actually doing "from django.utils.translation import *" and then trying to use ugettext_lazy, that would be a different story, but that wasn't what you said you were doing. Regards, Malcolm --~--~-~--~~~---~--~~ 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: cannot import name ugettext_lazy
> Well, it's int django/utils/translation/__init__.py. Specifically: > > http://code.djangoproject.com/browser/django/trunk/django/utils/trans... It looks like it was just checked in a little while ago. I will download the latest from SVN and try that. Thanks. I appreciate it. Wayne --~--~-~--~~~---~--~~ 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: 'adminapplist' is not a valid tag library
Yeah, apparently I needed the admin templates in a previous version. I renamed templates/admin and it's all good now. Thanks! On Aug 28, 8:10 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Thu, Aug 28, 2008 at 8:56 PM, XtraGreen <[EMAIL PROTECTED]> wrote: > > > I'm upgrading a Django site from 0.96 to the 1.0 beta (django-trunk > > svn as of tonight) and it's mostly going smoothly except the built in > > Django admin is giving me issues. > > > I think I've got everything setup for the new admin code, but when I > > try to execute the main admin page I get the following error: > > > TemplateSyntaxError: 'adminapplist' is not a valid tag library: Could > > not load template library from django.templatetags.adminapplist, No > > module named adminapplist > > > Indeed, adminapplist.py doesn't exist in django/templatetags so what's > > the catch? Is this a bug in the distribution or am I doing something > > wrong? > > Do you have a customized index.html admin template based on the old admin > index.html? That's where adminapplist used to be loaded from. It is no > longer referenced by the current django/contrib/admin/templates/index.html > file. > > Karen --~--~-~--~~~---~--~~ 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: Inconsistencies/Bug in ModelForm
Yes, Malcolm. You understood it correctly. I'll probably just add a quick MY_CHOICES_2 tuple that has these "-" values until I see what the plan is. On Aug 28, 9:40 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-08-28 at 21:32 -0400, Steve Holden wrote: > > lingrlongr wrote: > > > Submitted ticket #8663 for the following: > > > > When a ModelForm? is used to display a form for a Model, the fields > > > defined with a choices option insert a "---" value for the first > > > option when the form is rendered. If you override a field and manually > > > specify the choices for a Select widget, this "---" does not > > > appear as the first choice. > > > I believe this is by design, to allow you the option of forcing the user > > to select a specific value. > > I understood the original poster's question to be about the difference > between the auto-generated version and the version when he manually > specified the field. My first reaction is that he's right and it should > be the same in both cases (with the "" string), but I need to think > about it a bit more. > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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: cannot import name ugettext_lazy
On Thu, 2008-08-28 at 18:37 -0700, Wayne Dyck wrote: > > I think the original poster's tarball of Django is broken. At least the > > 1.0-alpha version is. The 0.96 releases never had ugettext_lazy(). > > So I should be seeing it at this location django.utils.translation in > the latest SVN beta? I browsed the code today on the website and > didn't see it in there. Well, it's int django/utils/translation/__init__.py. Specifically: http://code.djangoproject.com/browser/django/trunk/django/utils/translation/__init__.py#L70 Regards, Malcolm --~--~-~--~~~---~--~~ 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: Inconsistencies/Bug in ModelForm
On Thu, 2008-08-28 at 21:32 -0400, Steve Holden wrote: > lingrlongr wrote: > > Submitted ticket #8663 for the following: > > > > When a ModelForm? is used to display a form for a Model, the fields > > defined with a choices option insert a "---" value for the first > > option when the form is rendered. If you override a field and manually > > specify the choices for a Select widget, this "---" does not > > appear as the first choice. > > > I believe this is by design, to allow you the option of forcing the user > to select a specific value. I understood the original poster's question to be about the difference between the auto-generated version and the version when he manually specified the field. My first reaction is that he's right and it should be the same in both cases (with the "" string), but I need to think about it a bit more. Regards, Malcolm --~--~-~--~~~---~--~~ 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: cannot import name ugettext_lazy
> I think the original poster's tarball of Django is broken. At least the > 1.0-alpha version is. The 0.96 releases never had ugettext_lazy(). So I should be seeing it at this location django.utils.translation in the latest SVN beta? I browsed the code today on the website and didn't see it in there. Is this something simple that I am missing? Wayne --~--~-~--~~~---~--~~ 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: Inconsistencies/Bug in ModelForm
lingrlongr wrote: > Submitted ticket #8663 for the following: > > When a ModelForm? is used to display a form for a Model, the fields > defined with a choices option insert a "---" value for the first > option when the form is rendered. If you override a field and manually > specify the choices for a Select widget, this "---" does not > appear as the first choice. > I believe this is by design, to allow you the option of forcing the user to select a specific value. > # models.py > from django.db import models > > MY_CHOICES = ( > (0, 'Zero'), > (1, 'One'), > ) > So wouldn't it be possible to put another choice, {"", "") at the top of your list? [...] regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ --~--~-~--~~~---~--~~ 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: cannot import name ugettext_lazy
On Thu, 2008-08-28 at 21:18 -0400, Karen Tracey wrote: [...] > > Make sure you have an SVN checkout at revision 8680 or higher. This: > > http://code.djangoproject.com/ticket/8654 > > looks like it could be responsible for what you are reporting, and the > fix was only checked in about five hours ago. No, that's unrelated. The __all__ variable is only relevant for the "from foo import *" style of imports. When importing by name, it looks directly in the module. I think the original poster's tarball of Django is broken. At least the 1.0-alpha version is. The 0.96 releases never had ugettext_lazy(). The function has been in trunk since July 4, 2007 (when the unicode branch was merged in [5609]). If ugettext_lazy() was made unavailable, it would take about 15 seconds for the bugs to be reported. It's used all over the place, even inside Django. Regards, Malcolm > --~--~-~--~~~---~--~~ 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: cannot import name ugettext_lazy
On Thu, Aug 28, 2008 at 9:10 PM, Wayne Dyck <[EMAIL PROTECTED]> wrote: > > A couple of applications I have tried to install fail trying to import > ugettext_lazy. Specifically the import line is: > > django.utils.translation import ugettext_lazy as _ > > I have seen a number of posts that suggest getting the latest source > from SVN. I have Django version 96.2 and I have downloaded the latest > 1.0 alpha (or something close to that) from SVN. The ugettext_lazy is > missing from both. > > Any help or suggestions on what I have missed would be appreciated. > > Make sure you have an SVN checkout at revision 8680 or higher. This: http://code.djangoproject.com/ticket/8654 looks like it could be responsible for what you are reporting, and the fix was only checked in about five hours ago. Karen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
cannot import name ugettext_lazy
A couple of applications I have tried to install fail trying to import ugettext_lazy. Specifically the import line is: django.utils.translation import ugettext_lazy as _ I have seen a number of posts that suggest getting the latest source from SVN. I have Django version 96.2 and I have downloaded the latest 1.0 alpha (or something close to that) from SVN. The ugettext_lazy is missing from both. Any help or suggestions on what I have missed would be appreciated. Thanks. Wayne --~--~-~--~~~---~--~~ 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: 'adminapplist' is not a valid tag library
On Thu, Aug 28, 2008 at 8:56 PM, XtraGreen <[EMAIL PROTECTED]> wrote: > > I'm upgrading a Django site from 0.96 to the 1.0 beta (django-trunk > svn as of tonight) and it's mostly going smoothly except the built in > Django admin is giving me issues. > > I think I've got everything setup for the new admin code, but when I > try to execute the main admin page I get the following error: > > TemplateSyntaxError: 'adminapplist' is not a valid tag library: Could > not load template library from django.templatetags.adminapplist, No > module named adminapplist > > Indeed, adminapplist.py doesn't exist in django/templatetags so what's > the catch? Is this a bug in the distribution or am I doing something > wrong? > Do you have a customized index.html admin template based on the old admin index.html? That's where adminapplist used to be loaded from. It is no longer referenced by the current django/contrib/admin/templates/index.html file. Karen --~--~-~--~~~---~--~~ 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: Odd error when executing "runserver"
On Aug 29, 6:43 am, Huuuze <[EMAIL PROTECTED]> wrote: > I recently installed PostgreSQL 8.3.3 and psycopg 2 (latest from > SVN). When I attempt to start Django, I receive this error: > > File "/Library/Python/2.5/site-packages/django/db/backends/ > postgresql_psycopg2/base.py", line 20, in > raise ImproperlyConfigured("Error loading psycopg2 module: %s" % > e) > django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 > module: dlopen(/Library/Python/2.5/site-packages/psycopg2/_psycopg.so, > 2): Library not loaded: /Users/buildfarm/pginstaller/server/staging/ > osx/lib/libpq.5.dylib > Referenced from: /Library/Python/2.5/site-packages/psycopg2/ > _psycopg.so > Reason: image not found > > Is this an issue with Django, psycopg, or both? The error 'Image not found' on MacOS X normally means that the .so doesn't contain the object code for the architecture that the process it is being loaded into requires. This is normally an issue for mod_python and mod_wsgi on Leopard where the operating system supplied Apache is compiled with 64 bit support and so runs as 64 bit on latest hardware. What happens is that default compilation options for Python packages only builds them as 32 bit and thus the 64 bit architecture wouldn't be present in C extension modules. Since 'python' executable is not fully fat and only runs as 32 bit even if have 64 bit CPU, that you are getting this error when using "runserver" would indicate that you have installed pyscopg binaries from PowerPC, or if you compiled it yourself, that you have set it up to be 64 bit in mistaken belief that since you have 64 bit CPU that you would want to. You can find further details on these architecture issues at: http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX What you need to do is check build scripts for psycopg and ensure that it doesn't only have '-arch x86_64' as option, when it probably also needs to list at least '-arch i386'. Graham --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Inconsistencies/Bug in ModelForm
Submitted ticket #8663 for the following: When a ModelForm? is used to display a form for a Model, the fields defined with a choices option insert a "---" value for the first option when the form is rendered. If you override a field and manually specify the choices for a Select widget, this "---" does not appear as the first choice. # models.py from django.db import models MY_CHOICES = ( (0, 'Zero'), (1, 'One'), ) class MyModel(models.Model): my_field = models.IntegerField(choices=MY_CHOICES) # forms.py from django import forms from myapp.models import MyModel, MY_CHOICES class MyModelForm(forms.ModelForm): #my_field = forms.IntegerField(widget=forms.Select(choices=MY_CHOICES)) class Meta: model = MyModel View the HTML for the form with my_field commented out: >>> from myapp.forms import MyModelForm >>> f = MyModelForm() >>> print f My field: - Zero One Now uncomment my_field in MyModelForm?: >>> from myapp.forms import MyModelForm >>> f = MyModelForm() >>> print f My field: Zero One This value doesn't appear in the 2nd case: - SVN-8643 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
'adminapplist' is not a valid tag library
I'm upgrading a Django site from 0.96 to the 1.0 beta (django-trunk svn as of tonight) and it's mostly going smoothly except the built in Django admin is giving me issues. I think I've got everything setup for the new admin code, but when I try to execute the main admin page I get the following error: TemplateSyntaxError: 'adminapplist' is not a valid tag library: Could not load template library from django.templatetags.adminapplist, No module named adminapplist Indeed, adminapplist.py doesn't exist in django/templatetags so what's the catch? Is this a bug in the distribution or am I doing something wrong? --~--~-~--~~~---~--~~ 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: Odd error when executing "runserver"
Did you ldconfig? Did you add the library to your LD_CONFIG? On Thu, Aug 28, 2008 at 1:53 PM, Malcolm Tredinnick < [EMAIL PROTECTED]> wrote: > > > On Thu, 2008-08-28 at 13:43 -0700, Huuuze wrote: > > I recently installed PostgreSQL 8.3.3 and psycopg 2 (latest from > > SVN). When I attempt to start Django, I receive this error: > > > > File "/Library/Python/2.5/site-packages/django/db/backends/ > > postgresql_psycopg2/base.py", line 20, in > > raise ImproperlyConfigured("Error loading psycopg2 module: %s" % > > e) > > django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 > > module: dlopen(/Library/Python/2.5/site-packages/psycopg2/_psycopg.so, > > 2): Library not loaded: /Users/buildfarm/pginstaller/server/staging/ > > osx/lib/libpq.5.dylib > > Referenced from: /Library/Python/2.5/site-packages/psycopg2/ > > _psycopg.so > > Reason: image not found > > > > Is this an issue with Django, psycopg, or both? > > Looks like a problem with your psycopg2 package not being properly > installed, although Im not sure what the exact error message implies, > not being an OS X users (which seems to be the system you're using). > > Regards, > Malcolm > > > > > > -- http://www.goldwatches.com/ --~--~-~--~~~---~--~~ 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: Newbie Question - Regex Field to deal with Feet/Inches
bkev, GeoDjango has measurement objects: http://geodjango.org/docs/measure.html It does conversions (supports feet, inches, yards, miles, among others) and lists of distance instances are sortable. It's loosely coupled, so regular Django projects may use it without installing any of the GeoDjango prerequisites. -Justin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Django files documentation not up-to-date?
Hi, http://www.djangoproject.com/documentation/files/, section `The File Object' states that after opening a file and passing it to File from django.core.files, I should be able to use the File attributes like size, url, etc. I'm trying to do something similar: >>> f = open('image.jpg', 'r') >>> f >>> from django.core.files import File >>> File(f) >>> File(f).url Traceback (most recent call last): File "", line 1, in AttributeError: 'File' object has no attribute 'url' 1. Investigating django/core/files/base.py shows that the File class does not provide aforementioned attributes, but maybe I am completely missing something? (django svn-8684) 2. Is there another way to create a File object without opening the file first? I just need the name, path and url in a template, but I don't want to store these things in an ImageField, instead just glob it from the directory. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Using http header information in settings.py
I would like a way to to adjust settings based on information in the http header. I've seen a similar question asked before, but I don't need all the django request object, just the http header information. More specifically, user_agent, http_host, and path_info. Here are two examples of the sort of things I would like to do: # use iphone template if appropriate if http_header['USER_AGENT'].find('iphone'): TEMPLATE_DIRS = ( os.path.join(cur_dir_path, 'template_sets/' + 'iphone'), # set SITE_ID for MyOtherDomain.com if http_header["HTTP_HOST"].find('myotherdomain.com'): SITE_ID = 2 Does anyone know if this can be done? Thanks, Greg --~--~-~--~~~---~--~~ 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: Exceptions in FileUploadHandlers
On Thu, Aug 28, 2008 at 5:14 PM, mwebs <[EMAIL PROTECTED]> wrote: > > I wrote a custom FileUploadHandler to process uploaded data on the > fly. > My problem is that there are no exceptions raised. > > No matter if I am referencing a variable before I assign it, or if I > do something like raise Exception(). The server seems to get stuck. > The Exception does not bubble to the surface. > > For me it looks like a bug?! > Any experiences or ideas? otherwise I will open a ticket. > Hmm, I actually saw that behavior yesterday when I (unintentionally) uploaded to a full disk. I thought the write was hanging but actually it is generating an exception. I've expanded the scope of the ticket I opened yesterday reporting this: http://code.djangoproject.com/ticket/8622 Karen --~--~-~--~~~---~--~~ 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: Core keyword error
Thanks Malcolm and Rajesh! Expected I had missed something. Should have noted that 1st line Googling 'django core arguments' instead of 'django core keyword' got me there. Thanks again, Rob On Aug 28, 2008, at 12:30 PM, Malcolm Tredinnick wrote: > On Thu, 2008-08-28 at 12:24 -0700, Rob Goedman wrote: > [..] >> Until beta-1 no problems. Any hints? > > It was removed as part of r8616. It hasn't actually been needed since > newforms-admin landed, but was tied to the manipulator code that was > removed in the above changeset. > > Regards, > Malcolm On Aug 28, 2008, at 12:35 PM, Rajesh Dhawan wrote: > > Hi Rob, > > On Aug 28, 3:24 pm, Rob Goedman <[EMAIL PROTECTED]> wrote: >> Hi, >> >> Since moving to beta-2 I get: >> >> Robs-Intel:mcp rob$ ./manage.py runserver >> Validating models... >> Unhandled exception in thread started by > 0x7a8470> >> Traceback (most recent call last): >>File "/Library/Python/2.5/site-packages/django/core/management/ >> commands/runserver.py", line 47, in inner_run >> self.validate(display_num_errors=True) >>File "/Library/Python/2.5/site-packages/django/core/management/ >> base.py", line 122, in validate >> num_errors = get_validation_errors(s, app) >>File "/Library/Python/2.5/site-packages/django/core/management/ >> validation.py", line 28, in get_validation_errors >> for (app_name, error) in get_app_errors().items(): >>File "/Library/Python/2.5/site-packages/django/db/models/ >> loading.py", line 128, in get_app_errors >> self._populate() >>File "/Library/Python/2.5/site-packages/django/db/models/ >> loading.py", line 57, in _populate >> self.load_app(app_name, True) >>File "/Library/Python/2.5/site-packages/django/db/models/ >> loading.py", line 72, in load_app >> mod = __import__(app_name, {}, {}, ['models']) >>File "./Descriptors/models.py", line 27, in >> class AEDescriptor(models.Model): >>File "./Descriptors/models.py", line 31, in AEDescriptor >> code = models.PositiveSmallIntegerField(core=True) >> TypeError: __init__() got an unexpected keyword argument 'core' >> >> It's the 1st app that contains core=True in models.py: >> >> class AEDescriptor(models.Model): >> """ The Descriptor class for alarm/event/system message >> descriptor >> instances. >> Table is loaded from ./mcp/Descriptors/sql/ >> descriptor.sql""" >> >> code = models.PositiveSmallIntegerField(core=True) >> descriptor = models.CharField(max_length=60, core=True) >> >> def __str__(self): >> return self.descriptor >> >> class Meta: >> verbose_name_plural = 'Alarms and events descriptors' >> db_table='alarm_and_event_descriptors' >> >> Until beta-1 no problems. Any hints? >> >> I've checked the incompatible backward changes page and searched the >> archives but was not able to find anything. > > Actually, it's kind of included in this entry: > http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Removedoldformsvalidatorsandrelatedcode > > But you're right that it doesn't explicitly spell out that you will > need to remove the core option from all your model fields for model > validation to succeed. > >> I continue to be impressed by how smooth the migration/tracking svn >> has been using that page! > > Yep. > > -Rajesh D > > --~--~-~--~~~---~--~~ 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: HowTo: Django view as a class
I would be interested to try this in the context of a whole simple app, if you ever publish such a thing. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Exceptions in FileUploadHandlers
I wrote a custom FileUploadHandler to process uploaded data on the fly. My problem is that there are no exceptions raised. No matter if I am referencing a variable before I assign it, or if I do something like raise Exception(). The server seems to get stuck. The Exception does not bubble to the surface. For me it looks like a bug?! Any experiences or ideas? otherwise I will open a ticket. Thanks,Toni --~--~-~--~~~---~--~~ 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: Odd error when executing "runserver"
On Thu, 2008-08-28 at 13:43 -0700, Huuuze wrote: > I recently installed PostgreSQL 8.3.3 and psycopg 2 (latest from > SVN). When I attempt to start Django, I receive this error: > > File "/Library/Python/2.5/site-packages/django/db/backends/ > postgresql_psycopg2/base.py", line 20, in > raise ImproperlyConfigured("Error loading psycopg2 module: %s" % > e) > django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 > module: dlopen(/Library/Python/2.5/site-packages/psycopg2/_psycopg.so, > 2): Library not loaded: /Users/buildfarm/pginstaller/server/staging/ > osx/lib/libpq.5.dylib > Referenced from: /Library/Python/2.5/site-packages/psycopg2/ > _psycopg.so > Reason: image not found > > Is this an issue with Django, psycopg, or both? Looks like a problem with your psycopg2 package not being properly installed, although Im not sure what the exact error message implies, not being an OS X users (which seems to be the system you're using). Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Odd error when executing "runserver"
I recently installed PostgreSQL 8.3.3 and psycopg 2 (latest from SVN). When I attempt to start Django, I receive this error: File "/Library/Python/2.5/site-packages/django/db/backends/ postgresql_psycopg2/base.py", line 20, in raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Library/Python/2.5/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: /Users/buildfarm/pginstaller/server/staging/ osx/lib/libpq.5.dylib Referenced from: /Library/Python/2.5/site-packages/psycopg2/ _psycopg.so Reason: image not found Is this an issue with Django, psycopg, or both? --~--~-~--~~~---~--~~ 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: Newbie Question - Regex Field to deal with Feet/Inches
Ronny, This is fabulous...thank you so very much. If you don't mind me asking, can you give me an example of how you implemented this method in your Class? In my case, I've defined the field as a DecimalField type, but that brings up an error. Did you define some sort of custom save method around that? Thank you; I really appreciate it. bkev On Aug 27, 2:32 am, "Ronny Haryanto" <[EMAIL PROTECTED]> wrote: > On Wed, Aug 27, 2008 at 3:13 AM, bkev <[EMAIL PROTECTED]> wrote: > > I'm working on a site that has several imperial measurements (feet and > > inches) and I'd like to implement a field in my model that uses a > > regular expression like: > > ^(\d{1,5})\'((\s?)(-?)(\s?)([0-9]|(1[0-1]))\")?$ > > to parse off the feet and inches and save them in a sortable manner > > (I'm guessing the best way would be to convert them and save them as a > > decimal number, but the list and admin display needs to in x'-y" > > format. Anyone have any ideas as to how I might accomplish that? (or > > where I should look for more information)? > > I use the following method in one of my projects: > > def feetinch_to_cm(length): > """convert US style (feet-inch) length to metric (cm)""" > if length == u'' or length is None: > return None > m = re.match(r'(?P\d+)[\'`]( > *(?P\d+)(?P.)?("|\'\'))?', length) > if m is None: > raise Exception("unable to parse length: %s" % length,) > feet = int(m.group('feet')) > inch = int(m.group('inch') or 0) > half = int(m.group('half') == u'\xbd') > return (30.48 * feet) + (2.54 * inch) + (1.27 * half) > > I save the length in centimeters in database, then I can reformat it > as needed in the template or admin using a custom filter. > > Ronny --~--~-~--~~~---~--~~ 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: Is there a way to store Django tables in another schema
Thanks. --~--~-~--~~~---~--~~ 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: Newbie Question - Regex Field to deal with Feet/Inches
Ronny, This is fabulous...thank you so very much. If you don't mind me asking, can you give me an example of how you implemented this method in your Class? In my case, I've defined the field as a DecimalField type, but that brings up an error. Did you define some sort of custom save method around that? Thank you; I really appreciate it. bkev On Aug 27, 2:32 am, "Ronny Haryanto" <[EMAIL PROTECTED]> wrote: > On Wed, Aug 27, 2008 at 3:13 AM, bkev <[EMAIL PROTECTED]> wrote: > > I'm working on a site that has several imperial measurements (feet and > > inches) and I'd like to implement a field in my model that uses a > > regular expression like: > > ^(\d{1,5})\'((\s?)(-?)(\s?)([0-9]|(1[0-1]))\")?$ > > to parse off the feet and inches and save them in a sortable manner > > (I'm guessing the best way would be to convert them and save them as a > > decimal number, but the list and admin display needs to in x'-y" > > format. Anyone have any ideas as to how I might accomplish that? (or > > where I should look for more information)? > > I use the following method in one of my projects: > > def feetinch_to_cm(length): > """convert US style (feet-inch) length to metric (cm)""" > if length == u'' or length is None: > return None > m = re.match(r'(?P\d+)[\'`]( > *(?P\d+)(?P.)?("|\'\'))?', length) > if m is None: > raise Exception("unable to parse length: %s" % length,) > feet = int(m.group('feet')) > inch = int(m.group('inch') or 0) > half = int(m.group('half') == u'\xbd') > return (30.48 * feet) + (2.54 * inch) + (1.27 * half) > > I save the length in centimeters in database, then I can reformat it > as needed in the template or admin using a custom filter. > > Ronny --~--~-~--~~~---~--~~ 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: Newbie Question - Regex Field to deal with Feet/Inches
Ronny, This is fabulous...thank you so very much. If you don't mind me asking, can you give me an example of how you implemented this method in your Class? In my case, I've defined the field as a DecimalField type, but that brings up an error. Did you define some sort of custom save method around that? Thank you; I really appreciate it. bkev On Aug 27, 2:32 am, "Ronny Haryanto" <[EMAIL PROTECTED]> wrote: > On Wed, Aug 27, 2008 at 3:13 AM, bkev <[EMAIL PROTECTED]> wrote: > > I'm working on a site that has several imperial measurements (feet and > > inches) and I'd like to implement a field in my model that uses a > > regular expression like: > > ^(\d{1,5})\'((\s?)(-?)(\s?)([0-9]|(1[0-1]))\")?$ > > to parse off the feet and inches and save them in a sortable manner > > (I'm guessing the best way would be to convert them and save them as a > > decimal number, but the list and admin display needs to in x'-y" > > format. Anyone have any ideas as to how I might accomplish that? (or > > where I should look for more information)? > > I use the following method in one of my projects: > > def feetinch_to_cm(length): > """convert US style (feet-inch) length to metric (cm)""" > if length == u'' or length is None: > return None > m = re.match(r'(?P\d+)[\'`]( > *(?P\d+)(?P.)?("|\'\'))?', length) > if m is None: > raise Exception("unable to parse length: %s" % length,) > feet = int(m.group('feet')) > inch = int(m.group('inch') or 0) > half = int(m.group('half') == u'\xbd') > return (30.48 * feet) + (2.54 * inch) + (1.27 * half) > > I save the length in centimeters in database, then I can reformat it > as needed in the template or admin using a custom filter. > > Ronny --~--~-~--~~~---~--~~ 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: Is there a way to store Django tables in another schema
Hi Mathieu, On Aug 28, 3:24 pm, mathieu <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to use Django with an existing Oracle database, but I'd > rather not clutter the existing DB with Django tables, so I was > wondering if I can force them to some other schema that the main > schema I'm using. This isn't yet supported but see this ticket for more: http://code.djangoproject.com/ticket/6148 - RD --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Is there a way to store Django tables in another schema
Hi, I'm trying to use Django with an existing Oracle database, but I'd rather not clutter the existing DB with Django tables, so I was wondering if I can force them to some other schema that the main schema I'm using. Thanks -Mathieu --~--~-~--~~~---~--~~ 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: Core keyword error
Hi Rob, On Aug 28, 3:24 pm, Rob Goedman <[EMAIL PROTECTED]> wrote: > Hi, > > Since moving to beta-2 I get: > > Robs-Intel:mcp rob$ ./manage.py runserver > Validating models... > Unhandled exception in thread started by 0x7a8470> > Traceback (most recent call last): > File "/Library/Python/2.5/site-packages/django/core/management/ > commands/runserver.py", line 47, in inner_run > self.validate(display_num_errors=True) > File "/Library/Python/2.5/site-packages/django/core/management/ > base.py", line 122, in validate > num_errors = get_validation_errors(s, app) > File "/Library/Python/2.5/site-packages/django/core/management/ > validation.py", line 28, in get_validation_errors > for (app_name, error) in get_app_errors().items(): > File "/Library/Python/2.5/site-packages/django/db/models/ > loading.py", line 128, in get_app_errors > self._populate() > File "/Library/Python/2.5/site-packages/django/db/models/ > loading.py", line 57, in _populate > self.load_app(app_name, True) > File "/Library/Python/2.5/site-packages/django/db/models/ > loading.py", line 72, in load_app > mod = __import__(app_name, {}, {}, ['models']) > File "./Descriptors/models.py", line 27, in > class AEDescriptor(models.Model): > File "./Descriptors/models.py", line 31, in AEDescriptor > code = models.PositiveSmallIntegerField(core=True) > TypeError: __init__() got an unexpected keyword argument 'core' > > It's the 1st app that contains core=True in models.py: > > class AEDescriptor(models.Model): > """ The Descriptor class for alarm/event/system message descriptor > instances. > Table is loaded from ./mcp/Descriptors/sql/descriptor.sql""" > > code = models.PositiveSmallIntegerField(core=True) > descriptor = models.CharField(max_length=60, core=True) > > def __str__(self): > return self.descriptor > > class Meta: > verbose_name_plural = 'Alarms and events descriptors' > db_table='alarm_and_event_descriptors' > > Until beta-1 no problems. Any hints? > > I've checked the incompatible backward changes page and searched the > archives but was not able to find anything. Actually, it's kind of included in this entry: http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Removedoldformsvalidatorsandrelatedcode But you're right that it doesn't explicitly spell out that you will need to remove the core option from all your model fields for model validation to succeed. > I continue to be impressed by how smooth the migration/tracking svn > has been using that page! Yep. -Rajesh D --~--~-~--~~~---~--~~ 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: problems with request.user
In the docs for get_or_create()[1], it states that any argument given with `__` is stripped for the create() call. The reasons for this should be obvious. Thus, your original code was trying to save an empty Rating. As for speed, the new version has less SQL. `user__pk` creates a join and then compares the id of the user table with the id you gave. The second version is the same as `user_id=request.user.id` because that’s how Django compares models. [1]: http://docs.djangoproject.com/en/dev/ref/models/querysets/#queryset-methods-that-do-not-return-querysets On Aug 21, 2008, at 10:43 AM, Burr Settles wrote: > > When the IntegrityError is thrown, the debug package stated that > "songs_rating.user_id may not be NULL". It is indeed being thrown by > get_or_create(). Strangely enough, request.user.id contains the > correct value of the logged in user's ID, so I don't know what the > problem is. I did manage to get the view working by swapping out the > following for line 6: > > rating = Rating.objects.get_or_create(user=request.user, song=song) > [0] > > Now, it matches against the request.user and song objects directly, as > opposed to their IDs as primary keys. I don't know what sort of effect > this has on the efficiency of the underlying DB hit, but it seems the > best I can do for now. > > --B > > > On Aug 21, 12:20 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: >> On Wed, Aug 20, 2008 at 5:13 PM, Burr Settles >> <[EMAIL PROTECTED]> wrote: >> >>> I recently came back to a project I put on hold for a couple weeks, >>> and after updating the Django trunk, all my references to >>> "request.user.id" are broken. Here is an example view for a rating >>> widget: >> >>> 1 @login_required >>> 2 def rate(request, song_id): >>> 3 song = get_object_or_404(Song, pk=song_id) >>> 4 if 'rating' not in request.GET or request.GET['rating'] not in >>> range(1,5): >>> 5 HttpResponseRedirect(song.get_absolute_url()) >>> 6 rating = >>> Rating.objects.get_or_create(user__pk=request.user.id, >>> song__pk=song.id) >>> 7 rating.rating = int(request.GET['rating']) >>> 8 rating.save() >>> 9 return HttpResponseRedirect(song.get_absolute_url()) >> >>> This throws an "IntegrityError" if the user is logged in, presumably >>> complaining that request.user.id is NULL (at line 6). >> >> Presumably? I suspect you are guessing wrong here, but it would be >> best to >> make sure. There's lots of information available on the deubg page >> when >> something like an IntegrityError is thrown, have you checked the >> values of >> local variables to see what request.user.id actually is? >> >>> But it passes >>> the @login_required constraint just fine. I'm having similar >>> problems >>> with other views that use request.user. >> >>> Does anyone know if the user API has recently changed? I've scoured >>> the latest online documentation, and can't seem to find any >>> alternate >>> way to access the ID of the currently logged in user. Any help is >>> appreciated. >> >> I do not think anything has changed with request.user. It seems >> more likely >> something is going wrong in get_or_create. Such as the get fails >> to find an >> existing record so it tries to insert one but that is violating an >> integrity >> constraint. What, exactly, does the IntegrityError message say? >> Usually >> it will give some indication of what it is objecting to, which >> could provide >> a clue. >> >> Karen > > -- Peter of the Norse -- Peter of the Norse --~--~-~--~~~---~--~~ 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: Core keyword error
On Thu, 2008-08-28 at 12:24 -0700, Rob Goedman wrote: [..] > Until beta-1 no problems. Any hints? It was removed as part of r8616. It hasn't actually been needed since newforms-admin landed, but was tied to the manipulator code that was removed in the above changeset. Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Core keyword error
Hi, Since moving to beta-2 I get: Robs-Intel:mcp rob$ ./manage.py runserver Validating models... Unhandled exception in thread started by Traceback (most recent call last): File "/Library/Python/2.5/site-packages/django/core/management/ commands/runserver.py", line 47, in inner_run self.validate(display_num_errors=True) File "/Library/Python/2.5/site-packages/django/core/management/ base.py", line 122, in validate num_errors = get_validation_errors(s, app) File "/Library/Python/2.5/site-packages/django/core/management/ validation.py", line 28, in get_validation_errors for (app_name, error) in get_app_errors().items(): File "/Library/Python/2.5/site-packages/django/db/models/ loading.py", line 128, in get_app_errors self._populate() File "/Library/Python/2.5/site-packages/django/db/models/ loading.py", line 57, in _populate self.load_app(app_name, True) File "/Library/Python/2.5/site-packages/django/db/models/ loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "./Descriptors/models.py", line 27, in class AEDescriptor(models.Model): File "./Descriptors/models.py", line 31, in AEDescriptor code = models.PositiveSmallIntegerField(core=True) TypeError: __init__() got an unexpected keyword argument 'core' It's the 1st app that contains core=True in models.py: class AEDescriptor(models.Model): """ The Descriptor class for alarm/event/system message descriptor instances. Table is loaded from ./mcp/Descriptors/sql/descriptor.sql""" code = models.PositiveSmallIntegerField(core=True) descriptor = models.CharField(max_length=60, core=True) def __str__(self): return self.descriptor class Meta: verbose_name_plural = 'Alarms and events descriptors' db_table='alarm_and_event_descriptors' Until beta-1 no problems. Any hints? I've checked the incompatible backward changes page and searched the archives but was not able to find anything. I continue to be impressed by how smooth the migration/tracking svn has been using that page! Thanks, Rob --~--~-~--~~~---~--~~ 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: using File storage
On Aug 28, 8:53 pm, julianb <[EMAIL PROTECTED]> wrote: > I tried several things, I think Marty's solution was among them. It > did not throw errors, but the file I got was 0 bytes. I will try again > and check if I made a mistake or so... Okay, I solved the puzzle. The following works: big = StringIO.StringIO() # you have a StringIO ... image.save(big, "JPEG", quality=70) # write something to the StringIO ... # Photo is a model that has an image field photo = Photo(user=creator) # use getvalue because ContentFile just needs content big_file = ContentFile(big.getvalue()) # use save method of image field, no other function! photo.data.save("%s.jpg" % name, big_file) --~--~-~--~~~---~--~~ 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: Problem with query_set extra select/field casting
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, both hosts run the same Django version: trunk r8555. regards, Malcolm Tredinnick wrote: | | On Thu, 2008-08-28 at 20:58 +0200, Stephan Jäkel wrote: | [...] |> x.date returns a unicode string even its the same code, the same |> database and same versions (database, python-mysqldb, python itself). | | Is it the same version of Django? That could be an important difference. | If it is the same, *which* version of Django are you running? | | I can't think what could be causing this difference, but it would | certainly be interesting to work it out. Normally the database wrapper | (python-mysqldb in this case) takes care of the conversion between | column types and Python types, so Django shouldn't be doing anything | here (we have some converter overrides, but nothing for dates). | | Regards, | Malcolm | | | | | | - -- Stephan Jäkel e-Mail : [EMAIL PROTECTED] Website : http://rdev.info Mobile : +49 163 458 9 173 What do you mean that could take down the whole network? -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFItvgz4B/i3Mb6qe4RApDzAKDftx6G7yLEo2hIRQ3V1+G4jxNbhQCg3ENR fpyPOwISfD67ZcrzjqmfyEs= =Vo5T -END PGP SIGNATURE- --~--~-~--~~~---~--~~ 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: ANN: django-morsels
I just checked out the newest revision and it works! I am certain this will be a very handy asset. To debug the issue you can use the {% debug %} template tag. Thank you, Richard On Sun, Aug 24, 2008 at 6:11 AM, Richard Ward <[EMAIL PROTECTED]> wrote: > I too am unable to display the morsels. > > I believe it is install correctly. > > I can add morsels. > The morsel tag generates no error when the template is generated. > > This is my context setting: > TEMPLATE_CONTEXT_PROCESSORS = ( >"django.core.context_processors.auth", >"django.core.context_processors.debug", >"django.core.context_processors.i18n", >"django.core.context_processors.media", >"django.core.context_processors.request", > ) > > I do not know how to debug the installation. > > > Thanks > Richard > > On Sat, Aug 23, 2008 at 12:04 AM, Itai Tavor <[EMAIL PROTECTED]> wrote: >> >> Apologies to everyone who got bit by this. I updated the INSTALL >> instructions with the requirement of adding 'request' to the context. >> >> Itai >> >> >> On 23/08/2008, at 6:26 AM, lingrlongr wrote: >> >>> >>> Recommended fix @ http://code.google.com/p/django-morsels/issues/detail?id=1 >>> >>> On Aug 22, 2:51 pm, lingrlongr <[EMAIL PROTECTED]> wrote: If I change my view to this, it works: # views.py def myview(request): return object_list( request, queryset=Stuff.objects.all(), extra_context = { 'request': request, } ) Is this supposed to be the right way to use morsels? Keith On Aug 22, 12:50 pm, lingrlongr <[EMAIL PROTECTED]> wrote: > I can't get this to work at all. Seems to bomb here: > class MorselManager(models.Manager): > def get_for_current(self, context, name, inherit=False): > if not context.has_key('request'): <-- key never > seems to exist > return None > I have a morsel defined with a URL of "/mypage/". > # urls.py > (r'^mypage/$', myview), > # views.py > def myview(request): > return object_list( > request, > queryset=Stuff.objects.all(), > ) > I have this in my template: > {% load morsel_tags %} > {% morsel %} > Am I missing something? > Keith > On Aug 21, 5:19 am, Itai Tavor <[EMAIL PROTECTED]> wrote: >> At first glance (and, quite possibly, second and third) django- >> morsels >> might look like a clone of django-chunks >> (http://code.google.com/p/django-chunks/ >> ). Both apps attempt to solve the same problem, and in fact, I >> wrote >> this app after seeing and trying out django-chunks (so thanks, >> Clint >> Ecker!). But the feature set and functions differ enough to justify >> the existence of a second implementation. >> These apps provide a way to store partial page content in the >> database, and manage it in the admin app, when this content is >> integrated in pages that also contain dynamic features. I always >> dealt >> with this using FlatPages and templatetags (custom-written for each >> new project) that included them in templates. Looking at django- >> chunks, I realized a few things: >> 1) The templatetags I've already written worked better, for my own >> use, than the key-based approach of django-chunks. >> 2) Using a dedicated model for this type of content made a lot of >> sense. >> 3) Merging this model and all those custom templatetags I already >> had >> into a reusable app also made sense. >> 4) I needed a name that didn't have "chunks" in it. >> The main features of django-morselsare: >> * Each morsel can be tied to a site page by specifying the page's >> URL >> in the morsel. >> * Differentmorselscan be used in the same page by adding arbitrary >> names to the morsel's URL. >> *Morselscan be inherited from higher levels in the site's URL >> hierarchy. This allows the content of a single morsel to be >> displayed >> in a whole site section, while being overriden by othermorselsin >> specific pages within the section. >> *Morselscan include an optional title, which may be used to >> identify >> the morsel and may also be displayed in templates using the morsel. >> * Two custom templatetags - morsel and withmorsel - allowmorselsto >> be used in various, flexible ways. >> *Morselscan be locked, which prevents them from being deleted. This >> is intended to prevent accidental deletion of requiredmorsels, as >> having to explicitly unlock a morsel before deleting it should make >> the user think twice about it. >> * If the typogrify app (http://code.google.com/p/typogrify/) is >> installed, morsel content will be typogrified when rendered using
Re: Problem with query_set extra select/field casting
On Thu, 2008-08-28 at 20:58 +0200, Stephan Jäkel wrote: [...] > x.date returns a unicode string even its the same code, the same > database and same versions (database, python-mysqldb, python itself). Is it the same version of Django? That could be an important difference. If it is the same, *which* version of Django are you running? I can't think what could be causing this difference, but it would certainly be interesting to work it out. Normally the database wrapper (python-mysqldb in this case) takes care of the conversion between column types and Python types, so Django shouldn't be doing anything here (we have some converter overrides, but nothing for dates). Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problem with query_set extra select/field casting
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, i've got a problem while moving a django project from one host (debian linux) to another (suse linux) and it seems, that there is a problem with djangos database/models modules. on the current host i can do something like that: |> from board.models import Thread |> x = Thread.view_manager.get(pk=2) |> x.date datetime.datetime(2008, 8, 19, 22, 20, 41) x.date returns aa datetime object. (date in board_post is a DATETIME field in the database). on the new host, the same commands return this: |> from board.models import Thread |> x = Thread.view_manager.get(pk=2) |> x.date u'2008-08-19 22:20:41' x.date returns a unicode string even its the same code, the same database and same versions (database, python-mysqldb, python itself). but if i execute the same query on the new host directly using MySQLdb: |>> c.execute('SELECT date FROM board_post WHERE board_post.thread_id=2 ORDER BY date DESC LIMIT 1') 1L |>> c.fetchone()[0] datetime.datetime(2008, 8, 19, 22, 20, 41) This is the code used for Thread.view_manager: class ThreadManager(models.Manager): ~def get_query_set(self): ~extra_last_updated = """ ~SELECT date FROM board_post ~WHERE board_post.thread_id = board_thread.id ~ORDER BY date DESC LIMIT 1 ~""" ~return super(ThreadManager, self).get_query_set().extra( ~select = { ~'date': extra_last_updated, ~},).exclude(deleted=True).order_by('-date') I have no idea why this problem appears.. any ideas? thanks in advance :-) best regards, - -- Stephan Jäkel e-Mail : [EMAIL PROTECTED] Website : http://rdev.info Mobile : +49 163 458 9 173 What do you mean that could take down the whole network? -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFItvVr4B/i3Mb6qe4RAjUBAJ9YFNLeznIIbAHTQRlndZ4IqJGAAQCgru2T EDKCFfENKSlw9aKSAE6p4dM= =SGVp -END PGP SIGNATURE- --~--~-~--~~~---~--~~ 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: using File storage
On Aug 28, 8:44 pm, "Tim Kersten" <[EMAIL PROTECTED]> wrote: > This should fix the error you got: > > import StringIO > from django.core.files import File > f = StringIO.StringIO() > f.name, f.mode = 'data.xml', 'r' > f.write(data) > myfile = File(f) > Chart.objects.create(xml=default_storage.save(f.name, myfile)) > > However, Marty's solution seems a lot nicer. Did that not work? I've > never done anything like what I've shown you - it was more or less a > straight guess as to how it might work. Marty's solution looks a lot > more correct and a lot cleaner too. Perhaps you should be trying to > make that work instead? AttributeError: StringIO instance has no attribute 'name' I tried several things, I think Marty's solution was among them. It did not throw errors, but the file I got was 0 bytes. I will try again and check if I made a mistake or so... --~--~-~--~~~---~--~~ 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: using File storage
Oh, I should have seen that coming. (That's the bad thing when you write code without testing it yourself... something is often missed :-) This should fix the error you got: import StringIO from django.core.files import File f = StringIO.StringIO() f.name, f.mode = 'data.xml', 'r' f.write(data) myfile = File(f) Chart.objects.create(xml=default_storage.save(f.name, myfile)) However, Marty's solution seems a lot nicer. Did that not work? I've never done anything like what I've shown you - it was more or less a straight guess as to how it might work. Marty's solution looks a lot more correct and a lot cleaner too. Perhaps you should be trying to make that work instead? Tim ^,^ On Thu, Aug 28, 2008 at 7:18 PM, julianb <[EMAIL PROTECTED]> wrote: > > On Aug 28, 6:03 pm, "Tim Kersten" <[EMAIL PROTECTED]> wrote: >> There's probably a better way than this though so you might want to >> wait for other replies. >> >> import StringIO >> from django.core.files import File >> f = StringIO.StringIO() >> f.write(data) >> myfile = File(f) >> Chart.objects.create(xml=default_storage.save('data.xml', myfile)) > > That's not working for me, I get AttributeError: StringIO instance has > no attribute 'name'... > > > --~--~-~--~~~---~--~~ 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: Django and CSS
MEDIA_ROOT is the local path to the files on the server. One place this is used is with uploading files. So uploaded files will be placed in MEDIA_ROOT/some-upload-dir. I don't know about other uses, though. John --~--~-~--~~~---~--~~ 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: using File storage
On Aug 28, 6:03 pm, "Tim Kersten" <[EMAIL PROTECTED]> wrote: > There's probably a better way than this though so you might want to > wait for other replies. > > import StringIO > from django.core.files import File > f = StringIO.StringIO() > f.write(data) > myfile = File(f) > Chart.objects.create(xml=default_storage.save('data.xml', myfile)) That's not working for me, I get AttributeError: StringIO instance has no attribute 'name'... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Suggestion for developers using code-google
Is great to find so much django apps code in google-code, but it would better if the code was labelled with the version of django for which this done. Examples: django-0.96, django-0.97, django-1.0b1, django-1.0... Regards, Jordi --~--~-~--~~~---~--~~ 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: use crypt algo for user passwords
> thanks opend ticket #8647 Attached is a patch against contrib/auth/models.py that should add an "algo" parameter to set_password so it takes an algorithm. -tim --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- Index: models.py === --- models.py (revision 8666) +++ models.py (working copy) @@ -9,6 +9,7 @@ import urllib UNUSABLE_PASSWORD = '!' # This will never be a valid hash +DEFAULT_ALGO = 'sha1' try: set @@ -103,12 +104,12 @@ return self.name class UserManager(models.Manager): -def create_user(self, username, email, password=None): +def create_user(self, username, email, password=None, algo=DEFAULT_ALGO): "Creates and saves a User with the given username, e-mail and password." now = datetime.datetime.now() user = self.model(None, username, '', '', email.strip().lower(), 'placeholder', False, True, False, now, now) if password: -user.set_password(password) +user.set_password(password, algo) else: user.set_unusable_password() user.save() @@ -172,9 +173,8 @@ full_name = u'%s %s' % (self.first_name, self.last_name) return full_name.strip() -def set_password(self, raw_password): +def set_password(self, raw_password, algo=DEFAULT_ALGO): import random -algo = 'sha1' salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5] hsh = get_hexdigest(algo, salt, raw_password) self.password = '%s$%s$%s' % (algo, salt, hsh) @@ -343,7 +343,7 @@ def delete(self): raise NotImplementedError -def set_password(self, raw_password): +def set_password(self, raw_password, algo=DEFAULT_ALGO): raise NotImplementedError def check_password(self, raw_password):
Re: Random NoReverseMatch
I've just come across this ticket, http://code.djangoproject.com/ticket/8221, which has a patch attached. I've just applied the patch and crippled my url regex again to re-create the error. This is what was reported this time; NoReverseMatch: Reverse for 'MBBS.agenda_today_group' with arguments '(u'st4gp4&5',)' and keyword arguments '{}' not found. Now *that* would have saved a heap of time earlier on today ;) Ticket 8221 is down for the 1.0 release, so hopefully, we'll have that in trunk ready for the big release of V1.0. HTH Tone On Aug 28, 6:20 pm, tonemcd <[EMAIL PROTECTED]> wrote: > Well, this bit me a while back when I svn-up'ed from trunk and I got > fed up of changing my django.pth to point to trunk_r7971, so I was > determined to get it sorted out. > > The first thing is that the NoReverseMatch error seems to be a catch- > all for a variety of exceptions, so if you can, check out your imports > as Koen outlines below. > > However, I think that in this case it is far more likely that you have > some data that is triggering the NoReverseMatch exception, as you say > it happens randomly, and I think what is happening is your arguments > to {% url ... %} are not compatible with what your named url is > expecting to see. > > This is what happened to me; my urls are of the form; > > today//agenda > > where is letters (upper and lowercase), numbers and '-', so > these are valid stgp01, st2gp2-18 etc. > > I used this match to begin with; > url(r'^today/(?P[\w,-]+)/agenda$ > > fromhttp://python.about.com/od/regularexpressions/a/regexprimer.htm > you can see that \w handles alphanumerics and _. > > This is what killed it; > > /today/st4gp8&9/agenda > > With r7971 this would not have been a problem (well actually it would > have been a problem because the URL wouldn't work), but at least it > wouldn't give you an error. Now it does (it was changed in r8211, > seehttp://code.djangoproject.com/wiki/BackwardsIncompatibleChangesfor > more details). > > The solution for me was to include & and friends into the regex, so I > added \W as well (the above URL has details). > > My final URL pattern is url(r'^today/(?P[\w,\W-]+)/agenda$ and > this works just fine. > > I don't know what you're matching, but I'd hazard a guess that what > you're pumping out is not compatible with what your URL regex is > expecting to see. > > This seems like a prime example of something that needs a slightly > more descriptive error message, but whether that's possible or not, I > don't know (I did dig around in urlresolvers.py, but it went rapidly > over my django-fu). > > Hope this helps, > Tone > > On Aug 25, 8:40 pm, koenb <[EMAIL PROTECTED]> wrote: > > > > > I guess you are seeing the bug reported in #6379. You probably have an > > import error somewhere, but it is being hidden by theNoReverseMatch > > exception that is raised for anything that goes wrong. > > > Koen > > > On 25 aug, 16:13, Robin <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > i have the same exception and exactly as Julien explained in the dev > > > server works fine ... and also works fine with fast_cgi, but I am > > > using apache + mod_wsgi and it didn't work with the same problem: > > >NoReverseMatch > > > > Has any of you any clue to this error ? > > > > thanks in advance, > > > r > > > > On Aug 16, 8:16 pm, Alberto Piai <[EMAIL PROTECTED]> wrote: > > > > > On Aug 16, 12:01 am, Julien Phalip <[EMAIL PROTECTED]> wrote: > > > > > > Hi, > > > > > > It's likely that there is a typo somewhere in your templates, either > > > > > you didn't write the view name properly, or you didn't provide the > > > > > right parameters. > > > > > In the error message, there should be the name of the view. Look up > > > > > every occurrence et double check that you haven't made any typo. > > > > > I'm checking everything again. But actually I don't think the > > > > problem's there, as everything works fine when run from django's dev > > > > server, and now it's been working fine for some hours even on lighttpd > > > > +fcgi. When the problem appears again I'll send the traceback. > > > > > Thanks for you help, > > > > > Alberto --~--~-~--~~~---~--~~ 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: Dictionary key-value pair
On Aug 28, 2008, at 1:18 PM, saeb wrote: > No, it is not just those fields, there are about 20 key-value items. I > have a Database with about 40 tables. and I am essentially trying to > render a snapshot of about 15 important table which had foreign key > relationship with other tables. Following will give you an idea of > what I am trying to do. Thanks Since it looks like you're basically using the dictionary like a list of tuples, why not make it a list of tuples? It should preserve ordering too, that way. --- David Zhou [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: site using Django/mod_python/apache2 randomly showing "It worked!" page
Does Apache have mod_wsgi? If so, you can get them to make a change to your .conf file as detailed at http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode This means you only need to 'touch' the .wsgi file specified by the WSGIScriptAlias to get your Apache process to restart. Works a treat! I moved away from mod_python for the very reason you've outlined. The wealth of information on mod_wsgi is immense! Cheers, Tone On Aug 28, 6:25 pm, Gremmie <[EMAIL PROTECTED]> wrote: > On Aug 27, 8:18 pm, Richard Simões <[EMAIL PROTECTED]> wrote:> I have > non-root access to a server with apache2 and mod_python. I > > installed django with svn to a location in my home directory and > > created a test project. When I go to a URL defined with urls.py and > > views.py, 9/10 times the expected page is shown. The remaining 1/10 > > times the "It worked!" page pops up. Searching for this problem seems > > a bit difficult. Any idea on what could be happening? > > It sounds like some of the apache processes are running your new code, > but some of the other processes are still running the typical > mod_python test program you use to see if mod_python is configured > correctly. You will need to restart apache after every code change. --~--~-~--~~~---~--~~ 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: site using Django/mod_python/apache2 randomly showing "It worked!" page
On Aug 27, 8:18 pm, Richard Simões <[EMAIL PROTECTED]> wrote: > I have non-root access to a server with apache2 and mod_python. I > installed django with svn to a location in my home directory and > created a test project. When I go to a URL defined with urls.py and > views.py, 9/10 times the expected page is shown. The remaining 1/10 > times the "It worked!" page pops up. Searching for this problem seems > a bit difficult. Any idea on what could be happening? > It sounds like some of the apache processes are running your new code, but some of the other processes are still running the typical mod_python test program you use to see if mod_python is configured correctly. You will need to restart apache after every code change. --~--~-~--~~~---~--~~ 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: site using Django/mod_python/apache2 randomly showing "It worked!" page
On Thu, Aug 28, 2008 at 1:13 PM, Richard Simões <[EMAIL PROTECTED]> wrote: > > I didn't, no (no root access). At what point should that be necessary, > if ever? > Apache needs to be restarted any time you change your code. It's going to be very hard to develop on a setup with no ability to restart Apache. Karen > /Richard Simões > > On Aug 28, 12:11 am, David Zhou <[EMAIL PROTECTED]> wrote: > > On Aug 27, 2008, at 9:18 PM, Richard Simões wrote: > > > > > I have non-root access to a server with apache2 and mod_python. I > > > installed django with svn to a location in my home directory and > > > created a test project. When I go to a URL defined with urls.py and > > > views.py, 9/10 times the expected page is shown. The remaining 1/10 > > > times the "It worked!" page pops up. Searching for this problem seems > > > a bit difficult. Any idea on what could be happening? > > > > Did you restart the server after making your changes? > > > > --- > > David Zhou > > [EMAIL PROTECTED] > > > --~--~-~--~~~---~--~~ 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: Random NoReverseMatch
Well, this bit me a while back when I svn-up'ed from trunk and I got fed up of changing my django.pth to point to trunk_r7971, so I was determined to get it sorted out. The first thing is that the NoReverseMatch error seems to be a catch- all for a variety of exceptions, so if you can, check out your imports as Koen outlines below. However, I think that in this case it is far more likely that you have some data that is triggering the NoReverseMatch exception, as you say it happens randomly, and I think what is happening is your arguments to {% url ... %} are not compatible with what your named url is expecting to see. This is what happened to me; my urls are of the form; today//agenda where is letters (upper and lowercase), numbers and '-', so these are valid stgp01, st2gp2-18 etc. I used this match to begin with; url(r'^today/(?P[\w,-]+)/agenda$ from http://python.about.com/od/regularexpressions/a/regexprimer.htm you can see that \w handles alphanumerics and _. This is what killed it; /today/st4gp8&9/agenda With r7971 this would not have been a problem (well actually it would have been a problem because the URL wouldn't work), but at least it wouldn't give you an error. Now it does (it was changed in r8211, see http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges for more details). The solution for me was to include & and friends into the regex, so I added \W as well (the above URL has details). My final URL pattern is url(r'^today/(?P[\w,\W-]+)/agenda$ and this works just fine. I don't know what you're matching, but I'd hazard a guess that what you're pumping out is not compatible with what your URL regex is expecting to see. This seems like a prime example of something that needs a slightly more descriptive error message, but whether that's possible or not, I don't know (I did dig around in urlresolvers.py, but it went rapidly over my django-fu). Hope this helps, Tone On Aug 25, 8:40 pm, koenb <[EMAIL PROTECTED]> wrote: > I guess you are seeing the bug reported in #6379. You probably have an > import error somewhere, but it is being hidden by theNoReverseMatch > exception that is raised for anything that goes wrong. > > Koen > > On 25 aug, 16:13, Robin <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > i have the same exception and exactly as Julien explained in the dev > > server works fine ... and also works fine with fast_cgi, but I am > > using apache + mod_wsgi and it didn't work with the same problem: > >NoReverseMatch > > > Has any of you any clue to this error ? > > > thanks in advance, > > r > > > On Aug 16, 8:16 pm, Alberto Piai <[EMAIL PROTECTED]> wrote: > > > > On Aug 16, 12:01 am, Julien Phalip <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > It's likely that there is a typo somewhere in your templates, either > > > > you didn't write the view name properly, or you didn't provide the > > > > right parameters. > > > > In the error message, there should be the name of the view. Look up > > > > every occurrence et double check that you haven't made any typo. > > > > I'm checking everything again. But actually I don't think the > > > problem's there, as everything works fine when run from django's dev > > > server, and now it's been working fine for some hours even on lighttpd > > > +fcgi. When the problem appears again I'll send the traceback. > > > > Thanks for you help, > > > > Alberto --~--~-~--~~~---~--~~ 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: How to handle platform dependent settings?
On Aug 28, 12:15 am, David Zhou <[EMAIL PROTECTED]> wrote: > > If it's mostly paths that you need to change, check out: > > http://rob.cogit8.org/blog/2008/Jun/20/django-and-relativity/ > It is a lot more than dealing with relative paths. However this link takes the same approach as what I was thinking about doing, so thanks for that. --~--~-~--~~~---~--~~ 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: Dictionary key-value pair
No, it is not just those fields, there are about 20 key-value items. I have a Database with about 40 tables. and I am essentially trying to render a snapshot of about 15 important table which had foreign key relationship with other tables. Following will give you an idea of what I am trying to do. Thanks template --- User details {% for i in user_details.items %} {{i.0}} {{i.1}} {% endfor %} Order details {% for i in order_details.items %} {{i.0}} {{i.1}} {% endfor %} : : : ---views.py- if request.method == 'POST': user_id = request.POST["user_id"] user = Users.objects.get(pk=user_id) user_details['Name'] = user.name user_details['Login'] = user.login user_details['Phone No.'] = user.phone_number user_entity = UserEntities.objects.all().filter(owner=user_id) total_user_profit = sum([obj.profit for obj in user_entity]) total_user_loss = sum([obj.loss for obj in user_entity]) trader_acct_details['Total profit'] = total_user_profit trader_acct_details['Total loss'] = total_user_profit orders = Orders.objects.get_todays_orders(user_id) new_order_count = sum([obj.quantity for obj in orders.filter(order_state ='N')]) order_details['New Orders'] = new_order_count : : : return render_to_response('admin/ Snapshot.html', { 'user_details': user_details, 'user_acct_details': trader_acct_details, 'order_details': order_details }) On Aug 28, 11:49 am, David Zhou <[EMAIL PROTECTED]> wrote: > On Aug 28, 2008, at 12:45 PM, saeb wrote: > > > order is important for display, I am calculating sum and average on > > query objects and storing it in dictionary with key/values which are > > used in a template. So I have a dictionary something like this : > > {'name': user1, 'phone': 723872, 'Total Friends': 20, 'Avg Rating' : > > 3.6} > > so when I render I would these to appear in order. > > Can you post the relevant view and template code? > > But if it's just those fields, why not refer to them explicitly? Such > as: > > {{dict_variabe.name}} or {{dict_variable.phone}} > > --- > David Zhou > [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: site using Django/mod_python/apache2 randomly showing "It worked!" page
I didn't, no (no root access). At what point should that be necessary, if ever? /Richard Simões On Aug 28, 12:11 am, David Zhou <[EMAIL PROTECTED]> wrote: > On Aug 27, 2008, at 9:18 PM, Richard Simões wrote: > > > I have non-root access to a server with apache2 and mod_python. I > > installed django with svn to a location in my home directory and > > created a test project. When I go to a URL defined with urls.py and > > views.py, 9/10 times the expected page is shown. The remaining 1/10 > > times the "It worked!" page pops up. Searching for this problem seems > > a bit difficult. Any idea on what could be happening? > > Did you restart the server after making your changes? > > --- > David Zhou > [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: can't pickle OracleQuery
Many thanks for reply. It might just be of interest to know that what I was actaully pickling (storing in a session) was not the queryset itself (since it is large) but the Queryset.query attribute which I imagined to be just the sql (maybe wrapped in something). Once I'd encountered the error I did look at the oracle backend and saw that the OracleQuery was not defined at the module level and thus wouldn't pickle. It would certainly be handy if the .query attribute were pickleable even if the queryset itself could not be, then one could recreate the queryset as the docs (in the section on Pickling QuerySets) suggest. Paul Hide On Aug 28, 5:49 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-08-28 at 06:51 -0700, paulh wrote: > > django svn version 8659 > > I have some django code that runs perfectly against postgres > > (psycopg2), but fails with: PicklingError: Can't pickle > 'django.db.backends.oracle.query.OracleQuery'>: attribute lookup > > django.db.backends.oracle.query.OracleQuery failed > > when run against an Oracle XE database. > > > Just wondered whether anyone else had encountered this type of > > problem. > > Yes, it's a known restriction because the OracleQuery class is > dynamically defined (Python can only normally pickle classes defined at > the top level). I'm working on what I hope might be a solution for 1.0. > > The workaround is to manually convert your queryset to a list and > pickle/cache the list rather than the queryset. For almost all > use-cases, that should be equivalent. The case where it fails is when > you want to unpickle and then call extra queryset methods so, for now, > don't do that if you're using the Oracle backend. > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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: Change language in Admin modules
On Thu, Aug 28, 2008 at 12:45 PM, Bobo <[EMAIL PROTECTED]> wrote: > > Hi everybody, > > I've a question about the language settings in django and namely in > the Admin section. > > At djangoproject.com there are a danish translation (http:// > code.djangoproject.com/ticket/8308) but I don't know how to "install" > it so my Admin module is writing the text in Danish instead of > English. > > I know it is not meant to be installed but I can't find any > information on how to use those language files. I've tried to read in > django book but with little luck only. > > I hope someone have the answer or a good tutorial / page that can > explain how this works. > > Just set LANGUAGE_CODE in settings.py to 'da' and your Admin will display Danish: http://www.djangoproject.com/documentation/settings/#language-code Karen --~--~-~--~~~---~--~~ 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: intpoint filter
On Thu, 2008-08-28 at 10:54 -0400, Keith Eberle wrote: > I use similar functions for some of my template filters, but I use > locale instead. > > import locale > locale.setlocale(locale.LC_ALL, '') Unfortunately that has problems if your application is expected to work in multiple locales. Because it operates globally, setlocale() is kind of an anti-solution to anything that requires finely controlled locale support (the reason is because multiple threads of execution calling setlocale() for different settings are going to have conflicts). Any solution for this in Django has to work with multilingual sites. We have a good plan for how to solve this, but we just ran out of time for 1.0. #7980 is the tracking ticket for this. Regards, Malcolm --~--~-~--~~~---~--~~ 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: Generate admin files. Views and Templates with Django?
When you create a project you run a command (python manage.py startapp test) that creates the directory and the model and view files. However if you want the app to use the admin interface you must explicitly state it in your models.py file or admin.py (which you need to create) If you wish to automatically include some files you can specify these files in \django\conf\project_template On Thu, Aug 28, 2008 at 8:06 AM, Daniel A. <[EMAIL PROTECTED]> wrote: > > I'm a Rails switcher to Django. In Rails there's an option to generate > all the scaffold files, ie, there's a command line script that creates > all the files in the project folder of the admin interface. I want to > know if there's something similar for Django. Thanks > > > -- http://www.goldwatches.com/ --~--~-~--~~~---~--~~ 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: HowTo: Django view as a class
An alternative is to use some metaclass programming, but to be honest it's more trouble than it's worth. This does actually help with RESTfulness, because it allows you to aggregate your views on a resource-centric basis, as a collection of atomic operations on a resource, and then you would define a mapping between URLs (Uniform RESOURCE Locators) and Resource subclasses. So yes, it does help with RESTfulness. Regards, Zack On Aug 27, 8:51 pm, "Jenan Wise" <[EMAIL PROTECTED]> wrote: > V: Defining a __call__ method will make *instances* of the class callable. > Calling the class itself will still just instantiate it. > > On Tue, Aug 26, 2008 at 7:00 AM, V <[EMAIL PROTECTED]> wrote: > > > Hi! > > > Interesting solution. > > > Another possibility if you would like to stick with a class is to > > simply define a __call__ method on the class. Of course, this doesn't > > have to do anything with RESTfulness. > > > V > > > On Aug 26, 3:07 am, zvoase <[EMAIL PROTECTED]> wrote: > > > Hey Django users, just a quick suggestion which might help a few > > > people. > > > I have come up with a way of writing a Django view as a class. I've > > > done this as part of an effort to write easier-to-understand RESTful > > > apps, as this allows the grouping of similar views as different types > > > of operation on a resource. Essentially, the solution goes something > > > like this: > > > > * Views have to be callables which return HttpResponse objects. > > > * The problem with views as classes is that calling a view class > > > returns an instance of the view class, not HttpResponse. > > > * Solution: have the VC (view class) a subclass of HttpResponse. > > > This way, 'calling' the class will return a HttpResponse instance. > > > > I've written a general class, Resource, which performs a dispatch on > > > the request method, so that a resource can be retrieved, created/ > > > updated and deleted by writing 'get', 'put' and 'delete' methods on a > > > subclass of Resource. > > > > A sample resource may look like this: > > > > # CODE START # > > > > class Book(Resource): > > > def get(self, request, book_name): > > > book = myapp.models.Book.objects.get(name=book_name) > > > return render_to_response('book_template.html', {'book': > > > book}) > > > > def put(self, request, book_name): > > > new_book, created = get_or_create(myapp.models.Book, > > > name=book_name) > > > new_book.data = request.raw_post_data > > > if created: > > > return HttpResponse(status=201) > > > return HttpResponse(status=200) > > > > def delete(self, request, book_name): > > > book = myapp.models.Book.objects.get(name=book_name) > > > book.delete() > > > return HttpResponse() > > > > # CODE END # > > > > You can see how these methods correspond to GET, PUT and DELETE > > > request methods, and the dispatch is performed in the __init__ method > > > defined in the Resource class. HttpResponse instances can be returned > > > from these methods, and their data will be merged with 'self' by > > > __init__. > > > > Okay, so here's the code I've written: > > > > # CODE START # > > > > class Resource(HttpResponse): > > > def __init__(self, request, *args, **kwargs): > > > HttpResponse.__init__(self) > > > if hasattr(self, request.method.lower()): > > > value = getattr(self, > > request.method.lower())(request, *args, > > > **kwargs) > > > if isinstance(value, HttpResponse): > > > self.update(value) > > > elif hasattr(self, 'run'): > > > value = self.run(request, *args, **kwargs) > > > if isinstance(value, HttpResponse): > > > self.update(value) > > > > def update(self, response): > > > self._charset = response._charset > > > self._is_string = response._is_string > > > self._container = response._container > > > self._headers.update(response._headers) > > > self.cookies.update(response.cookies) > > > self.status_code = response.status_code > > > > def render_to_response(self, *args, **kwargs): > > > self.update(render_to_response(*args, **kwargs)) > > > > # CODE END # > > > > I hope people find this useful. > > > > Regards, > > > Zack --~--~-~--~~~---~--~~ 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: can't pickle OracleQuery
On Thu, 2008-08-28 at 06:51 -0700, paulh wrote: > django svn version 8659 > I have some django code that runs perfectly against postgres > (psycopg2), but fails with: PicklingError: Can't pickle 'django.db.backends.oracle.query.OracleQuery'>: attribute lookup > django.db.backends.oracle.query.OracleQuery failed > when run against an Oracle XE database. > > Just wondered whether anyone else had encountered this type of > problem. Yes, it's a known restriction because the OracleQuery class is dynamically defined (Python can only normally pickle classes defined at the top level). I'm working on what I hope might be a solution for 1.0. The workaround is to manually convert your queryset to a list and pickle/cache the list rather than the queryset. For almost all use-cases, that should be equivalent. The case where it fails is when you want to unpickle and then call extra queryset methods so, for now, don't do that if you're using the Oracle backend. Regards, Malcolm --~--~-~--~~~---~--~~ 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: Dictionary key-value pair
On Aug 28, 2008, at 12:45 PM, saeb wrote: > order is important for display, I am calculating sum and average on > query objects and storing it in dictionary with key/values which are > used in a template. So I have a dictionary something like this : > {'name': user1, 'phone': 723872, 'Total Friends': 20, 'Avg Rating' : > 3.6} > so when I render I would these to appear in order. Can you post the relevant view and template code? But if it's just those fields, why not refer to them explicitly? Such as: {{dict_variabe.name}} or {{dict_variable.phone}} --- David Zhou [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Change language in Admin modules
Hi everybody, I've a question about the language settings in django and namely in the Admin section. At djangoproject.com there are a danish translation (http:// code.djangoproject.com/ticket/8308) but I don't know how to "install" it so my Admin module is writing the text in Danish instead of English. I know it is not meant to be installed but I can't find any information on how to use those language files. I've tried to read in django book but with little luck only. I hope someone have the answer or a good tutorial / page that can explain how this works. Thanks - Bobo --~--~-~--~~~---~--~~ 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: enforcing uniqueness
Hi Robin, On Thu, 2008-08-28 at 12:55 +0100, Robin Becker wrote: > My boss, created a model that represents an override to parts of other model > instances; Man, I gotta remember to use the "don't shoot me; my boss did it" reasoning some time. :-) > the business logic demands that the model instances should be > uniquely defined by two attributes a and b > > ie > > o1.a==o2.a and o1.b==o2.b <==> o1 is o2. > > I know that we can implement validation rules in the admin to ensure that > this > is so, but he prefers to merge an existing instance into the new version at > save > time and also delete the existing one. Is that in fact possible with django's > orm? > > I'm thinking of code somewhat like this > > def save(self): >P=list(Over.objects.exclude(id=self.id). > filter(a=self.a,b=self.b).order_by('id')) >if P: > for p in P: > self.merge(p) > p.delete() >super(Over, self).save() You'll have to write the merge() method yourself, since that's going to be domain specific (and also doesn't exist in Django). The rest of the code looks fine, although there are a couple of micro-improvements possible: (1) The order_by() call is unnecessary for what you're doing. (2) If you kept P as a queryset, instead of converting it to a list (just drop the list() call in the first line), you could write: for p in P: self.merge(p) P.delete() The delete call is then does as a single SQL statement. As with the order_by() call, this probably isn't a big deal, since I'd expect P will either be empty or contain only a very small number of elements. But wanted to make you aware there is a delete() method on querysets that does what you would expect. (3) You can drop the "if P:" test, since everything will work smoothly if P is empty (the results iterator of the queryset will return nothing and delete() does nothing on an empty queryset). Regards, Malcolm --~--~-~--~~~---~--~~ 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: Dictionary key-value pair
order is important for display, I am calculating sum and average on query objects and storing it in dictionary with key/values which are used in a template. So I have a dictionary something like this : {'name': user1, 'phone': 723872, 'Total Friends': 20, 'Avg Rating' : 3.6} so when I render I would these to appear in order. thanks! On Aug 28, 11:36 am, David Zhou <[EMAIL PROTECTED]> wrote: > On Aug 28, 2008, at 12:34 PM, saeb wrote: > > > I am using a dictionary to render a template. But my rendered > > template has the key-value pair which are out of order. Since > > dictionary uses a hash table to store it elements, I can't rely on > > order of these key-value pairs. Is there any other way to render > > bunch of key-value items from a view in a desired order? Thanks for > > help > > What are you trying to do, specifically? If order is important, why > bother with a key? Why not just store all the values in a list? > > --- > David Zhou > [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: Optimizing Django ORM SQL queries when in a loop
I'm going to give this a try. I'll let you know how I get on! Thanks guys! Mike. On Aug 27, 6:18 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > user_id_list=User.objects.filter(whatever).values_list('id', > flat=True) > posts=Post.objects.filter(user__id__in=user_id_list) > > Would that work? --~--~-~--~~~---~--~~ 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: request: auth_user User model, not enough characters in email
On Aug 28, 2008, at 8:17 AM, Bram de Jong wrote: > it's obviously a very small hack in the django source code, but it > would be nice if the email-field would have a few more characters. > I have a few pesky users who actually use my site and have a vry > long email address. If you have a recent version from trunk, you should be able to define your own length via max_length: http://docs.djangoproject.com/en/dev/ref/models/fields/#emailfield --- David Zhou [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: Dictionary key-value pair
On Aug 28, 2008, at 12:34 PM, saeb wrote: > I am using a dictionary to render a template. But my rendered > template has the key-value pair which are out of order. Since > dictionary uses a hash table to store it elements, I can't rely on > order of these key-value pairs. Is there any other way to render > bunch of key-value items from a view in a desired order? Thanks for > help What are you trying to do, specifically? If order is important, why bother with a key? Why not just store all the values in a list? --- David Zhou [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: Storing some media files on web server and some on external a/v server
On Aug 28, 2008, at 12:31 PM, [EMAIL PROTECTED] wrote: > What would be ideal for me to do is to be able to store the images > that are uploaded via the admin site on the main web server and then > the audio that we upload via the admin site onto the streaming media > server. > > Is this possible with Django, also if so is there any documentation > out there on how to set the servers up so I can pass that along to our > network admin set the servers up for me? You should be able assign a callable to the upload_to argument for FileFields: http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField Then you can write your own method that returns the proper path. --- David Zhou [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Dictionary key-value pair
I am using a dictionary to render a template. But my rendered template has the key-value pair which are out of order. Since dictionary uses a hash table to store it elements, I can't rely on order of these key-value pairs. Is there any other way to render bunch of key-value items from a view in a desired order? Thanks for help --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Storing some media files on web server and some on external a/v server
We have a web server here at work that is going to host all of our Django app stuff and the majority of our static media files (images, css, js, etc) and then we have a streaming media server where we store the audio of all of our courses. What would be ideal for me to do is to be able to store the images that are uploaded via the admin site on the main web server and then the audio that we upload via the admin site onto the streaming media server. Is this possible with Django, also if so is there any documentation out there on how to set the servers up so I can pass that along to our network admin set the servers up for me? thnx, --~--~-~--~~~---~--~~ 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: Forms problem?
Scott, that was the hint I needed. I had a default value of datetime.date.today instead of datetime.datetime.now. Strangely enough, the problem only manifested itself from within the admin interface, the ModelForms worked fine. Thanks, Greg On Aug 28, 11:40 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote: > Greg, it looks to me like you are storing a date value into a datetime > field. Consider the error: > > File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line 662, > > > in decompress > > return [value.date(), value.time().replace(microsecond=0)] > > > AttributeError: 'datetime.date' object has no attribute 'date' > > The Django code is trying to peel away the date and time values from the > value in the form field. But evidently the form field contains a > datetime.date, whereas Django is expecting a datetime.datetime. Does that > make sense? Perhaps you are passing in something like > "datetime.date.today()" where you should be passing in something like > "datetime.datetime.now()". Or else maybe your field really should be a date > field instead of a datetime field? > > -- Scott > > On Thu, Aug 28, 2008 at 11:35 AM, Greg Taylor <[EMAIL PROTECTED]>wrote: > > > > > > > Thanks for the tip. I replaced all of my from datetime import datetime > > istances, but it looks like this is still happening. The problem only > > manifested itself when I updated to the latest trunk. I was previously > > running a few revisions earlier than the signals refactoring. If you > > have any other ideas, I'm all ears, this is a bit of a showstopper for > > me. > > > Thanks! > > Greg > > > On Aug 28, 10:31 am, Daniel Roseman <[EMAIL PROTECTED]> > > wrote: > > > On Aug 28, 3:01 pm, Greg Taylor <[EMAIL PROTECTED]> wrote: > > > > > I'm getting the following error on some of my models with > > > > DateTimeFields. Any ideas? > > > > > Traceback (most recent call last): > > > > ... snip. ... > > > > > File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line > > > > 662, in decompress > > > > return [value.date(), value.time().replace(microsecond=0)] > > > > > AttributeError: 'datetime.date' object has no attribute 'date' > > > > This probably means that somewhere in your code you've done "from > > > datetime import datetime" rather than just "import datetime". > > > Annoyingly and confusingly, both the module and one of its classes are > > > called datetime. The *module* 'datetime' does have an attribute called > > > 'date', but the *class* 'datetime' does not. > > > > Basically, unless you have a very good reason, you should always use > > > "import datetime". > > > -- > > > DR. > > --http://scott.andstuff.org/|http://truthadorned.org/ --~--~-~--~~~---~--~~ 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: using File storage
> Chart.objects.create(xml=default_storage.save('data.xml', ContentFile(data))) ha, I was almost certain that django wouldn't make it as hard as I had explained it. :-D Glad to see it's this easy! Tim ^,^ --~--~-~--~~~---~--~~ 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: to_field in admin
On Thu, Aug 28, 2008 at 4:34 AM, chr <[EMAIL PROTECTED]> wrote: > > hi. i've got a model like this: > > class Inventory(models.Model): >barcode = models.PositiveIntegerField(unique=True) >parent = models.ForeignKey('self', to_field='barcode', blank=True, > null=True) >name = models.CharField(blank=False) > > and i get: > >>> i = Inventory.objects.get(barcode=115716) > >>> i > > >>> i.parent > > > which is fine. whereas in the admin the select-widget will have the > item selected whose id accidentally matches the barcode. i.e. the > values in the select-widget aren't the values from barcode but the pk. > Apple Mighty Mouse > > i couldn't find this behaviour in the admin documented anywhere. > > so, is the bug in my model, the lack of documentation or the admin? > > I believe it's a bug admin. I've opened a ticket: http://code.djangoproject.com/ticket/8648 Karen --~--~-~--~~~---~--~~ 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: using File storage
On Thu, Aug 28, 2008 at 11:44 AM, Jiri Barton <[EMAIL PROTECTED]> wrote: > I would like Django to take care of the file naming for me. I would > like to use a one-liner such as > > Chart.objects.create(xml=default_storage.save('data.xml', data)) You're nearly there for getting this to work, it's just the matter of how you're passing in the data. Try importing ContentFile from django.core.files.base, and using it like so: Chart.objects.create(xml=default_storage.save('data.xml', ContentFile(data))) > The example from > http://www.djangoproject.com/documentation/files/#storage-objects > does not work for me either: > from django.core.files.storage import default_storage > path = default_storage.save('/path/to/file', 'new content') > > This will give me > > : 'str' object has no attribute > 'chunks' Egad! Would you mind opening a ticket for this? That example is definitely wrong, and will need to be updated. -Gul --~--~-~--~~~---~--~~ 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: using File storage
iirc, you can use http://docs.python.org/lib/module-StringIO.html to have a file like object from a string, and use that to make your django File object ( http://www.djangoproject.com/documentation/files/#the-file-object ). There's probably a better way than this though so you might want to wait for other replies. import StringIO from django.core.files import File f = StringIO.StringIO() f.write(data) myfile = File(f) Chart.objects.create(xml=default_storage.save('data.xml', myfile)) Tim ^,^ On Thu, Aug 28, 2008 at 4:44 PM, Jiri Barton <[EMAIL PROTECTED]> wrote: > > What is the preferred way of storing generated content into file > models? > > class Chart(models.Model): >xml = models.FileField(upload_to='charts') >... > > I would like compute the image on the fly, using some data in the > database. How should I store the generated data? How should I use File > storage for this task? > > I would like Django to take care of the file naming for me. I would > like to use a one-liner such as > > Chart.objects.create(xml=default_storage.save('data.xml', data)) > > where data is a string, but that gives me > > AttributeError: 'str' object has no attribute 'chunks' > > The example from > http://www.djangoproject.com/documentation/files/#storage-objects > does not work for me either: > from django.core.files.storage import default_storage > path = default_storage.save('/path/to/file', 'new content') > > This will give me > > : 'str' object has no attribute > 'chunks' > > Should I use the class File directly? How? For File.save() to work, I > would need an associated an object. Please advise. > > Thank you > > > --~--~-~--~~~---~--~~ 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: use crypt algo for user passwords
thanks opend ticket #8647 On 28 Ago, 16:55, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > Hi Sam, > > I'm tring to figure out how to use crypt algorithm for user password. > > > looking at the code (http://code.djangoproject.com/browser/django/ > > trunk/django/contrib/auth/models.py) lin 175 there is no way to use > > other than sha1. > > You're right that algo='sha1' is hard coded in User.set_password(). > You've a couple of options: > > 1. Write your own function that's a copy of User.set_password() and > uses any of the other supported algorithms. You can keep this custom > function anywhere you like (it doesn't have to be a method on User). > It would take a User instance and an algorithm as its parameters and > do what the built-in method does. > > 2. You can open a ticket and suggest that algo='sha1' be moved to a > keyword argument of the built-in method User.set_password so that it > can be called with other values. But before you open the ticket, wait > a day or two to let other developers comment on whether there was a > deliberate decision to not expose algo as a user controllable > parameter. > > -Rajesh D --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Setting Modelform exclude field after post
Hi All, I exclude a field in modelform because the info is known. It's a Customer > 1-to-n > Project model setup. I get the following (1048, "Column 'customer_id' cannot be null") on a form.save() which is correct. But how do I put that customer_id back in the request.POST querydict? I'm messing with the appendlist() but it seems like dirty work at the moment. This is the clean method: def project_add(request, customer_id=''): customer = get_object_or_404(Customer, pk=customer_id) if request.method == 'POST': # here the customer_id needs to be put in somehow if form.is_valid(): form.save() request.user.message_set.create(message='Project created') return HttpResponseRedirect('/myapp/project') else: form = ProjectForm() return render_to_response(template+'/project_add.html', {'form': form, 'customer': customer}) Can anybody help me out? Thanx! Gerard. -- urls = { 'fun': 'www.zonderbroodje.nl', 'tech': 'www.gp-net.nl' } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
using File storage
What is the preferred way of storing generated content into file models? class Chart(models.Model): xml = models.FileField(upload_to='charts') ... I would like compute the image on the fly, using some data in the database. How should I store the generated data? How should I use File storage for this task? I would like Django to take care of the file naming for me. I would like to use a one-liner such as Chart.objects.create(xml=default_storage.save('data.xml', data)) where data is a string, but that gives me AttributeError: 'str' object has no attribute 'chunks' The example from http://www.djangoproject.com/documentation/files/#storage-objects does not work for me either: >>> from django.core.files.storage import default_storage >>> path = default_storage.save('/path/to/file', 'new content') This will give me : 'str' object has no attribute 'chunks' Should I use the class File directly? How? For File.save() to work, I would need an associated an object. Please advise. Thank you --~--~-~--~~~---~--~~ 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: Forms problem?
Greg, it looks to me like you are storing a date value into a datetime field. Consider the error: File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line 662, > in decompress > return [value.date(), value.time().replace(microsecond=0)] > > AttributeError: 'datetime.date' object has no attribute 'date' > The Django code is trying to peel away the date and time values from the value in the form field. But evidently the form field contains a datetime.date, whereas Django is expecting a datetime.datetime. Does that make sense? Perhaps you are passing in something like "datetime.date.today()" where you should be passing in something like "datetime.datetime.now()". Or else maybe your field really should be a date field instead of a datetime field? -- Scott On Thu, Aug 28, 2008 at 11:35 AM, Greg Taylor <[EMAIL PROTECTED]>wrote: > > Thanks for the tip. I replaced all of my from datetime import datetime > istances, but it looks like this is still happening. The problem only > manifested itself when I updated to the latest trunk. I was previously > running a few revisions earlier than the signals refactoring. If you > have any other ideas, I'm all ears, this is a bit of a showstopper for > me. > > Thanks! > Greg > > On Aug 28, 10:31 am, Daniel Roseman <[EMAIL PROTECTED]> > wrote: > > On Aug 28, 3:01 pm, Greg Taylor <[EMAIL PROTECTED]> wrote: > > > > > I'm getting the following error on some of my models with > > > DateTimeFields. Any ideas? > > > > > Traceback (most recent call last): > > > > ... snip. ... > > > > > File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line > > > 662, in decompress > > >return [value.date(), value.time().replace(microsecond=0)] > > > > > AttributeError: 'datetime.date' object has no attribute 'date' > > > > This probably means that somewhere in your code you've done "from > > datetime import datetime" rather than just "import datetime". > > Annoyingly and confusingly, both the module and one of its classes are > > called datetime. The *module* 'datetime' does have an attribute called > > 'date', but the *class* 'datetime' does not. > > > > Basically, unless you have a very good reason, you should always use > > "import datetime". > > -- > > DR. > > > -- http://scott.andstuff.org/ | http://truthadorned.org/ --~--~-~--~~~---~--~~ 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: Forms problem?
Thanks for the tip. I replaced all of my from datetime import datetime istances, but it looks like this is still happening. The problem only manifested itself when I updated to the latest trunk. I was previously running a few revisions earlier than the signals refactoring. If you have any other ideas, I'm all ears, this is a bit of a showstopper for me. Thanks! Greg On Aug 28, 10:31 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Aug 28, 3:01 pm, Greg Taylor <[EMAIL PROTECTED]> wrote: > > > I'm getting the following error on some of my models with > > DateTimeFields. Any ideas? > > > Traceback (most recent call last): > > ... snip. ... > > > File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line > > 662, in decompress > > return [value.date(), value.time().replace(microsecond=0)] > > > AttributeError: 'datetime.date' object has no attribute 'date' > > This probably means that somewhere in your code you've done "from > datetime import datetime" rather than just "import datetime". > Annoyingly and confusingly, both the module and one of its classes are > called datetime. The *module* 'datetime' does have an attribute called > 'date', but the *class* 'datetime' does not. > > Basically, unless you have a very good reason, you should always use > "import datetime". > -- > DR. --~--~-~--~~~---~--~~ 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: ModelForm - Required Fields
Anyone else ever do anything like this? On Aug 26, 10:13 pm, lingrlongr <[EMAIL PROTECTED]> wrote: > Is there a way for me to quickly make certain fields in a ModelForm > class required. I know this looks back to the model for that > information... > > In my case I'm using a FormWizard to display a series of forms. The > fields shows in some steps are dependent on answers to previous > questions. So, in my model, sometimes a field will be required, > sometimes not. Therefore, I'm looking for the form to validate that > part. > > I know I can just list the fields like this: > > class MyForm(ModelForm): > my_field = forms.CharField(max_length=80, choices=MY_CHOICES, > required=True) > ...etc... > > ...but I don't want to have to repeat all the stuff that just > "happens" automatically... > > Keith --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Generate admin files. Views and Templates with Django?
I'm a Rails switcher to Django. In Rails there's an option to generate all the scaffold files, ie, there's a command line script that creates all the files in the project folder of the admin interface. I want to know if there's something similar for Django. Thanks --~--~-~--~~~---~--~~ 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: use crypt algo for user passwords
Hi Sam, I'm tring to figure out how to use crypt algorithm for user password. > looking at the code (http://code.djangoproject.com/browser/django/ > trunk/django/contrib/auth/models.py) lin 175 there is no way to use > other than sha1. You're right that algo='sha1' is hard coded in User.set_password(). You've a couple of options: 1. Write your own function that's a copy of User.set_password() and uses any of the other supported algorithms. You can keep this custom function anywhere you like (it doesn't have to be a method on User). It would take a User instance and an algorithm as its parameters and do what the built-in method does. 2. You can open a ticket and suggest that algo='sha1' be moved to a keyword argument of the built-in method User.set_password so that it can be called with other values. But before you open the ticket, wait a day or two to let other developers comment on whether there was a deliberate decision to not expose algo as a user controllable parameter. -Rajesh D --~--~-~--~~~---~--~~ 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: problem passing var to template tag
Ah, yes, thank you... must have missed that somehow. Guess I didn't read all the way down. Much appreciated. -Chris On Aug 28, 10:42 am, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 28 août, 13:59, flynnguy <[EMAIL PROTECTED]> wrote: > > > I'm trying to get a list of photos so I can then go through a list. I > > have the template tag working if I hard code a value but I want to > > pass an id to it. So here's the relevant parts of my template tag: > > class PetPhotoListObject(template.Node): > > def __init__(self, pet_id): > > self.pet_id_var = template.Variable(pet_id) > > > def render(self, context): > > pet_id = self.pet_id_var.resolve(context) > context['photo_list'] = Media.objects.filter(pet__id=pet_id) > > > return '' > > (snip) > > > Anyone have a clue what I'm doing wrong? > > Failed to read the FineManual, I'd > say:http://www.djangoproject.com/documentation/templates_python/#passing-... > > HTH --~--~-~--~~~---~--~~ 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: intpoint filter
I use similar functions for some of my template filters, but I use locale instead. import locale locale.setlocale(locale.LC_ALL, '') def whole_currency(value): return locale.format_string("$%0.f", value, grouping=True) def decimal_currency(value): return locale.format_string("$%0.2f", value, grouping=True) keith On Thu, Aug 28, 2008 at 10:12 AM, Nicola Murino <[EMAIL PROTECTED]>wrote: > > I think for european user an intpoint function in contrib.humanize > would be very useful > > here is the code (copied from intcomma) > > def intpoint(value): >""" >Converts an integer to a string containing commas every three > digits. >For example, 3000 becomes '3,000' and 45000 becomes '45,000'. >""" >orig = force_unicode(value) >new = re.sub("^(-?\d+)(\d{3})", '\g<1>.\g<2>', orig) >if orig == new: >return new >else: >return intpoint(new) > intpoint.is_safe = True > register.filter(intpoint) > > regards > Nicola > > > > --~--~-~--~~~---~--~~ 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: intpoint filter
On 28 Ago, 16:47, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > Hi Nicola, > > On Aug 28, 10:12 am, Nicola Murino <[EMAIL PROTECTED]> wrote: > > > > > I think for european user an intpoint function in contrib.humanize > > would be very useful > > > here is the code (copied from intcomma) > > > def intpoint(value): > > """ > > Converts an integer to a string containing commas every three > > digits. > > For example, 3000 becomes '3,000' and 45000 becomes '45,000'. > > """ > > orig = force_unicode(value) > > new = re.sub("^(-?\d+)(\d{3})", '\g<1>.\g<2>', orig) > > if orig == new: > > return new > > else: > > return intpoint(new) > > intpoint.is_safe = True > > register.filter(intpoint) > > Consider opening a ticket and submitting this as a patch to > contrib.humanize. > (Read this doc for tips before you open the > ticket:http://www.djangoproject.com/documentation/contributing/) > > Also, there are probably other ways to incorporate this into humanize. > For instance: > > 1. the separator (comma, point, etc.) could be a setting > 2. the separator could be a function of the request's LANGUAGE_CODE > 3. instead of a second filter, the separator could be passed in as a > filter argument to the existing filter (with a default of comma.) > 4. the regex could also be a function of the LANGUAGE_CODE > you are right > Once you open this feature request ticket, the best ways to > incorporate this can be discussed. http://code.djangoproject.com/ticket/8557 seems this feature will not be in 1.0 , thanks Nicola > > -Rajesh D --~--~-~--~~~---~--~~ 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: intpoint filter
Hi Nicola, On Aug 28, 10:12 am, Nicola Murino <[EMAIL PROTECTED]> wrote: > I think for european user an intpoint function in contrib.humanize > would be very useful > > here is the code (copied from intcomma) > > def intpoint(value): > """ > Converts an integer to a string containing commas every three > digits. > For example, 3000 becomes '3,000' and 45000 becomes '45,000'. > """ > orig = force_unicode(value) > new = re.sub("^(-?\d+)(\d{3})", '\g<1>.\g<2>', orig) > if orig == new: > return new > else: > return intpoint(new) > intpoint.is_safe = True > register.filter(intpoint) > Consider opening a ticket and submitting this as a patch to contrib.humanize. (Read this doc for tips before you open the ticket: http://www.djangoproject.com/documentation/contributing/) Also, there are probably other ways to incorporate this into humanize. For instance: 1. the separator (comma, point, etc.) could be a setting 2. the separator could be a function of the request's LANGUAGE_CODE 3. instead of a second filter, the separator could be passed in as a filter argument to the existing filter (with a default of comma.) 4. the regex could also be a function of the LANGUAGE_CODE Once you open this feature request ticket, the best ways to incorporate this can be discussed. -Rajesh D --~--~-~--~~~---~--~~ 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: problem passing var to template tag
On 28 août, 13:59, flynnguy <[EMAIL PROTECTED]> wrote: > I'm trying to get a list of photos so I can then go through a list. I > have the template tag working if I hard code a value but I want to > pass an id to it. So here's the relevant parts of my template tag: > class PetPhotoListObject(template.Node): > def __init__(self, pet_id): self.pet_id_var = template.Variable(pet_id) > def render(self, context): pet_id = self.pet_id_var.resolve(context) context['photo_list'] = Media.objects.filter(pet__id=pet_id) > return '' (snip) > Anyone have a clue what I'm doing wrong? Failed to read the FineManual, I'd say: http://www.djangoproject.com/documentation/templates_python/#passing-template-variables-to-the-tag HTH --~--~-~--~~~---~--~~ 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: Forms problem?
On Aug 28, 3:01 pm, Greg Taylor <[EMAIL PROTECTED]> wrote: > I'm getting the following error on some of my models with > DateTimeFields. Any ideas? > > Traceback (most recent call last): > ... snip. ... > > File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line > 662, in decompress > return [value.date(), value.time().replace(microsecond=0)] > > AttributeError: 'datetime.date' object has no attribute 'date' This probably means that somewhere in your code you've done "from datetime import datetime" rather than just "import datetime". Annoyingly and confusingly, both the module and one of its classes are called datetime. The *module* 'datetime' does have an attribute called 'date', but the *class* 'datetime' does not. Basically, unless you have a very good reason, you should always use "import datetime". -- DR. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---