Re: Does Django have a function that can be called by every view function ?
On Mon, Dec 1, 2008 at 2:23 AM, David Shieh <[EMAIL PROTECTED]> wrote: > I dont' know whether this make any sense . > Right now , I can't test it , but if django won't initiate the > views.py as a class , this method will make no sense. Why not write a decorator? --- 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: Usage of {% url %}
On Sun, 2008-11-30 at 23:42 -0800, Roy wrote: > Hi, > > I have the following in one of my templates: > Flag > > But I'm getting a TemplateSyntaxError: > > Caught an exception while rendering: Reverse for 'mysite.comments- > flag' with arguments '(, '')' > and keyword arguments '{}' not found > > The named url "comments-flag" comes from > django.contrib.comments.urls.py: > > url(r'^flag/(\d+)/$','moderation.flag', name='comments- > flag'), This URL pattern only accepts a single parameter (an integer). You are passing in two parameters, so it won't match this pattern. The fact that your view takes an option second parameter is irrelevant to this situation, since Django is only comparing against the regular expression pattern. I'm guessing a little bit, but it looks like (from the name) that you're wanting the second parameter to be used as a query string in the resulting URL. The "url" template tag cannot construct URLs that use querystrings like that. You would need to write your own tag that knew to use the first N parameters in a call to reverse() to construct the first portion of the URL and then the remaining parameters were used to construct the query string. 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: Does Django have a function that can be called by every view function ?
I have found a post in here : http://davyd.livejournal.com/262859.html this is the way this author resolves this problem. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Usage of {% url %}
Hi, I have the following in one of my templates: Flag But I'm getting a TemplateSyntaxError: Caught an exception while rendering: Reverse for 'mysite.comments- flag' with arguments '(, '')' and keyword arguments '{}' not found The named url "comments-flag" comes from django.contrib.comments.urls.py: url(r'^flag/(\d+)/$','moderation.flag', name='comments- flag'), Checking moderation.flag, the signature is: def flag(request, comment_id, next=None) Shouldn't it work? I tried using named parameters also, same error. It works if I remove the 2nd argument, passing comment.id only, but shouldn't I be able to specify the "next" parameter? Thanks! Roy --~--~-~--~~~---~--~~ 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 can I to show a 2D dictionary in template ?
Oh, I got it! {% for content_id, content in contents.items %} {{ content.title }} {{ content.type }} {{ content.relative }} {% endfor %} On Dec 1, 3:32 pm, "K*K" <[EMAIL PROTECTED]> wrote: > Hi, I'm a newbie in Django. I got I problem looks like below: > > == contents.py == > > from testcms.contents.models import * > > class Contents(UserDict): > def get_contents_list(self): > > contents = Contents.objects.all() > for content in contents: > author = Users.objects.get(userid = content.author_id) > type = ContentTypes.objects.get(type_id = content.type_id) > relative = ContentsRelative.objects.filter(content_id = > content.content_id).count() > > self[content.id] = { > 'content_id' : content.id, > 'title' : content.name, > 'type' : type.name, > 'relative' : relative, > } > > return self > > === views.py == > > def contents_list(request): > content = Contents() > contents = content.get_contents_list() > > return render_to_response("show.html", {'contents' : contents}) > > === show.html = > > {% for content in contents %} > {{ > content.title }} > content.type > content.relative > > {% endfor %} > > = > > The data struct of content is like: > > {346L: {'type': u'Function', 'relative': 0, 'content_id': 346L, > 'title': u'Config Diff Interface'}} > > But when I run my program, it report: > > TemplateSyntaxError at /plans/ > Caught an exception while rendering: 0 > > Original Traceback (most recent call last): > File "/Library/Python/2.5/site-packages/Django-1.0_final-py2.5.egg/ > django/template/debug.py", line 71, in render_node > result = node.render(context) > File "/Library/Python/2.5/site-packages/Django-1.0_final-py2.5.egg/ > django/template/defaulttags.py", line 130, in render > for i, item in enumerate(values): > File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/UserDict.py", line 22, in __getitem__ > raise KeyError(key) > KeyError: 0 > > How can I use 2D dictionary data struct like upon in tempmlate ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How can I to show a 2D dictionary in template ?
Hi, I'm a newbie in Django. I got I problem looks like below: == contents.py == from testcms.contents.models import * class Contents(UserDict): def get_contents_list(self): contents = Contents.objects.all() for content in contents: author = Users.objects.get(userid = content.author_id) type = ContentTypes.objects.get(type_id = content.type_id) relative = ContentsRelative.objects.filter(content_id = content.content_id).count() self[content.id] = { 'content_id' : content.id, 'title' : content.name, 'type' : type.name, 'relative' : relative, } return self === views.py == def contents_list(request): content = Contents() contents = content.get_contents_list() return render_to_response("show.html", {'contents' : contents}) === show.html = {% for content in contents %} {{ content.title }} content.type content.relative {% endfor %} = The data struct of content is like: {346L: {'type': u'Function', 'relative': 0, 'content_id': 346L, 'title': u'Config Diff Interface'}} But when I run my program, it report: TemplateSyntaxError at /plans/ Caught an exception while rendering: 0 Original Traceback (most recent call last): File "/Library/Python/2.5/site-packages/Django-1.0_final-py2.5.egg/ django/template/debug.py", line 71, in render_node result = node.render(context) File "/Library/Python/2.5/site-packages/Django-1.0_final-py2.5.egg/ django/template/defaulttags.py", line 130, in render for i, item in enumerate(values): File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/UserDict.py", line 22, in __getitem__ raise KeyError(key) KeyError: 0 How can I use 2D dictionary data struct like upon in tempmlate ? --~--~-~--~~~---~--~~ 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: Does Django have a function that can be called by every view function ?
No , not in that way. Let me show you some code #a.py class A: def __init__(self): #do somthing #views.py class B(A): def index(request): #do something else #urls.py (r'^$', 'site.app.views.index'), I dont' know whether this make any sense . Right now , I can't test it , but if django won't initiate the views.py as a class , this method will make no sense. On Dec 1, 2:52 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2008-11-30 at 22:46 -0800, David Shieh wrote: > > yeah , I will consider about middleware , and I am also thinking about > > write a class that contains the functions I need , and other funcions > > just inherit it , will it work ? > > Since functions don't inherit from classes, your question doesn't really > make sense. > > 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: Does Django have a function that can be called by every view function ?
On Sun, 2008-11-30 at 22:46 -0800, David Shieh wrote: > yeah , I will consider about middleware , and I am also thinking about > write a class that contains the functions I need , and other funcions > just inherit it , will it work ? Since functions don't inherit from classes, your question doesn't really make sense. 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: djangobook.com, chapter 5, __init__() got an unexpected keyword argument 'maxlength'
On Mon, Dec 1, 2008 at 2:04 PM, djan <[EMAIL PROTECTED]> wrote: > > Hello, > > I'm following along with djangobook.com, and I have a problem in > chapter 5 that I cannot resolve. I am using OpenSuSE-11.0, Python > 2.5.2, sqlite3-3.5.7-17.1 (and incidentally, this same error occurs > with MySQL). > TypeError: __init__() got an unexpected keyword argument 'maxlength' The Django book is based on Django Version 0.96; we have since released Version 1.0, which introduced a few backwards incompatibilities - in this case, the 'maxlength' was renamed to 'max_length' for consistency with other parts of Django. A guide to porting 0.96 applications to 1.0 can be found here: http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/ A full list of backwards incompatibilities between version 0.96 and 1.0 can be found here: http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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: djangobook.com, chapter 5, __init__() got an unexpected keyword argument 'maxlength'
On Sun, 2008-11-30 at 21:04 -0800, djan wrote: > Hello, > > I'm following along with djangobook.com, and I have a problem in > chapter 5 that I cannot resolve. I am using OpenSuSE-11.0, Python > 2.5.2, sqlite3-3.5.7-17.1 (and incidentally, this same error occurs > with MySQL). The Django book was writting for Django 0.96. There have been a number of backwards-incompatible changed in the period between that and Django 1.0 (which is why we held off calling earlier versions 1.0: 1.0 provides quite good backwards compatibility assurances). You'll need to read the book in conjunction with this document: http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/ (and the pages it links to). 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: Does Django have a function that can be called by every view function ?
yeah , I will consider about middleware , and I am also thinking about write a class that contains the functions I need , and other funcions just inherit it , will it work ? On Dec 1, 2:41 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2008-11-30 at 22:35 -0800, David Shieh wrote: > > Hi , Malcolm, > > > Now , I understand what you said.But using session means user must to > > call a certain to set the session. > > I was using session as an *example*. It's something that, based on > incoming request information, is run every time and can do some extra > processing. It's an example of how to abstract away that processing from > the view functions. > > > Maybe Django should learn from other frameworks to get a action system > > to handle this. > > You keep operating on the assumption that it doesn't exist, but that > seems to be because you're locked into it being a way to pass extra > parameters to a view. Django already has such a system. It's called > middleware. > > 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 -~--~~~~--~~--~--~---
djangobook.com, chapter 5, __init__() got an unexpected keyword argument 'maxlength'
Hello, I'm following along with djangobook.com, and I have a problem in chapter 5 that I cannot resolve. I am using OpenSuSE-11.0, Python 2.5.2, sqlite3-3.5.7-17.1 (and incidentally, this same error occurs with MySQL). When I run the following: $ python manage.py validate I receive: Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/usr/local/lib64/python2.5/site-packages/django/core/ management/__init__.py", line 340, in execute_manager utility.execute() File "/usr/local/lib64/python2.5/site-packages/django/core/ management/__init__.py", line 295, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib64/python2.5/site-packages/django/core/ management/base.py", line 192, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/local/lib64/python2.5/site-packages/django/core/ management/base.py", line 219, in execute output = self.handle(*args, **options) File "/usr/local/lib64/python2.5/site-packages/django/core/ management/base.py", line 348, in handle return self.handle_noargs(**options) File "/usr/local/lib64/python2.5/site-packages/django/core/ management/commands/validate.py", line 9, in handle_noargs self.validate(display_num_errors=True) File "/usr/local/lib64/python2.5/site-packages/django/core/ management/base.py", line 246, in validate num_errors = get_validation_errors(s, app) File "/usr/local/lib64/python2.5/site-packages/django/core/ management/validation.py", line 28, in get_validation_errors for (app_name, error) in get_app_errors().items(): File "/usr/local/lib64/python2.5/site-packages/django/db/models/ loading.py", line 128, in get_app_errors self._populate() File "/usr/local/lib64/python2.5/site-packages/django/db/models/ loading.py", line 57, in _populate self.load_app(app_name, True) File "/usr/local/lib64/python2.5/site-packages/django/db/models/ loading.py", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File "$HOME/djcode/mysite/books/models.py", line 3, in class Publisher(models.Model): File "$HOME/djcode/mysite/books/models.py", line 4, in Publisher name = models.CharField(maxlength=30) TypeError: __init__() got an unexpected keyword argument 'maxlength' I've copied and pasted the examples for models.py as on the website, and I have the following in settings.py: DATABASE_ENGINE = 'sqlite3' DATABASE_NAME = '$HOME/djcode/prototype.sqlite' # DATABASE_USER = '' # Not used with sqlite3. # DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' Any thoughts? Thanks in advance for any 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 -~--~~~~--~~--~--~---
Re: Does Django have a function that can be called by every view function ?
On Sun, 2008-11-30 at 22:35 -0800, David Shieh wrote: > Hi , Malcolm, > > Now , I understand what you said.But using session means user must to > call a certain to set the session. I was using session as an *example*. It's something that, based on incoming request information, is run every time and can do some extra processing. It's an example of how to abstract away that processing from the view functions. > Maybe Django should learn from other frameworks to get a action system > to handle this. You keep operating on the assumption that it doesn't exist, but that seems to be because you're locked into it being a way to pass extra parameters to a view. Django already has such a system. It's called middleware. 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: Does Django have a function that can be called by every view function ?
Hi , Malcolm, Now , I understand what you said.But using session means user must to call a certain to set the session.I mean , for example , I am setting up a blog , and every page want to show the categories this blog have . If I write these categories as a session value , I have to write it into the index function ,and when a user visit the index page , he will get it ,and no matter which page he visit , he will also get this value . However , the problem is , what if he firstly visit one of the other article page , maybe he just get the url for some page , so , he won't get the categories value , cause he didn't visit the index page , am I right ? Maybe Django should learn from other frameworks to get a action system to handle this. Indeed , I really need your help with this . Thanks On Dec 1, 2:22 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2008-11-30 at 21:48 -0800, David Shieh wrote: > > Thanks , Malcolm , > > > I think your solution can resolve my problem.But does it a bit > > complex ? > > In fact , what I really want is a view function that will be called by > > every view function. > > i.e. , if I wrote an auth system , I need to authenticate whether the > > user is logged in every view functions and pass some parameters to > > every views function . > > > Any suggestions ? > > You'll end up dispatching every URL to the same view and then > essentially building your own dispatcher to further dispatch to the > "real" view functions. Or attach a decorator to those views you want > this to happen to. > > Because, the point is, you rarely want such a thing to run for *every* > view function. In any significantly sized application, there is rarely > common stuff that runs for every single view that cannot be done via > middleware. You're already receiving a request object in your functions, > you can pass in extra parameters through that (just like we do with > request.session, etc). > > In other words, the functionality already exists. It's spelled slightly > differently to other frameworks, but that's pretty normal -- everybody > has slightly different ways of writing the same thing. > > The option you are looking for is middleware. If you don't want to use > that, that's fine and writing a wrapper to make it all automatic is > obviously possible. But it's not shipped with Django, since we already > provide one way to achieve this functionality. > > 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: Template engine reads OS locale (?) and expects comma instead of decimal point in floatformat
Hi again Malcolm, I've now performed some of the test you suggest here, and I would like to report my findings. > > It seems to me that when the Python renderer sees the Decimal() call, > > it goes and fetches my OS locale, which calls for Swedish decimal > > commas instead of US decimal points. > > This doesn't seem to be the case from looking at the source. The decimal > module in Python is purely Python code and it doesn't call any of the > locale functions Yes, you are right. According to my findings reported below, it is not the Decimal that is causing my problem. It rather seems to be something happening deeper in the pymssql code while the value rendered as Decimal is processed. > I'd personally be a little suspicious of what the database backend is > doing. Is the type of your id column really something that can only be > represented by a Decimal() class? Because if it's an integer, the db > backend should be returning an integer there (that's a secondary bug, > but it makes me suspicious about what else is going on). The table value type is BIGINT, and as I learned from the pymssql documentation this is rendered as a Decimal. > Try comparing the output of locale.localeconv() before and after you > make the call to the database, for example. It shouldn't change and > everything should be operating in the C locale (since the external > locale of your system isn't applied unless something calls > locale.setlocale(locale.LC_ALL, '')). I could imagine some code that > tries to be "helpful" and changes the locale for whatever reason and > messes everything else up. OK, so now I checked on the locale before and after the database call and also checked with a hardcoded list emulating the return values from the database call, including the Decimal. As far as I can see there was NO changes in locale in either case, and the hardcoded Decimal didn't affect the behaviour of the template floatformat. So my assumption that Decimal affects the locale is thus wrong (as I believe you have been trying to tell me all the time). Here is a list of test outputs on my web page for various scenarios: Before database call >From database: [] Locale: {'mon_decimal_point': '', 'int_frac_digits': 127, 'p_sep_by_space': 127, 'frac_digits': 127, 'thousands_sep': '', 'n_sign_posn': 127, 'decimal_point': '.', 'int_curr_symbol': '', 'n_cs_precedes': 127, 'p_sign_posn': 127, 'mon_thousands_sep': '', 'negative_sign': '', 'currency_symbol': '', 'n_sep_by_space': 127, 'mon_grouping': [], 'p_cs_precedes': 127, 'positive_sign': '', 'grouping': []} Hardcoded variable: 678.9 Hardcoded variable through floatformat: 678.9 After database call >From database: [(Decimal("27164771"), 27, 16, 7.77128, 9.25572002, 2006, 'Quantum dynamics of a d-wave Josephson junction', 3, 30.0, '000234546300030', 17.601243339253998, '@', 7)] Locale: {'mon_decimal_point': '', 'int_frac_digits': 127, 'p_sep_by_space': 127, 'frac_digits': 127, 'thousands_sep': '', 'n_sign_posn': 127, 'decimal_point': '.', 'int_curr_symbol': '', 'n_cs_precedes': 127, 'p_sign_posn': 127, 'mon_thousands_sep': '', 'negative_sign': '', 'currency_symbol': '', 'n_sep_by_space': 127, 'mon_grouping': [], 'p_cs_precedes': 127, 'positive_sign': '', 'grouping': []} Hardcoded variable: 678,90 (sending 668.90 raises template error in floatformat) Hardcoded variable through floatformat: After hardcoded results list Hardcoded: [(Decimal("27164771"), 27, 16, 7.77128, 9.25572002, 2006, 'Quantum dynamics of a d-wave Josephson junction', 3, 30.0, '000234546300030', 17.601243339253998, '@', 7)] Locale: {'mon_decimal_point': '', 'int_frac_digits': 127, 'p_sep_by_space': 127, 'frac_digits': 127, 'thousands_sep': '', 'n_sign_posn': 127, 'decimal_point': '.', 'int_curr_symbol': '', 'n_cs_precedes': 127, 'p_sign_posn': 127, 'mon_thousands_sep': '', 'negative_sign': '', 'currency_symbol': '', 'n_sep_by_space': 127, 'mon_grouping': [], 'p_cs_precedes': 127, 'positive_sign': '', 'grouping': []} Hardcoded variable through: 678.90 Hardcoded variable through floatformat: 678.9 After doing those tests, I realised that if our database BIGINT was a problem for pymssql, I could try to change the data type for the value returned. So I convoluted the record ID in a Transact-SQL CAST statement, converting it to a INT and then I got a proper integer returned and all my problems went away. Here is the web page result: After doing CAST AS INT --- SQL: SELECT CAST(Artikel.ID AS INT), ... FROM Artikel ... >From database: [(27164771, 27, 16, 7.77128, 9.25572002, 2006, 'Quantum dynamics of a d-wave Josephson junction', 3, 30.0, '000234546300030', 17.601243339253998, '@', 7)] Locale: {'mon_decimal_point': '', 'int_frac_digits': 127, 'p_sep_by_space': 127, 'frac_digits': 127, 'thousands_sep': '', 'n_sign_posn': 127, 'decimal_point': '.', 'int_curr_symbol': '', 'n_cs_precedes': 127,
OpenId
I have been looking into using OpenId and I discovered that there are to 2 django libraries that handle this: django_openId and django_authopenid. Any opinions on the two? Not sure which one I should go with. --~--~-~--~~~---~--~~ 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: Does Django have a function that can be called by every view function ?
On Sun, 2008-11-30 at 21:48 -0800, David Shieh wrote: > Thanks , Malcolm , > > I think your solution can resolve my problem.But does it a bit > complex ? > In fact , what I really want is a view function that will be called by > every view function. > i.e. , if I wrote an auth system , I need to authenticate whether the > user is logged in every view functions and pass some parameters to > every views function . > > Any suggestions ? You'll end up dispatching every URL to the same view and then essentially building your own dispatcher to further dispatch to the "real" view functions. Or attach a decorator to those views you want this to happen to. Because, the point is, you rarely want such a thing to run for *every* view function. In any significantly sized application, there is rarely common stuff that runs for every single view that cannot be done via middleware. You're already receiving a request object in your functions, you can pass in extra parameters through that (just like we do with request.session, etc). In other words, the functionality already exists. It's spelled slightly differently to other frameworks, but that's pretty normal -- everybody has slightly different ways of writing the same thing. The option you are looking for is middleware. If you don't want to use that, that's fine and writing a wrapper to make it all automatic is obviously possible. But it's not shipped with Django, since we already provide one way to achieve this functionality. 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: Does Django have a function that can be called by every view function ?
On Sun, Nov 30, 2008 at 11:48 PM, David Shieh <[EMAIL PROTECTED]> wrote: > I think your solution can resolve my problem.But does it a bit > complex ? > In fact , what I really want is a view function that will be called by > every view function. > i.e. , if I wrote an auth system , I need to authenticate whether the > user is logged in every view functions and pass some parameters to > every views function . Perhaps it would be a good idea at this point to read Django's middleware documentation, to get a feel for how that works and how you might put it to use? -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: Does Django have a function that can be called by every view function ?
Thanks , Malcolm , I think your solution can resolve my problem.But does it a bit complex ? In fact , what I really want is a view function that will be called by every view function. i.e. , if I wrote an auth system , I need to authenticate whether the user is logged in every view functions and pass some parameters to every views function . Any suggestions ? On Dec 1, 11:49 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2008-11-30 at 19:41 -0800, David Shieh wrote: > > [...] > > > I have searched for some information . I know that middleware can do > > this , but what I really want is just a small function for this . > > A process_request() function in middleware can be as small as you like. > Middleware provides the hooks for functions that run before and/or after > each view function. It's exactly what you're asking about and you > haven't explained why they don't do what you want. > > 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: Does Django have a function that can be called by every view function ?
On Sun, 2008-11-30 at 19:41 -0800, David Shieh wrote: [...] > I have searched for some information . I know that middleware can do > this , but what I really want is just a small function for this . A process_request() function in middleware can be as small as you like. Middleware provides the hooks for functions that run before and/or after each view function. It's exactly what you're asking about and you haven't explained why they don't do what you want. 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: how to deploy css and images with apache
It is a very correct suggestion,Thank you! On 12月1日, 上午1时49分, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Nov 30, 5:26 pm, l0he1g <[EMAIL PROTECTED]> wrote: > > > Hi,everyone,this is a beginner's first post,after a long,tired search > > here and there without any solution. > > I use apache+mod_python on windows,The problem is the css and images > > does't be imported anyway,as I did what "How to use Django with Apache > > and mod_python" told inhttp://docs.djangoproject.com/. > > > > > > > > I'm guessing your problem lies here. You haven't used an initial > slash, so the browser is looking for a path relative to your Django > page's URL. Try > > and see if that works. > > -- > 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 -~--~~~~--~~--~--~---
Does Django have a function that can be called by every view function ?
I have used Django for several months , and it really attacts me . I love it. But when I use it more , I found a problem troubles me , that is , I can't find a way to make a function be called by every view function automatically . I used CakePHP , it have a function named beforeFilter() . It will be called everytime before the action excute . That is , when a user calles an action , this beforeFilter() fucntion is called by CakePHP automatically , very convenient. So I think , does Django have the same function like CakePHP ? And as I know , other frameworks also have the same function , like RoR . I have searched for some information . I know that middleware can do this , but what I really want is just a small function for this . So , guys , please help me with this , 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: Error was: 'module' object has no attribute 'Form'
On Sun, 2008-11-30 at 16:25 -0800, Andrew Arrow wrote: > Trying to get the example from > > http://docs.djangoproject.com/en/dev/topics/forms/ > > to work. I copied and pasted: > > from django import forms > > class ContactForm(forms.Form): > subject = forms.CharField(max_length=100) > message = forms.CharField() > sender = forms.EmailField() > cc_myself = forms.BooleanField(required=False) > > but get this error everytime: > > ViewDoesNotExist at / > Tried main in module myapp.main.views. Error was: 'module' object has > no attribute 'Form' Are you sure you're using Django 1.0? Because that should work perfectly. At a minimum, you can try this sort of test: `--> ./manage.py shell [...banner snipped...] In [1]: from django import forms In [2]: forms.Form Out[2]: If that doesn't work, you are running an old version of Django by mistake. 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 -~--~~~~--~~--~--~---
Error was: 'module' object has no attribute 'Form'
Trying to get the example from http://docs.djangoproject.com/en/dev/topics/forms/ to work. I copied and pasted: from django import forms class ContactForm(forms.Form): subject = forms.CharField(max_length=100) message = forms.CharField() sender = forms.EmailField() cc_myself = forms.BooleanField(required=False) but get this error everytime: ViewDoesNotExist at / Tried main in module myapp.main.views. Error was: 'module' object has no attribute 'Form' any ideas? 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: how to deploy css and images with apache
Thank you a lot ,I think I have solved it,by add the following to httpd.conf: Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all I think the docs of django who said " would be meaningless here." is misleading a lot. On 12月1日, 上午10时03分, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2008-11-30 at 17:57 -0800, l0he1g wrote: > > I am sorry adding a initial slash doesn't solve this problem,but thank > > you for the same. > > when I gethttp://localhost/staticdirectly in browser,arise a 403 > > message: > > Forbidden > > You don't have permission to access /static on this server. > > Which tells you exactly what the problem is: your web server doesn't > have permission to read the files in that directory. So check the file > permissions (remember that the web server does not run as the same user > as you necessarily use when you log in). > > 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: how to deploy css and images with apache
On Sun, 2008-11-30 at 17:57 -0800, l0he1g wrote: > I am sorry adding a initial slash doesn't solve this problem,but thank > you for the same. > when I get http://localhost/static directly in browser,arise a 403 > message: > Forbidden > You don't have permission to access /static on this server. Which tells you exactly what the problem is: your web server doesn't have permission to read the files in that directory. So check the file permissions (remember that the web server does not run as the same user as you necessarily use when you log in). 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: how to deploy css and images with apache
I am sorry adding a initial slash doesn't solve this problem,but thank you for the same. when I get http://localhost/static directly in browser,arise a 403 message: Forbidden You don't have permission to access /static on this server. when I get http:/localhost/,I inspect the adress of images in the browser by firefox,they like that: http://localhost/static/images/logo_index.png. So,I think the problem isn't the browser cannot interpret the adress correctly,but someting wrong in the map relationship between url and physical path. On 12月1日, 上午1时49分, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Nov 30, 5:26 pm, l0he1g <[EMAIL PROTECTED]> wrote: > > > Hi,everyone,this is a beginner's first post,after a long,tired search > > here and there without any solution. > > I use apache+mod_python on windows,The problem is the css and images > > does't be imported anyway,as I did what "How to use Django with Apache > > and mod_python" told inhttp://docs.djangoproject.com/. > > > > > > > > I'm guessing your problem lies here. You haven't used an initial > slash, so the browser is looking for a path relative to your Django > page's URL. Try > > and see if that works. > > -- > 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: Sending automatic emails
It is also possible to use a cronjob to initiate a script to send an e- mail. --~--~-~--~~~---~--~~ 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 revision for ORM aggregation patch
On Mon, Dec 1, 2008 at 9:13 AM, Ariel Mauricio Nunez Gomez <[EMAIL PROTECTED]> wrote: > >> I should be in a position to publish a git repository with my work in >> progress in the next day or so, which will remove the need for anyone >> to apply the patch manually. When I push the repository, I'll announce >> on the ticket and on django-developers. Watch this space. > > That'd be great, thanks a lot. FYI - the repository is now live: http://github.com/freakboy3742/django/tree/aggregation See the notes on ticket #3566 for details about the code in that repository. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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 1.0 no longer prints higher ASCII?
On Sun, 2008-11-30 at 07:56 -0800, Log0 wrote: > Hi all, > > This string : > > data = ''.join( [ chr(i) for i in xrange(256) ] ) > > In Django 0.96, this string prints well. > In Django 1.0, this string simply disappears before going to Apache, > and the data is never transmitted to the client or even apache. You're going to need to supply a bit more information than that. You don't explain how you are trying to send that information to the client, for example. Is it part of a template? Or raw data that you push into an HttpResponse object? Realise that there were some things with bytestrings like this that worked by accident in Django 0.96. When we added proper unicode support just after 0.96 was released, this also meant that all bytestrings are treated as UTF-8. So arbitrary bytestrings like the above won't make a lot of sense most of the time (it isn't valid UTF-8). However, it depends on the context you are using the data in, so if you can supply a few more details, we might be able to help. 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: ordering by models.ForeignKey
On Sun, 2008-11-30 at 13:15 +0100, Alfredo Alessandrini wrote: > Hi, > > I've this model: > > class Player(models.Model): > user = models.ForeignKey(User, blank=True, null=True) > country = models.ForeignKey(Country) > > If I try to ordering Player by "user", don' work: > > Player.objects.order_by("user") What do you mean "doesn't work"? That line should work without any problems. It will order by the primary key value of the User model (not particularly useful, but it still works as advertised). > I want ordering Player by user.username So use Player.objects.order_by("user__username") This is all documented, with examples, in the order_by() documentation: http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields 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: Template engine reads OS locale (?) and expects comma instead of decimal point in floatformat
On Sun, 2008-11-30 at 01:34 -0800, Ulf Kronman wrote: > Hi Malcolm, > > > I forgot to mention this in my last reply, but you didn't actually > > answer the question that Karen asked. If you open up a Python prompt on > > your machine and do this: > > > > >>> import decimal > > >>> decimal.Decimal('1.0') > > > > does it raise an exception? > > Sorry, I forgot to report on that part, but I did that without any > problem. Here is the check: > > Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import decimal > >>> decimal.Decimal('1.0') > Decimal("1.0") > >>> So Decimal isn't fundamentally broken on Python on Windows (not too surprising). > Also sorry for seemingly forking the issue in two threads, but this > was an effect of me (being a confused non-programmer) trying to sort > things out and respond to your suggestions, respectively. Yeah, no worries. I realised you were trying to respond to both sub-threads at once, so I was trying to pull things back together a bit. > > I'll read and try to understand and follow your suggestions for > checking on locale before and after the database call and get back > with a report on that. > > I've already hardcoded variable values as you suggest and sent them > off to the template before the database call (lst_result = cur.fetchall > ()), and at that point floatformat works fine with a decimal point > (and a string with decimal comma breaks the floatformat). > > Sending hardcoded variable values on the line after the database call > gives the opposite result; values with decimal point break the > floatformat, but strings with decimal comma don't break floatformat, > but are on the other hand not displayed after doing floatformat. Okay, that's useful. It really strongly suggests that it's the database wrapper you've got that is breaking things by doing something with the locale. That would be a fairly serious bug in that code if you're able to narrow it down. You should be able to construct a small repeatable test case that doesn't involve Django at all, which will help narrow down the problem. Sounds a lot like a pymssql bug at the moment. 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: Receiving xml via HTTP POST
On Sun, 2008-11-30 at 01:15 -0800, Daniel Roseman wrote: [...] > No doubt someone will correct me if I'm wrong, but I don't think there > *is* any other way of receiving a file via POST except via a form. You gave an answer, so it's going to look crabby to say this, but that isn't correct. You can send anything in the body of an HTTP POST request and Django will be able to work with it. What you cannot do is use request.POST to access the data, since that does form-decoding. Instead, use request.raw_post_data, which is the unprocessed input data (and check request.METHOD to see which method was used to submit the data -- POST, PUT, etc). 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: Django revision for ORM aggregation patch
> I should be in a position to publish a git repository with my work in > progress in the next day or so, which will remove the need for anyone > to apply the patch manually. When I push the repository, I'll announce > on the ticket and on django-developers. Watch this space. That'd be great, thanks a lot. > > > I tried unsuccesfully with django 1.0rc, 1.0 and 1.0.2, everytime > different > > rejections, and when I try to fix them by hand I always get a 'SELECT > FROM > > ...' invalid clause error. > > This error isn't one I can recall seeing during my work, so I'd need > to see more detail to help out here. The only error I am aware of with > the patch as published is that one of the test cases causes problems > with MySQL due to a quoting problem with a column name with a space in > it. This arises as a ProgrammingError during the test suite, not an > invalid clause error. > I also contacted Nicolas off list and he said he was gonna try to update the patch to work against trunk in the next days or so. So I think I would better wait a week or so and see what happens, I already read all the docs on the patch, this certainly looks great. Ariel. --~--~-~--~~~---~--~~ 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 revision for ORM aggregation patch
On Mon, Dec 1, 2008 at 2:04 AM, Ariel Mauricio Nunez Gomez <[EMAIL PROTECTED]> wrote: > Does anybody know which revision of django works with the latest patch in > the ticket #3566 > http://code.djangoproject.com/ticket/3566 The patch on the ticket was constructed against a trunk revision just prior to 1.0 release. Since then, I have been working on this ticket in my local git repository. While there are some minor variations between the published patch and my current working version, the changes I have made aren't particular significant, so I'm not aware of any merge problems that you should be having. I should be in a position to publish a git repository with my work in progress in the next day or so, which will remove the need for anyone to apply the patch manually. When I push the repository, I'll announce on the ticket and on django-developers. Watch this space. > I tried unsuccesfully with django 1.0rc, 1.0 and 1.0.2, everytime different > rejections, and when I try to fix them by hand I always get a 'SELECT FROM > ...' invalid clause error. This error isn't one I can recall seeing during my work, so I'd need to see more detail to help out here. The only error I am aware of with the patch as published is that one of the test cases causes problems with MySQL due to a quoting problem with a column name with a space in it. This arises as a ProgrammingError during the test suite, not an invalid clause error. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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: Admin - Auto Generate user_id on save
On Nov 29, 8:26 pm, AJ <[EMAIL PROTECTED]> wrote: > James, > > Thanks for the reply, I can't tell you how many times I read over that > page in the documentation today, and didn't catch that. I think when > this problem arose I looked over the ModelForm docs and couldn't find > a solution. Thanks again for your assistance! > > On Nov 29, 6:38 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > > > On Sat, Nov 29, 2008 at 5:25 PM, AJ <[EMAIL PROTECTED]> wrote: > > > to the vairables self and commit. So as far as I can tell I can't do > > > this in the Admin. It looks like I would need to write my own custom > > > form and view. Is this correct, or is there another way to do this? > > > Consult the documentation for the admin; there are methods on > > ModelAdmin you can override to customize and control what happens > > during object saving. Override your method and receive as a parameter the request object, so through the request object you can get access to the user logged in. > > > And in general, please consider doing some searching when you > > encounter something you don't quite know how to do; this is, for > > example, one of the most-frequently-asked questions about the admin, > > and the techniques for solving it have been covered repeatedly on this > > list and elsewhere. > > > -- > > "Bureaucrat Conrad, you are technically correct -- the best kind of > > correct." --~--~-~--~~~---~--~~ 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: Adding new forms dynamically to the page?
I'm not expert at this. I've only used formsets a little, and I've never added any dynamically. But depending upon your requirements, you could define the formset with an adequate number of "extra=" forms and have the javascript hide most of them by default, displaying an additional one each time a button is pressed. I believe that formsets are smart enough to simply ignore extra forms, which have not been filled in, during validation. This might be simpler than generating the forms on the fly in javascript. And in this case you would not have to worry about modifying the management form. But like I say, I'm no whiz at this. -Steve --~--~-~--~~~---~--~~ 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 1.0 no longer prints higher ASCII?
On Nov 30, 9:56 am, Log0 <[EMAIL PROTECTED]> wrote: > Hi all, > > This string : > > data = ''.join( [ chr(i) for i in xrange(256) ] ) > > In Django 0.96, this string prints well. > In Django 1.0, this string simply disappears before going to Apache, > and the data is never transmitted to the client or even apache. > > Why? > Any fix? > > Thanks a lot. Technically speaking, ASCII is only a 7-bit code. However, what is your DOCTYPE and charset on the page you are serving? How are you displaying 'data'? --~--~-~--~~~---~--~~ 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 1.0 no longer prints higher ASCII?
What do you mean by "disappears"? How are you trying to output it? There's nothing special about the string that line generates, and I doubt anything would have changed between versions of Django that would stop that string from doing something it used to do. -Jeff On Nov 30, 10:56 am, Log0 <[EMAIL PROTECTED]> wrote: > Hi all, > > This string : > > data = ''.join( [ chr(i) for i in xrange(256) ] ) > > In Django 0.96, this string prints well. > In Django 1.0, this string simply disappears before going to Apache, > and the data is never transmitted to the client or even apache. > > Why? > Any fix? > > Thanks a lot. > > --- > > Best Regards, > Log0 --~--~-~--~~~---~--~~ 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: GeoDjango question about US zipcode lookup and spatial query
On Sat, Nov 29, 2008 at 12:24 PM, Justin Bronn <[EMAIL PROTECTED]> wrote: > > > I do have a few basic questions > > - on slide 37, there's a Zipcode model, how does one populate this model? > > Are we using fe_2007_us_zcta500.shp? If so, is there a program which > > converts the zipcode shape from the shape file? > > Yes, you use that shapefile. The script that loads the data is also > in the presentation, go to slide 68 (in the `LayerMapping` section). > Thanks Justin, I was using MySQL and it looks like I do need Postgres to get the best gis support. Do people normally switch their DB backend entirely or do they start a new project for geo stuff and connect the main site to this as a separate backend? I can see the pros and cons of each approach. Just want to hear about people's experience I followed the example and did: def test_zipcode(): zipcode_mapping = { 'code' : 'ZCTA5CE00', 'mpoly' : 'MULTIPOLYGON', } zipcode_shp = '/usr/local/share/census/fe_2007_us_zcta500.shp' lm = LayerMapping(Zipcode, zipcode_shp, zipcode_mapping) lm.save(verbose=True) and tried a few zipcode in Admin interface. I see several problems and want to make sure it's a data error rather than installation error: 1. There's no 08544 zipcode after the layer mapping. 08544 should point to Princeton NJ. 2. I do see 08540 and 08542. 08542 seems correct but 08540 shows North Pole?? 3. I also did a shp2pgsql dump with srid=4269 which seems the closest match of the prj file as compared to spatial_ref_sys in the pgsql db. shp2pgsql -s 4269 fe_2007_us_zcta500 zipcode > zipcode.sql and 08544 is not there. If so, it does look like the zipcode is incomplete even though the dataset is fairly recent and from census. Do you have recommendation on what maybe a better DataSource? > > > - on slide 41, there is an Address model, does GeoDjango provide > geocoding > > which converts it to (lat, lon) for spatial query? If not, does it mean > that > > one has to query Google/Yahoo/MSFT WebServices? > > No, GeoDjango does not provide geocoding services. Geopy [1] is a > popular Python geocoding interface. > Let say I want to do something similar to your example of HoustonCrimeMap, and I use Geopy to perform the geocoding to get back the (lat, lon) for each crime event location and I also want to show the events within a certain radius R from a point P. Do you store the lat lon as a Point for each event and construct a polygon of a circle(P,R) and check if the event point is contained inside the polygon? What do you recommend as the best practice? Thanks -Aaron > > Regards, > -Justin > > [1] http://code.google.com/p/geopy/ > > > --~--~-~--~~~---~--~~ 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 deploy css and images with apache
On Nov 30, 5:26 pm, l0he1g <[EMAIL PROTECTED]> wrote: > Hi,everyone,this is a beginner's first post,after a long,tired search > here and there without any solution. > I use apache+mod_python on windows,The problem is the css and images > does't be imported anyway,as I did what "How to use Django with Apache > and mod_python" told inhttp://docs.djangoproject.com/. > > > I'm guessing your problem lies here. You haven't used an initial slash, so the browser is looking for a path relative to your Django page's URL. Try and see if that works. -- 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: Adding new forms dynamically to the page?
Thanks Steve. I've got the server-side portion done, just need to now work on the javascript. :) On Nov 30, 9:02 am, Steve Bergman <[EMAIL PROTECTED]> wrote: > When you add a form with javascript, you must also increment the > hidden field in the management form which holds the form count. > Actually, you'll need to read that field before you add the form to > determine what the proper ids and names for the new input elements > should be. Validation will then expect and validate that number of > forms when the user submits. > > -Steve --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
how to deploy css and images with apache
Hi,everyone,this is a beginner's first post,after a long,tired search here and there without any solution. I use apache+mod_python on windows,The problem is the css and images does't be imported anyway,as I did what "How to use Django with Apache and mod_python" told in http://docs.djangoproject.com/. I set the static dictionary,including css,images,js files I want to root,in the httpd.conf: Alias /static D:/home/django/myproject/static SetHandler None and,in html: Is there any relationship with Media_root,Media_URL in the settings file,which I set like these: MEDIA_ROOT ='D:/home/django/myproject/static/ MEDIA_URL ='http:/localhost/static/' I have tried to put the static dictionary in the htdocs of apache,the css and images can be invoked when I open http://localhost/,but once go to another link,such as http://localhost/register,the css and images are missing again! Is there any good solution to treat these static files,by which we can use relative path to include css and images files like /style/ index.css in html templates. Thank you very much! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 revision for ORM aggregation patch
Does anybody know which revision of django works with the latest patch in the ticket #3566 http://code.djangoproject.com/ticket/3566 I tried unsuccesfully with django 1.0rc, 1.0 and 1.0.2, everytime different rejections, and when I try to fix them by hand I always get a 'SELECT FROM ...' invalid clause error. -Ariel. --~--~-~--~~~---~--~~ 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: Adding new forms dynamically to the page?
When you add a form with javascript, you must also increment the hidden field in the management form which holds the form count. Actually, you'll need to read that field before you add the form to determine what the proper ids and names for the new input elements should be. Validation will then expect and validate that number of forms when the user submits. -Steve --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Invalid block tag: render_comment_form
Hello, I use the comments framework from the newest Django SVN checkout. I have in my template: {% load comments % } [...] {% render_comment_form for object %} resulting in a Invalid block tag: 'render_comment_form' I have found the same error in one other posting but no solution. What is wrong? Thanks, Florian --~--~-~--~~~---~--~~ 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: Implement file upload in admin interface
hi, It is mush easier then my approach. Thanks a lot! On Fri, Nov 28, 2008 at 9:28 PM, redbaron <[EMAIL PROTECTED]> wrote: > > > My current solution is. > > 1. Define new model Batches: > > class Batches(models.Model): > batchfile = model.FileField(upload_to="noop") > > 2. In admin.py define new form with custom validators: > > class BatchUploadForm(forms.ModelFormi): >class Meta: >model = Batches > >def clean_batchfile(self): >data = self.cleaned_data['batchfile'].read() #here we've got > uploaded file content >ret = your_processing_routine(data) #if file is wrong > processing returns error message >if ret: >raise forms.ValidationError(ret) > > > 3. Register customized ModelAdmin for Batches: > > class BatchesAdmin(admin.ModelAdmin): >form = BatchUploadForm #here we've replaced default form to our > one > >def save_model(self, request, obj, form, change): >pass #nothing save to base actually > > > > --~--~-~--~~~---~--~~ 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: OneToOneField blank=True null=True having an accident
I found a solution on my own, and it's a doozy. If anyone can think of something a bit less ugly, let me know. The reason why the global variables are lists is to keep Python from trying to rebind the names as local variables inside the functions on assignment (the very behaviour that makes closures ugly to do in Python - one of the few things that annoy me about Python). This one's a beaut. It combines the code to delete the whole tree with the code to save the parent keys if necessary by listening to pre_delete. What it does is keep track of the id of the last SubKeyRing it tried to kill... when the SubKeyRing tries to commit matricide, Mom tries to kill it, naturally, which results in it trying to kill Mom in an endless loop, but since we keep track of the last SubKeyRing that tried to be killed, we only let that go on for one cycle. When we detect the endless cycle of violence, we stash away the id of the parent key. We also listen to post_delete for both kinds of keys, and if the id of the key that was just deleted matches the id of a parent that should not have been deleted, we set the subkeyring to None and save the instance, basically putting it back in the database. Anyway: from django.db.models import signals subkeyring_tried_to_kill = [None] put_root_key_back = [None] put_sub_key_back = [None] def delete_subkeyring(sender, instance, **kwargs): if instance.subkeyring: if instance.subkeyring.id == subkeyring_tried_to_kill[0]: if isinstance(instance, SubKey): put_sub_key_back[0] = instance.id else: put_root_key_back[0] = instance.id else: subkeyring_tried_to_kill[0] = instance.subkeyring.id instance.subkeyring.delete() def return_parent(sender, instance, **kwargs): if isinstance(instance, SubKey): if instance.id == put_sub_key_back[0]: instance.subkeyring = None instance.save() put_sub_key_back[0] = None elif instance.id == put_root_key_back[0]: instance.subkeyring = None instance.save() put_root_key_back[0] = None signals.pre_delete.connect(delete_subkeyring, sender=RootKey) signals.pre_delete.connect(delete_subsubkeyring, sender=SubKey) signals.post_delete.connect(return_parent, sender=RootKey) signals.post_delete.connect(return_parent, sender=SubKey) On Nov 30, 10:26 am, stevedegrace <[EMAIL PROTECTED]> wrote: > Another problem! I'm using Django 1.0.2, Python 2.5.2, on Ubuntu 8.10. > > I have a structure of keys and keyrings arranged in a tree of > arbitrary depth which I decided to implement as a bunch of models: > RootKeyRing, RootKey, SubKeyRing, SubKey (rather than as XML like > maybe I should have done) because I wanted to use the Admin interface > with it and not manually edit XML or write a special admin. > > A SubKey has a ForeignKey which is a SubKeyRing to which it must > belong, and a OneToOneField with attributes blank=True and null=True > which is a SubKeyRing it may optionally point to. That all works > great. The problem comes when I go to delete a SubKeyRing. > > The desired behaviour is for all of the SubKeyRing's SubKeys to die, > and it does that (the case of killing any SubKeyRings that belong to > the SubKeys is handled by using the pre_delete signal, and not the > problem right now). However, it has an unpleasant side effect - it > also kills its parent key, which is pointing to it with the > OneToOneField, even though that field is allowed to be none. > > I understand it is doing this because OneToOneField is based off of > ForeignKey - but what I would like to have happen is to set the > OneToOneField to None instead of deleting the parent key. Is there > some way to suppress the delete cascade behaviour for a relation? I > tried connecting a function to the pre_delete signal for the > SubKeyRing and just setting the parent_key to None, but it tries to > delete the parent key anyway and raises an AttributeError, so that's > not going to cut it. > > Any ideas? I would rather suppress the delete cascade behaviour than > restructure my models because aside from this one problem, I really > like the structure I'm using and don't want to refactor it. > > Thanks, > > Stephen --~--~-~--~~~---~--~~ 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 1.0 no longer prints higher ASCII?
Hi all, This string : data = ''.join( [ chr(i) for i in xrange(256) ] ) In Django 0.96, this string prints well. In Django 1.0, this string simply disappears before going to Apache, and the data is never transmitted to the client or even apache. Why? Any fix? Thanks a lot. --- Best Regards, Log0 --~--~-~--~~~---~--~~ 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 1.0 no longer prints higher ASCII?
Hi all, This string : data = ''.join( [ chr(i) for i in xrange(256) ] ) In Django 0.96, this string prints well. In Django 1.0, this string simply disappears before going to Apache, and the data is never transmitted to the client or even apache. Why? Any fix? Thanks a lot. --- Best Regards, Log0 --~--~-~--~~~---~--~~ 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: Adding new forms dynamically to the page?
So to clarify, I'd be modifying the new rows on the client side, correct? On Nov 29, 9:47 pm, "Felipe Sodré Silva" <[EMAIL PROTECTED]> wrote: > I don't see why it wouldn't. > > On Sun, Nov 30, 2008 at 3:42 AM, Zeroth <[EMAIL PROTECTED]> wrote: > > > Thanks Felipe for your quick answer. Does that still get validated > > properly? > > > On Nov 29, 9:20 pm, "Felipe Sodré Silva" <[EMAIL PROTECTED]> wrote: > > > You can easily add new rows to the form with ids 'rowN', where N is the > > > number of rows, and also modify a hidden element that tells how many > > > elements are there in the form so far. This is more elegant than string > > > manipulation, and also more efficient. > > > > Cheers, > > > > Felipe > > > > On Sun, Nov 30, 2008 at 3:01 AM, Zeroth <[EMAIL PROTECTED]> wrote: > > > > > I'm making essentially a wishlist webapp(for fun). However, I would > > > > like to make it so that the user can press a button, and add another > > > > row for entering an item, via AJAX. My issue is making sure that the > > > > webserver processes all the data properly. I've been looking at > > > > formsets, and maybe using a combination of js on the client side and > > > > string manipulation on the server side to make sure that the formset > > > > validates every form. Is there a better way/smarter/pythonic way of > > > > doing this? --~--~-~--~~~---~--~~ 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 uploaded image
On Nov 30, 2008, at 10:36 PM, Alex Jonsson wrote: > > Hey guys, > > I have an application where I want my users to be able to upload a > picture. The model contains a name field and a ImageField. > > My question is how the easiest way would be to modify this image > before saving it? That is, cropping it down to a certain size and > renaming it to the person's name instead of having randomly named > files in my folders. The most direct method is overriding the model's save() method. Every time a picture instance is saved, it will go through whatever you put in the save method -- usually this means using the PIL library, which may or may not be installed in your production environment. Use the PIL.Image class to open the image (ie img = Image.open(self.imagefield.path)) and manipulate it, then resave it. Check out both PIL: http://www.pythonware.com/products/pil/ and the django file storage docs: http://docs.djangoproject.com/en/dev/ref/models/fields/#imagefield Note that changing the path to something relative to the currently logged-in user will be a little more difficult. As far as I know the thread-locals hack is still required there... E > > > Thanks, > Alex > > --~--~-~--~~~---~--~~ 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 uploaded image
Hey guys, I have an application where I want my users to be able to upload a picture. The model contains a name field and a ImageField. My question is how the easiest way would be to modify this image before saving it? That is, cropping it down to a certain size and renaming it to the person's name instead of having randomly named files in my folders. Thanks, Alex --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
OneToOneField blank=True null=True having an accident
Another problem! I'm using Django 1.0.2, Python 2.5.2, on Ubuntu 8.10. I have a structure of keys and keyrings arranged in a tree of arbitrary depth which I decided to implement as a bunch of models: RootKeyRing, RootKey, SubKeyRing, SubKey (rather than as XML like maybe I should have done) because I wanted to use the Admin interface with it and not manually edit XML or write a special admin. A SubKey has a ForeignKey which is a SubKeyRing to which it must belong, and a OneToOneField with attributes blank=True and null=True which is a SubKeyRing it may optionally point to. That all works great. The problem comes when I go to delete a SubKeyRing. The desired behaviour is for all of the SubKeyRing's SubKeys to die, and it does that (the case of killing any SubKeyRings that belong to the SubKeys is handled by using the pre_delete signal, and not the problem right now). However, it has an unpleasant side effect - it also kills its parent key, which is pointing to it with the OneToOneField, even though that field is allowed to be none. I understand it is doing this because OneToOneField is based off of ForeignKey - but what I would like to have happen is to set the OneToOneField to None instead of deleting the parent key. Is there some way to suppress the delete cascade behaviour for a relation? I tried connecting a function to the pre_delete signal for the SubKeyRing and just setting the parent_key to None, but it tries to delete the parent key anyway and raises an AttributeError, so that's not going to cut it. Any ideas? I would rather suppress the delete cascade behaviour than restructure my models because aside from this one problem, I really like the structure I'm using and don't want to refactor it. Thanks, Stephen --~--~-~--~~~---~--~~ 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: Templatetag: parser is choking
Well, I got that fairly complicated recursive control structure working nicely... it resembles if/else/endif, but it loops picking up nodelists in a dictionary indexed by tag name, makes a list of the tags it finds until the endtag, and checks the list to make sure the syntax inside the bock was correct. So I'm happier this morning. :) On Nov 29, 10:12 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sat, 2008-11-29 at 17:37 -0800, stevedegrace wrote: > > I have a weird problem. (I'm using Django 1.0.2, Python version 2.5.2 > > on Ubuntu 8.10). Say I have a template like this: > > > """ > > {% sometag %} > > Some stuff > > {% someothertag %} > > Some more stuff > > {% yetanothertag %} > > Last stuff > > {% endsometag %} > > """ > > My template tag function looks something like this: > > > @register.tag(name="sometag") > > def do_sometag(parser, token): > > nodelist1 = parser.parse(('someothertag',' yetanothertag', > > 'endsometag')) > > parser.delete_first_token() > > nodelist2 = parser.parse(('someothertag',' yetanothertag', > > 'endsometag')) > > parser.delete_first_token() > > # ... do some stuff ... no point returning a node, not going to > > get that far... > > Looks like using delete_first_token() in the middle of a parsing > operation like this isn't vaild. It changes the list of tokens in place, > which might be messing up the parsing state. In the documentation (and > all the uses of delete_first_token in the Django template tags), it's > only used as the very last thing before passing the remainder to a Node > object. > > The if...else block tag would be a good pattern to model code on. > > 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 -~--~~~~--~~--~--~---
Multi Table Inheritance with Mulitple Children
I have an inheritance system for defining people. So there's a class Person, and sub-class User thus: class Person(models.Model): ''' A person! ''' firstname = models.CharField("first name", max_length = 128, help_text = "(required)") lastname = models.CharField("last name", max_length = 128, help_text = "(required)") email = models.EmailField("email address", unique = True, help_text = "(required)") groups = models.ManyToManyField(Group, blank = True, through = 'Membership', related_name = 'group_set', verbose_name = "group memberships") created = models.DateTimeField(auto_now_add = True) last_modified = models.DateTimeField(auto_now = True) class User(Person): ''' Persons who are also users ''' password = models.CharField(max_length = 40, blank = True, editable = False) I would like to add child classes after previously having an object as only a parent - so at some point in time a Person can become a User. So I try this in the manage.py shell: >>> from MyPidge.Users.models import Person, User >>> myuser = Person.objects.create(firstname = "Fergus", lastname = "Ferrier", >>> email = "[EMAIL PROTECTED]") >>> myuser.save() After myuser.save() there is a Person row in the DB, and all appears well. >>> newu = User(password = "hello") >>> newu.person_ptr_id = myuser.id [ also tried person = myuser and person_ptr = myuser] >>> newu.save() ... Traceback gumph ... Warning: Column 'created' cannot be null There is no User row, and the Person row now has blank values except for the last modified field. Please tell me if I've done something totally crazy. I only want to add children after-the-fact... Many thanks, Ferg --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ordering by models.ForeignKey
Hi, I've this model: class Player(models.Model): user = models.ForeignKey(User, blank=True, null=True) country = models.ForeignKey(Country) If I try to ordering Player by "user", don' work: Player.objects.order_by("user") I want ordering Player by user.username Alfredo --~--~-~--~~~---~--~~ 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 - processing flatpages problem.
Thank you for the tip. It works well. I have problem with processing flat pages. When debug is switched to True the error appear in db with following content: Traceback (most recent call last): File "/usr/local/lib/python2.6/site-packages/django/core/handlers/base.py", line 86, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.6/site-packages/django/views/static.py", line 56, in serve raise Http404, '"%s" does not exist' % fullpath Http404: "/home/grzegorz/workspace/ghome/src/ghome/../ghome/media/o-mnie" does not exist [30/Nov/2008 12:18:16] "GET /o-mnie/ HTTP/1.1" 200 9733 It seems with debugging enabled flat page is processing successfully because page http://127.0.0.1:8080/o-mnie/ is displayed as expected. But when debugging is disabled (DEBUG=True) error generated after processing above url has the same content and additionally I get "Server Error (500)" in browser: [30/Nov/2008 12:19:04] "GET /o-mnie/ HTTP/1.1" 500 1120 Could someone help with this issue? On Sunday 30 of November 2008 10:26:51 DIrk Ye wrote: > How about use this app: > > http://code.google.com/p/django-crashlog/ > > It will store error info in db. > > DIrk > > On Sun, Nov 30, 2008 at 4:36 PM, Grzegorz Szymański <[EMAIL PROTECTED]>wrote: > > On Sunday 30 of November 2008 09:31:55 Grzegorz Szymański wrote: > > > Hi, > > > I have no too much experience with django and I have problem with my > > > > django > > > > > application. > > > When I switch DEBUG variable in settings.py to True the given url is > > > handled correctly and page is displayed as I expect. But when is switch > > > DEBUG to False then I get "Unhandled exception error" I tried to set > > > > ADMIN > > > > > variable to get e-mail notification about this error but it seems not > > > working. > > > > > > I could provide additional information if necessary. > > > > > > Cheers > > > > It is django "1.0.1 final" and python 2.6. > > > > -- > > Grzegorz Szymański | mailto:[EMAIL PROTECTED] | pgp:0x14A27314 > > jabber ID: [EMAIL PROTECTED] > > > > Dzwon tanio do wszystkich! > > Sprawdz >> http://link.interia.pl/f1fa7 > > -- Grzegorz Szymański | mailto:[EMAIL PROTECTED] | pgp:0x14A27314 jabber ID: [EMAIL PROTECTED] Dzwon tanio do wszystkich! Sprawdz >> http://link.interia.pl/f1fa7 --~--~-~--~~~---~--~~ 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: m2m relationship by intermediary model and inline editing
Ok, Solved!! It wasmy fault because I have overwritten the form widget in the inline model. Now I have removed the customized form. On Nov 29, 11:16 pm, mrsource <[EMAIL PROTECTED]> wrote: > I have models and admin configuration like these:http://dpaste.com/94671/ > > when I edit the model "composizione" the first foreign key > (composizione) field of "through" model is automatically valorized by > the parent model, and the second (articolo) is user selected. The > problem is that if I don't valorize the second filed (articolo),and I > edit only the parent model, I get an empty field error validation on > the extra inline model. > Can I escape this validation ? Or is not possible to use inline > editing when I have an intermediary model? > If I put blank=True in the field articolo of intermediary model I get > another error because the foreign key must be not blank. --~--~-~--~~~---~--~~ 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 debugging problem.
How about use this app: http://code.google.com/p/django-crashlog/ It will store error info in db. DIrk On Sun, Nov 30, 2008 at 4:36 PM, Grzegorz Szymański <[EMAIL PROTECTED]>wrote: > > On Sunday 30 of November 2008 09:31:55 Grzegorz Szymański wrote: > > Hi, > > I have no too much experience with django and I have problem with my > django > > application. > > When I switch DEBUG variable in settings.py to True the given url is > > handled correctly and page is displayed as I expect. But when is switch > > DEBUG to False then I get "Unhandled exception error" I tried to set > ADMIN > > variable to get e-mail notification about this error but it seems not > > working. > > > > I could provide additional information if necessary. > > > > Cheers > It is django "1.0.1 final" and python 2.6. > > -- > Grzegorz Szymański | mailto:[EMAIL PROTECTED] | pgp:0x14A27314 > jabber ID: [EMAIL PROTECTED] > > Dzwon tanio do wszystkich! > Sprawdz >> http://link.interia.pl/f1fa7 > > > > > --~--~-~--~~~---~--~~ 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: Template engine reads OS locale (?) and expects comma instead of decimal point in floatformat
Hi Malcolm, > I forgot to mention this in my last reply, but you didn't actually > answer the question that Karen asked. If you open up a Python prompt on > your machine and do this: > > >>> import decimal > >>> decimal.Decimal('1.0') > > does it raise an exception? Sorry, I forgot to report on that part, but I did that without any problem. Here is the check: Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import decimal >>> decimal.Decimal('1.0') Decimal("1.0") >>> Also sorry for seemingly forking the issue in two threads, but this was an effect of me (being a confused non-programmer) trying to sort things out and respond to your suggestions, respectively. I'll read and try to understand and follow your suggestions for checking on locale before and after the database call and get back with a report on that. I've already hardcoded variable values as you suggest and sent them off to the template before the database call (lst_result = cur.fetchall ()), and at that point floatformat works fine with a decimal point (and a string with decimal comma breaks the floatformat). Sending hardcoded variable values on the line after the database call gives the opposite result; values with decimal point break the floatformat, but strings with decimal comma don't break floatformat, but are on the other hand not displayed after doing floatformat. This happens without even doing anything at all with the values returned from the database call. Actually, I don't do anything with the record ID returned as Decimal() in the code that started breaking floatformat in the first place. Thanks for all your help and once again my apologies for fragmented and confused reports. Ulf --~--~-~--~~~---~--~~ 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: Receiving xml via HTTP POST
On Nov 30, 1:25 am, chefsmart <[EMAIL PROTECTED]> wrote: > Can someone throw a few ideas at me regarding this please... I'm sure > seasoned Django-ists could have really good ideas about this... > Thanks. > > On Nov 22, 10:06 pm, chefsmart <[EMAIL PROTECTED]> wrote: > > > Hi All, > > > I am creating an Adobe AIR application that will interact with my > > Django app. I am currently trying out django-rest-interface that can > > be found on googlecode. However, there's too much behind-the-scenes > > stuff django-rest-interface (for the little amount of knowledge I > > have) and I need more control over the processing of both sent and > > received data, thus I'm now doing it my own way. > > > I plan to create django views for: - > > 1. creating single or multiple new objects of each model (throughxml > > data received via HTTPPOST), > > 2. retrieving single or multiple existing objects of each model > > (retrieving via pk and retrieving all objects, paged). This single > > object or multiple objects will be sent asxmlwhen requested via HTTP > > GET > > 3. updating single or multiple existing objects of each model > > (throughxmldata received via HTTPPOST) > > 4. deleting single or multiple existing objects of each model > > (throughxmldata received via HTTPPOST) > > > This is not REST, but it gives me the control I need. > > > Thus far I have item no. 2 above sorted out. I just can't figure out > > how to receivexmldata via HTTPPOST. (I have only ever used HTTPPOSTfor html > > forms.) Let's say I have the followingxml, how do I > > send thisxmldata via HTTPPOST? > > > > > > > TX > > Texas > > 1 > > > > > > > All help is highly appreciated. No doubt someone will correct me if I'm wrong, but I don't think there *is* any other way of receiving a file via POST except via a form. So what you would need to do is simulate a form from your AIR app, with a single field containing your XML data. Then you can simply process the XML with your favourite Python XML library (personally I like ElementTree) and create/update the objecst as required. -- 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: Django debugging problem.
On Sunday 30 of November 2008 09:31:55 Grzegorz Szymański wrote: > Hi, > I have no too much experience with django and I have problem with my django > application. > When I switch DEBUG variable in settings.py to True the given url is > handled correctly and page is displayed as I expect. But when is switch > DEBUG to False then I get "Unhandled exception error" I tried to set ADMIN > variable to get e-mail notification about this error but it seems not > working. > > I could provide additional information if necessary. > > Cheers It is django "1.0.1 final" and python 2.6. -- Grzegorz Szymański | mailto:[EMAIL PROTECTED] | pgp:0x14A27314 jabber ID: [EMAIL PROTECTED] Dzwon tanio do wszystkich! Sprawdz >> http://link.interia.pl/f1fa7 --~--~-~--~~~---~--~~ 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 debugging problem.
Hi, I have no too much experience with django and I have problem with my django application. When I switch DEBUG variable in settings.py to True the given url is handled correctly and page is displayed as I expect. But when is switch DEBUG to False then I get "Unhandled exception error" I tried to set ADMIN variable to get e-mail notification about this error but it seems not working. I could provide additional information if necessary. Cheers -- Grzegorz Szymański | mailto:[EMAIL PROTECTED] | pgp:0x14A27314 jabber ID: [EMAIL PROTECTED] -- Doladowanie telefonu. Szybko i wygodnie. Sprawdz >> http://link.interia.pl/f1fa8 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---