Re: Attribute Error
On Sun, 2007-08-19 at 14:30 -0700, MikeHowarth wrote: > I'll take a look at that. > > Even commenting that line out and attempting to access self.title I'm > still getting an attribute error thrown: 'Register' object has no > attribute 'title' Doug Ballanc has explained how you should be writing your save() method. I thought I might just add something about why what you're doing doesn't seem to work, despite looking like perfectly valid Python code. The newforms Form class has a specialised __new__ method, which is what is responsible for attaching attributes to the object you get back from calling Form(). In the default case (i.e. pretty much always), what this method does is *not* creating attributes for anything that is a newforms.fields.Field subclass. Rather, those fields are put into an attribute called "base_fields" (which is copied to an attribute called "fields" in __init__). All this metaclass stuff happens in DeclarativeFieldsMetaclass in newforms.forms. Replacing the metaclass with something elase to populate the base_fields leaves open some interesting possibilities about how to initialise form classes for those with imagination. This might look very strange and, in a way, it is unusual. When I was wondering, early on in newforms life, why this was done (I think my initial mental question was "what was he smoking?"), I realised there isn't a completely natural thing to store in those attributes. Do they hold the normalized, cleaned data? The original value? Both, depending upon whether clean has been called? If the attribute is None, does that mean we don't have that value? We haven't set it yet? Or that the form's normalized value is None (possible for some fields)? How would you know which fields had errors in them and what would prevent you accidentally accessing those attributes and treating the values as real values? To some extent, it reduces confusion by not having attributes at all for fields. Instead, you initialise a form with the raw, submitted data. Then you access "cleaned_data" or is_valid() or "errors" whenever you like and the raw data is cleaned and normalized (where possible) and sent to two dictionaries: Form.cleaned_data and Form.errors. So, whilst what you were attempting might seem logical on one level, hopefully I've explained why it could, in many cases, be more confusing and error-prone than convenient. So the design uses a slightly different approach from providing access to the form data and errors. Best wishes, Malcolm -- Borrow from a pessimist - they don't expect it back. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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: recursive relationship foreignkey
On Sun, 2007-08-19 at 18:41 -0400, Francis Lavoie wrote: > Hi, > > I still have this error with null=True . > > model.py: > class Category(models.Model): > name = models.CharField(max_length=36) > description = models.CharField(max_length=200) > parent = models.ForeignKey('self', null=True, blank=True) > > class Admin: > # Admin options go here > pass > > then I did (to reset de database) : python manage.py flush > > and `python manage.py sql myapp` returns : > > BEGIN; > CREATE TABLE `myapp_category` ( > `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, > `name` varchar(36) NOT NULL, > `description` varchar(200) NOT NULL, > `parent_id` integer NULL > ) > ; > ALTER TABLE `myapp_category` ADD CONSTRAINT > parent_id_refs_id_5d9ae1d8600b3d85 FOREIGN KEY (`parent_id`) > REFERENCES `myapp_category` (`id`); That should work perfectly. It's the standard setup for a tree-like model structure. The database table also looks correct. Try creating the models from scratch in a separate project or application and I'll think you'll find it will work. It sounds like there is something going wrong from your earlier failed attempts. Regards, Malcolm -- I don't have a solution, but I admire your problem. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Mod_Python and Apache
Is it normal to experience a sudden sharp spike in cpu and memory usage for about a minute or so after a start/stop and restart? I'm running the pre-fork mpm, FreeBSD 6.2, and latest mod_python. I've tried disableing mod_python and it went away, so it's clearly mod python. I know that the pre-fork mpm has dummy connections to signal processes to die off and that's evident in logs, can it be causing the spike because it's hitting " / "? I've tried the rewrites and all, but notta. Any suggestions would be greatly appreciated. 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: Float Field not displaying the two zeros at the end of a price
Jake, No I didn't. When I tried the 'floatformat:2' I made sure that my model fields were of type FloatField. When I do use the 'floatformat: 3' and view the template. I notice that in my error message my for statement is highlighted: TypeError at /rugs/milliken/border/ionica/ float() argument must be a string or a number {% for a in thespinfo %} # This line is highlighted red 27 28 29 30 31 {{ a.size }} 32 ${{ a.price|floatformat:2 }} 33 Also, here is my floatfield in my models.py file. This is the field that I'm doing the 'floatformat:2' on. name = models.FloatField() Thanks Line 26 is what is highlighted red. Thanks On Aug 19, 11:36 pm, jake <[EMAIL PROTECTED]> wrote: > hi greg, > > just checking - did you try both at once? ie DecimalField in your model > and |floatformat:2 in your template. > > -jake > > Greg wrote: > > Vincent and James, > > I tired both of your suggestions and I couldn't get either to work. > > > First, still using my prices as FloatFields. I added the following to > > my template: {{ a.price|floatformat:2 }}. When I tried this I got the > > following error: > > > TypeError > > float() argument must be a string or a number > > > 2) I changed my price fields to Decimal Fields listed below: > > > models.DecimalField(max_digits=6, decimal_places=2) > > > However, the prices are still displayed without the decimal values for > > prices that end with 00. > > > 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 install django on Apache/Linux
On Aug 19, 11:04 pm, Chris Hoeppner <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > If my site is under /var/www/html/python, with the settings file as / > > var/www/html/python/foo/settings.py should I write, > > SetEnv DJANGO_SETTINGS_MODULE foo.settings > > (or) SetEnv DJANGO_SETTINGS_MODULE python.foo.settings > > Python imports stuff based on the environment variable PYTHONPATH, which > is similar to the UNIX PATH variable. If you have /var/www/html/ in your > pythonpath, you'll import using python.foo.settings. It might be handy > to put /var/www/html/python on the pythonpath though. But this is just a > matter of taste. By the way, the python stuff does not need to be in the > html root. Just make sure the apache user has the right permissions. If one is using Apache/mod_python, what you have PYTHONPATH environment variable set to in your own personal user environment is totally irrelevant in as much as Apache is normally started as root and doesn't inherit your user environment. Instead look at the PythonPath directive that mod_python supports. Check the Django setup documentation for mod_python for more details. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: clean method for auto generated forms (newforms)
Ah, yes, sort of obvious in retrospect. But at least I was in the neighborhood of a sane way of using it. Thanks. On Aug 19, 5:49 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 8/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > forms.models.form_for_instance(original_laborder, form=LabOrderForm) > > > Is there a more django-esque to get a custom clean method for an auto- > > generated form like this or is this the way it's supposed to go? > > There's actually two ways to do this. Your way is one method. The > other is to use conventional model inheritance. Remember, > form_for_model returns a class, so the following will be legal: > > BaseLabOrderForm = forms.form_for_instance(original_laborder) > class LabOrderForm(BaseLabOrderForm): >def clean(self): > ... > > Both will work; it's entirely up to you which one you prefer. > > > Also it seems that newforms doesn't respect the validator_list in the > > model, is that correct? As designed? > > Yes. Form validation and model validation are decoupled. Model > validation is a work in progress. > > 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: Cache middleware causing unit tests to fail
Eratothene wrote: > I think you better not disable cache middleware in tests. If tests > fail, so will be in production. I had similar problem, I thought it > was something wrong with tests, but really it was problem in the code. > My site was running well on django built-in server, but not on apache > mod_python. My site was working fine. My unittests was what were in error. Yeah there are going to be differences between production and devel. But, personally I believe unittests should test one thing. Not many things at once such as cache/view/db (as an aside I'm sort of sad django doesn't have a mock db for view unittests) So, I think you should test your cache framework and how your app uses it, but, those tests should not be part of the view unittests. I was testing that a specific template was being used to render page. With caching the correct behavior is to not use any template, not to render at all, but rather to pump contents of cache down the wire. In my test_settings.py file I have: # disable cache for testing MIDDLEWARE_CLASSES.remove('django.middleware.cache.CacheMiddleware') CACHE_BACKEND = "dummy:///" Then run python manage.py --settings=test_settings test works beautifully. --~--~-~--~~~---~--~~ 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: Float Field not displaying the two zeros at the end of a price
Vincent and James, I tired both of your suggestions and I couldn't get either to work. First, still using my prices as FloatFields. I added the following to my template: {{ a.price|floatformat:2 }}. When I tried this I got the following error: TypeError float() argument must be a string or a number 2) I changed my price fields to Decimal Fields listed below: models.DecimalField(max_digits=6, decimal_places=2) However, the prices are still displayed without the decimal values for prices that end with 00. Thanks On Aug 19, 6:56 pm, Vincent Foley <[EMAIL PROTECTED]> wrote: > {{ price|floatformat:2 }} > > On Aug 19, 4:44 pm, Greg <[EMAIL PROTECTED]> wrote: > > > I have a FloatField called price that stores the price of different > > elements. When the price is 19.99, 19.79, 19.01 etc... everything is > > displayed correctly. However, when I have a price of 19.00. The > > price when viewed in a browser is just 19. Is there anyway that I can > > have it display the two zeros so that it is displayed as 19.00? > > > 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 -~--~~~~--~~--~--~---
Closed
It was a typo. Everything works now. Sorry for the fuss! On Aug 19, 12:07 pm, Drasty <[EMAIL PROTECTED]> wrote: > I'm getting an escaped double quotation mark (", rendered as '%22') at > the end of some stuff that I'm using to reference an anchor on the > same page. This isn't a problem in templates, since the links and > corresponding anchors are generated. But if I want to enter a link in, > say, a TextField to one of those anchors, it becomes a bit tedious. > > I'm wondering if there's a way for me to get rid of that apparently > automatically generated character. > > Here's an example, with the escaped character in the "Output" section: > > (Code:) > > class Thing(models.Model): > words = models.TextField() > note = models.IntegerField() > > def note_anchor(self): > return self.note > > (Template:) > > Note {{ thing.note }} > > {{ thing.words }} > > > (Input:) > > words = 'Blah blah.' > note = '1' > > (Output:) > > Note 1 > > Blah blah. > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
quiz design
Hi, Has anyone worked on a quiz/ multiple choice contest design using Django using Newforms? RS --~--~-~--~~~---~--~~ 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: ImageField via admin
Grigory Fateyev wrote: > Hello! > > I have simple class with ImageField, but cann't add any object: > > class Book(models.Model): > name = models.CharField(_('Book Title'), maxlength=200) > book_number = models.IntegerField() > image = models.ImageField(upload_to='%Y/%m/%d/', core=True, > blank=True) > comment = models.TextField(_('Book Comment'), blank=True, >null=True) > author = models.CharField(_('Author'), maxlength=100, > blank=True) > year_rate = models.IntegerField() > > class Meta: > verbose_name = _('Book') > verbose_name_plural = _('Books') > > class Admin: > list_display = ('book_number', 'name', 'year_rate') > > def __unicode__(self): > return u"%s %s %s" % (self.book_number, self.name, > self.year_rate) > > the error: > > Traceback (most recent call last): > File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in > get_response 77. response = callback(request, *callback_args, > **callback_kwargs) File > "/usr/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" > in _checklogin 51. if 'post_data' in request.POST: File > "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in > _get_post 135. self._load_post_and_files() File > "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in > _load_post_and_files 113. self._post, self._files = > http.parse_file_upload(self.environ['wsgi.input'], self.environ) File > "/usr/lib/python2.4/site-packages/django/http/__init__.py" in > parse_file_upload 71. raw_message = '\r\n'.join(['%s:%s' % pair for > pair in header_dict.items()]) > > AttributeError at /admin/books/book/add/ > '_fileobject' object has no attribute 'items' > > What the problem it can be? > I just made a project with just that model. works for me. I would start by looking at these lines: [EMAIL PROTECTED]:~/django/foo/foot$ grep static * settings.py:# settings.py:MEDIA_ROOT = BASE_DIR+'/static/' settings.py:MEDIA_URL = '/static/' urls.py:(r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.BASE_DIR+'/static/', 'show_indexes': True}), What version of django? I am using current svn. Carl K --~--~-~--~~~---~--~~ 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: Attribute Error
I think you've got some misconceptions about newforms. http://www.djangoproject.com/documentation/newforms/ should give you the info you need. Something more like this: def save(self): #set up the objects we are going to populate user = User() # you want a new -instance- not another reference to the User class user.title = self.clean_data['title'] # validated data in the self.clean(ed)_data dict return user --~--~-~--~~~---~--~~ 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: Question: trailing escaped character in a href=""?
Hi, On 8/19/07, Drasty <[EMAIL PROTECTED]> wrote: > I'll investigate to see if will successfully point > to , though I have my doubts! Which version of django do you use? --~--~-~--~~~---~--~~ 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: application and project coupling in unittests
On 8/20/07, Viraj Alankar <[EMAIL PROTECTED]> wrote: > My question is why does my test in polls need to know anything about > the root url configuration of the project? This seems to couple my > poll-specific unittest to the project and it would be cleaner to not > need to specify the '/polls/' url prefix. Also for my test fixture I > need to specify the 'polls/' subdirectory which also increases that > coupling. This is an interesting idea. However, the primary reason is that fixtures, templates, and other application settings aren't specified at an application level - they're specified at the project level. As a result, testing needs to happen at the project level, too. Essentially, you can't run an application by itself - it needs to have a project around it, even if only a skeleton project. At the very least, it's the project that provides the './manage.py test' hook :-) I'm unclear as to why you need to specify the 'polls' directory in a fixture, though. There shouldn't be anything project specific in a fixture file. > This is probably just a minor nit, but I'm curious if I'm just doing > this wrong and whether others do it differently. I'm a little confused > as to how to organize my tests. Placing the unittest files within the > application directories when they actually require the root url config > seems strange to me. Personally, I lean very heavily on reverse URL lookup. In my applications, I almost never use a literal /foo/bar path, either in template or view code. Instead, I make sure every URL is named, and I use reverse() in view code, and {% url %} in templates. This completely separates the application from the URL - and not just for testing purposes. If your application uses URL lookups rather than hard-coding URLs, you can 'remount' an application anywhere in the URL space without changing a thing; you can also refactor the URL naming schemes without having to play games with search and replace. As a side effect, testing also becomes decoupled - the project in which the application is mounted becomes irrelevant. 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: Float Field not displaying the two zeros at the end of a price
{{ price|floatformat:2 }} On Aug 19, 4:44 pm, Greg <[EMAIL PROTECTED]> wrote: > I have a FloatField called price that stores the price of different > elements. When the price is 19.99, 19.79, 19.01 etc... everything is > displayed correctly. However, when I have a price of 19.00. The > price when viewed in a browser is just 19. Is there anyway that I can > have it display the two zeros so that it is displayed as 19.00? > > 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 -~--~~~~--~~--~--~---
Django app for locations? (countries, provinces, cities, venues...)
Is there an existing Django app for managing locations? Specificall, countries, states/provinces, cities, and specific locations with addresses. (I was just adding such an app to my project, but thought I might be duplicating someone better effort...) Thanks, -- Austin Govella Thinking & Making: IA, UX, and IxD http://thinkingandmaking.com [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: clean method for auto generated forms (newforms)
On 8/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > forms.models.form_for_instance(original_laborder, form=LabOrderForm) > > Is there a more django-esque to get a custom clean method for an auto- > generated form like this or is this the way it's supposed to go? There's actually two ways to do this. Your way is one method. The other is to use conventional model inheritance. Remember, form_for_model returns a class, so the following will be legal: BaseLabOrderForm = forms.form_for_instance(original_laborder) class LabOrderForm(BaseLabOrderForm): def clean(self): ... Both will work; it's entirely up to you which one you prefer. > Also it seems that newforms doesn't respect the validator_list in the > model, is that correct? As designed? Yes. Form validation and model validation are decoupled. Model validation is a work in progress. 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 -~--~~~~--~~--~--~---
application and project coupling in unittests
Hi, I've just started playing around with Django and have a question on unittesting. The docs mention that tests are looked for in the models.py files of applications and a tests.py file in the application directory. This seems to let me write tests specific to the application. However, when using django.test.client.Client, it uses the project url configuration instead of just the application's. For example, in the tutorial project I have a urls.py that looks like: urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), (r'^polls/', include('mysite.polls.urls')), ) And in polls/urls.py: urlpatterns = patterns('', (r'^$', 'django.views.generic.list_detail.object_list', info_dict), ... However, in my polls/tests.py, I have to do something like the following to get it working: from django.test import TestCase from django.test.client import Client class SimpleTest(TestCase): fixtures = ['polls/test_fixture.json'] def test_details(self): response = self.client.get('/polls/1/') ... My question is why does my test in polls need to know anything about the root url configuration of the project? This seems to couple my poll-specific unittest to the project and it would be cleaner to not need to specify the '/polls/' url prefix. Also for my test fixture I need to specify the 'polls/' subdirectory which also increases that coupling. This is probably just a minor nit, but I'm curious if I'm just doing this wrong and whether others do it differently. I'm a little confused as to how to organize my tests. Placing the unittest files within the application directories when they actually require the root url config seems strange to me. Thanks, Viraj. --~--~-~--~~~---~--~~ 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: List comprehension with unique, sorted values
> It works like a charm, but I'm obviously getting duplicates, and the > choices are not sorted. Looks like set() may do the job (I've never used it, but I'm glad to learn about those related functions). Another option may be tacking distinct() onto your query. .. _distinct: http://www.djangoproject.com/documentation/db-api/#distinct - whiteinge --~--~-~--~~~---~--~~ 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: List comprehension with unique, sorted values
I should have mentioned that I found such a function in the ASPN cookbook. Hope this helps (a bit)! --~--~-~--~~~---~--~~ 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: recursive relationship foreignkey
Hi, I still have this error with null=True . model.py: class Category(models.Model): name = models.CharField(max_length=36) description = models.CharField(max_length=200) parent = models.ForeignKey('self', null=True, blank=True) class Admin: # Admin options go here pass then I did (to reset de database) : python manage.py flush and `python manage.py sql myapp` returns : BEGIN; CREATE TABLE `myapp_category` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(36) NOT NULL, `description` varchar(200) NOT NULL, `parent_id` integer NULL ) ; ALTER TABLE `myapp_category` ADD CONSTRAINT parent_id_refs_id_5d9ae1d8600b3d85 FOREIGN KEY (`parent_id`) REFERENCES `myapp_category` (`id`); Regards, Francis On dim, 2007-08-19 at 13:02 -0700, olivier wrote: > Hi, > > On 19 août, 21:51, Francis Lavoie <[EMAIL PROTECTED]> wrote: > > I'm trying to implement a recursive relationship with a foreignkey, but I > > failed to make it work. > > If I dont use blank=True, the admin interface doesn't let me add the > > category, otherwise I received the error. > > You need also null = True. > > blank is for django, null is for the backend (btw, OperationalError > are always propagated from the backend). > > Regards, > > Olivier > > > > --~--~-~--~~~---~--~~ 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: List comprehension with unique, sorted values
Hi, On 8/19/07, Chris Hoeppner <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hi there! > > I thought this is just the kind of questions you love :) > > I haven't been able to find concise information about this on the net. > > I need to construct a choices var for a field widget at runtime, with > the data from my database. Actually, I want to give a select field > options depending on the values in the database, and since there's no > separate table for those options, and it doesn't make sense creating one > just for this purpose, I resorted to list comprehensions to filter/map a > queryset into a valid choice list. > > It works like a charm, but I'm obviously getting duplicates, and the > choices are not sorted. > > My current code looks like this: > > all_props = Property.objects.all() > rooms_choices = [(p.rooms, p.rooms) for p in all_props] > > Ideally, I'd do something like "for p in all_props if p.rooms not in > rooms_choices" but I have no clue on how to access the being-built list, > nor how to compare to the values inside the tuple. > > Any ideas? :) Yes, .order_by() and set(). I also found a function to remove duplicates from a list, but I'm sure you could also do this on the queryset. :) > ~Chris Kai --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
List comprehension with unique, sorted values
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi there! I thought this is just the kind of questions you love :) I haven't been able to find concise information about this on the net. I need to construct a choices var for a field widget at runtime, with the data from my database. Actually, I want to give a select field options depending on the values in the database, and since there's no separate table for those options, and it doesn't make sense creating one just for this purpose, I resorted to list comprehensions to filter/map a queryset into a valid choice list. It works like a charm, but I'm obviously getting duplicates, and the choices are not sorted. My current code looks like this: all_props = Property.objects.all() rooms_choices = [(p.rooms, p.rooms) for p in all_props] Ideally, I'd do something like "for p in all_props if p.rooms not in rooms_choices" but I have no clue on how to access the being-built list, nor how to compare to the values inside the tuple. Any ideas? :) ~Chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGyKurSyMaQ2t7ZwcRApCMAKDcVkDlodXx5gbL6u5Rc2UgzdM6QwCdHU5H Q4AQ3q9h4dIHVMZhHzZ0afM= =xAbb -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~--- begin:vcard fn:Christian Hoeppner n:Hoeppner;Christian email;internet:[EMAIL PROTECTED] note:I am a freelance coder specialized in web applications and their deployment at a small or medium scale. x-mozilla-html:FALSE version:2.1 end:vcard
Re: Attribute Error
I'll take a look at that. Even commenting that line out and attempting to access self.title I'm still getting an attribute error thrown: 'Register' object has no attribute 'title' On Aug 19, 10:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > As a first guess I'm not sure that user = User is doing what you would > want. I think instead you want to instantiate a new User object. All > you are doing right now is creating an alias user for User. > > On Aug 19, 3:16 pm, MikeHowarth <[EMAIL PROTECTED]> wrote: > > > Hi I was wondering whether anyone can help me out. > > > I'm currently creating a form to register users, what I'm finding is > > that when I then attempt to save the user within the Register:save > > method I'm getting an attribute error when trying to access the title > > attribute. I've tried referencing both title, and self.title to no > > avail. > > > Can anyone advise me on where I'm going wrong with this? > > > class Register(forms.Form): > > > def __init__(self, data=None, request=None, *args, **kwargs): > > if request is None: > > raise TypeError("Keyword argument 'request' must be > > supplied") > > super(Register, self).__init__(data, *args, **kwargs) > > self.request = request > > > #personal information > > title = forms.ChoiceField(choices=titlechoice) > > > def save(self): > > > #set up the objects we are going to populate > > user = User > > user.title = self.title --~--~-~--~~~---~--~~ 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: Attribute Error
As a first guess I'm not sure that user = User is doing what you would want. I think instead you want to instantiate a new User object. All you are doing right now is creating an alias user for User. On Aug 19, 3:16 pm, MikeHowarth <[EMAIL PROTECTED]> wrote: > Hi I was wondering whether anyone can help me out. > > I'm currently creating a form to register users, what I'm finding is > that when I then attempt to save the user within the Register:save > method I'm getting an attribute error when trying to access the title > attribute. I've tried referencing both title, and self.title to no > avail. > > Can anyone advise me on where I'm going wrong with this? > > class Register(forms.Form): > > def __init__(self, data=None, request=None, *args, **kwargs): > if request is None: > raise TypeError("Keyword argument 'request' must be > supplied") > super(Register, self).__init__(data, *args, **kwargs) > self.request = request > > #personal information > title = forms.ChoiceField(choices=titlechoice) > > def save(self): > > #set up the objects we are going to populate > user = User > user.title = self.title --~--~-~--~~~---~--~~ 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: Float Field not displaying the two zeros at the end of a price
On 8/19/07, Greg <[EMAIL PROTECTED]> wrote: > I have a FloatField called price that stores the price of different > elements. When the price is 19.99, 19.79, 19.01 etc... everything is > displayed correctly. However, when I have a price of 19.00. The > price when viewed in a browser is just 19. Is there anyway that I can > have it display the two zeros so that it is displayed as 19.00? If you require two places of precision, regardless of whether they're technically necessary to convey the value (e.g., if you always want 19.00 instead of 19, and 19.50 instead of 19.5), a FloatField is not appropriate. Instead you want a DecimalField with "decimal_places" set to 2: http://www.djangoproject.com/documentation/model-api/#decimalfield -- "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 -~--~~~~--~~--~--~---
Attribute Error
Hi I was wondering whether anyone can help me out. I'm currently creating a form to register users, what I'm finding is that when I then attempt to save the user within the Register:save method I'm getting an attribute error when trying to access the title attribute. I've tried referencing both title, and self.title to no avail. Can anyone advise me on where I'm going wrong with this? class Register(forms.Form): def __init__(self, data=None, request=None, *args, **kwargs): if request is None: raise TypeError("Keyword argument 'request' must be supplied") super(Register, self).__init__(data, *args, **kwargs) self.request = request #personal information title = forms.ChoiceField(choices=titlechoice) def save(self): #set up the objects we are going to populate user = User user.title = self.title --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Float Field not displaying the two zeros at the end of a price
I have a FloatField called price that stores the price of different elements. When the price is 19.99, 19.79, 19.01 etc... everything is displayed correctly. However, when I have a price of 19.00. The price when viewed in a browser is just 19. Is there anyway that I can have it display the two zeros so that it is displayed as 19.00? 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 -~--~~~~--~~--~--~---
clean method for auto generated forms (newforms)
I'm hoping to get a sanity check for how I'm using the clean method. I'm using new forms and I wanted to do a sanity covering the relationship of two different fields. The form as auto created with form_for_instance and friends was just fine, I just needed a "clean()" method of my choosing. I got something working (after trying several very hacky things) and here is the least hacky thing I ended up with. Still seems a little weird to me for some reason. I'd just like some advice on whether this is how it's designed to work or if I'm still missing something. class LabOrderForm(forms.BaseForm): def __init__(self, *s, **kw): forms.BaseForm.__init__(self, *s, **kw) def clean(self): index_number = self.cleaned_data.get('index_number') nih_contract_code = self.cleaned_data.get('nih_contract_code') if index_number: if (index_number.contract_type == 'nih' and not nih_contract_code or index_number.contract_type != 'nih' and nih_contract_code): raise forms.ValidationError('all nih contracts (and only nih contracts) must have an associated contract number') return forms.BaseForm.clean(self) This can then be instantiated with: forms.models.form_for_instance(original_laborder, form=LabOrderForm) Is there a more django-esque to get a custom clean method for an auto- generated form like this or is this the way it's supposed to go? Also it seems that newforms doesn't respect the validator_list in the model, is that correct? As designed? 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 -~--~~~~--~~--~--~---
Modification of URLField
Hello! What should I do to modify behavior of the URLField in the Admin Panel? I'd like to have a field that behaves like the URLField but doesn't require 'http://' part in it's value. Is it possible at all? I never used old style forms, so the code is not very readable to me. Regards -- Jakub Wiśniowski --~--~-~--~~~---~--~~ 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: recursive relationship foreignkey
Hi, On 19 août, 21:51, Francis Lavoie <[EMAIL PROTECTED]> wrote: > I'm trying to implement a recursive relationship with a foreignkey, but I > failed to make it work. > If I dont use blank=True, the admin interface doesn't let me add the > category, otherwise I received the error. You need also null = True. blank is for django, null is for the backend (btw, OperationalError are always propagated from the backend). Regards, Olivier --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Welcome to CHirkut!!
Welcome to Chirkut !! An Online Community site for Friends... visit www.chirkut.co.in Chirkut is an online community website designed for friends. The main goal of our service is to make your social life, and that of your friends, more active and stimulating. Chirkut`s social network can help you both maintain existing relationships and establish new ones by reaching out to people you`ve never met before. At Chirkut we pay due credits to everyone who helps us making this site a better place. Please Help us in building the network. Invite all your friends to join Chirkut. -Chirkut Team --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
recursive relationship foreignkey
Hi, I'm trying to implement a recursive relationship with a foreignkey, but I failed to make it work. My goal is to have a table containing different categories and sub categories of equipment. the relationship with 'self' is for the subcategories. But I can't create the Master categories. here's my error: Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 77, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.5/site-packages/django/contrib/admin/views/decorators.py", line 55, in _checklogin return view_func(request, *args, **kwargs) File "/usr/lib/python2.5/site-packages/django/views/decorators/cache.py", line 39, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/usr/lib/python2.5/site-packages/django/contrib/admin/views/main.py", line 261, in add_stage new_object = manipulator.save(new_data) File "/usr/lib/python2.5/site-packages/django/db/models/manipulators.py", line 110, in save new_object.save() File "/usr/lib/python2.5/site-packages/django/db/models/base.py", line 247, in save ','.join(placeholders)), db_values) File "/usr/lib/python2.5/site-packages/MySQLdb/cursors.py", line 164, in execute self.errorhandler(self, exc, value) File "/usr/lib/python2.5/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue OperationalError: (1048, "Column 'parent_id' cannot be null") here's my object : class Category(models.Model): name = models.CharField(max_length=36) description = models.CharField(max_length=200) parent = models.ForeignKey('self',blank=True) class Admin: # Admin options go here pass If I dont use blank=True, the admin interface doesn't let me add the category, otherwise I received the error. Any help would be appreciated. Thank you Francis --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
User templates: store in the db or as files on the server?
I want templates to be accessible and editable via my admin interface (not *the* admin). My question is about the best way to achieve this? Should templates be stored in the database? Or should they be stored in a templates directory and sucked into a textarea for editing? This is for a multi-user app (so every user could have totally different templates). User interaction for both would be the same. Go to the area of the admin where you edit templates, select the template you want to edit, and the template appears in a textarea for you to edit. Saving stores the template, and your changes are immediately visible. (MovableType will store templates in the database, but it will also link the template "to a file" where it uses a file on the server for the template instead of pulling it out of the database.) Any thoughts or advice? Thanks, -- Austin Govella Thinking & Making: IA, UX, and IxD http://thinkingandmaking.com [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: TIME_ZONE setting: How does it work?
Malcom, Thank you for the elaborate explanation. That fixed the problem, and I actually understood it ;) Michael > -Original Message- > From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED] > On Behalf Of Malcolm Tredinnick > Sent: Sunday, August 19, 2007 11:54 AM > To: django-users@googlegroups.com > Subject: Re: TIME_ZONE setting: How does it work? > > > On Sun, 2007-08-19 at 11:15 +0200, Michael Elsdoerfer wrote: > > I'm having some trouble with time zones on my production machine > (debian, > > apache prefork with mod_python). On Windows, everything works as > expected. > > I'm running the trunk from maybe two weeks ago. > > More accurately, on Windows, Django's timezone stuff does absolutely > nothing. Setting timezones on Windows requires code we don't have > (there's an open invitation for somebody to write the necessary code if > they need it), so we don't modify the environment at all. > > > Basically, I have TIME_ZONE = 'GMT+1', but while > datetime.datetime.today() > > in a vanilla python shell returns the correct date, the same in > manage.py > > shell does not (off by 3 hours). > > You've fallen into a common trap with POSIX timezone specifications, > which is what are being used here. > > The string "GMT+1" actually means (in POSIX terms) "my timezone is > called 'GMT' and it is one hour *west* of the Prime Meridian." The > format is parsed as "name + offset" where offset is negative for East > and positive for West -- it's the number of hours you add to localtime > to get UTC, instead of vice-versa. > > Based on your e-mail headers, it looks like you are in the Central > European timezone and, since it's summer time, one hour behind UTC (west > of the Prime Meridian) is three hours behind your current timezone, > which is what you are seeing. > > So, either use something like "CET-2" or use the more descriptive names. > These names used to be in the PostgreSQL documentation, but I just > noticed that they have been removed in the latest version. So check a > slightly older version of the PostgreSQL documentation (using a similar > link to that in settings.py above TIME_ZONE) for some examples. > > > While I try to figure this out, allow me a more general question. It > seems > > every time I change the time zone, the date that gets written to my > MySQL > > database changes. > > > > Frankly, what I would have expected is: The values stored in the backend > > remain the same, only when read are interpreted differently. Isn't that > how > > it *should* work? Although I am always confused by time zones, so maybe > I'm > > way off here. > > Django doesn't support datetime fields with timezones. Instead, it > writes the time to the database using the local time (as configured via > the TIME_ZONE setting). This isn't particularly optimal in a number of > cases, but reflects Django's historical usage where the server was only > serving one timezone and never changing, etc. I would expect that to be > fixed in some fashion in the future, because it's hardly uncommon to > have to store multiple time-zoned information (even the Lawrence guys > are discovering this, I gather). There are also problems with corrupting > the environment for other processes by setting the TZ environment > variable. > > Tom Tobin has opened a ticket in Trac, volunteering to take on this > effort. I am fully behind it in the broader sense (although he doesn't > seem to have proposed using timezone-aware database fields yet, which is > the best solution a lot of times). > > > What am I missing? > > Don't let your assumptions lead you around by the nose. :-) > > Cheers, > Malcolm > > -- > Honk if you love peace and quiet. > http://www.pointy-stick.com/blog/ > > > --~--~-~--~~~---~--~~ 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: Question: trailing escaped character in a href=""?
Sorry, I got confused about your input question re: the note integer. (The confusion is from my accidental use of single quotes around the input note value.) I'm afraid I'm not using any buggy middleware, unless the stuff in django.contrib is buggy. I'll investigate to see if will successfully point to , though I have my doubts! On Aug 19, 1:00 pm, olivier <[EMAIL PROTECTED]> wrote: > > def note_anchor(self): > > return int(self.note) > > If it's already an integer, you don't need to do this,do you ? > > Otherwise, are you not using a buggy middleware that tries to > refactors your html to make it valid XHTML ? > > If not, I'm afraid I don't have any clues... > > Olivier --~--~-~--~~~---~--~~ 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: wiki design
Hi Carl, On 8/19/07, Carl Karsten <[EMAIL PROTECTED]> wrote: > > I am trying do design a iddy biddy site that will replace a site that is only > about 8 static pages. I want to make it wiki-ish, so the 'site admin' can > tweak > things now and then, and it needs pictures. so sort of a hybrid between a > wiki > and a gallery. > > I figure I need models.FileField() but not really sure what it would do other > than provide a way for the user (admin) to upload jpg's which I could probably > do with a simple upload form, but having the admin UI seems like it might add > something. > > anyone seen anything like this, or have any ideas? Do you mean something like this? http://code.google.com/p/django-databasetemplateloader/ For the image inclusion, I created an Image model and a template filter that replaces a placeholder with the image url. Kai --~--~-~--~~~---~--~~ 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: Question: trailing escaped character in a href=""?
> def note_anchor(self): > return int(self.note) If it's already an integer, you don't need to do this,do you ? Otherwise, are you not using a buggy middleware that tries to refactors your html to make it valid XHTML ? If not, I'm afraid I don't have any clues... Olivier --~--~-~--~~~---~--~~ 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: Question: trailing escaped character in a href=""?
No, I'm using MySQL. The same thing happens with a SlugField, so I'm not sure if the string/integer difference matters here. To return 'note' as an integer, would I write: def note_anchor(self): return int(self.note) or something else? On Aug 19, 12:21 pm, olivier <[EMAIL PROTECTED]> wrote: > Hi, > > On 19 août, 19:07, Drasty <[EMAIL PROTECTED]> wrote: > > > class Thing(models.Model): > > words = models.TextField() > > note = models.IntegerField() > > > def note_anchor(self): > > return self.note > > > (Input:) > > > words = 'Blah blah.' > > note = '1' > > In your example, you input `note` as a string, whereas `note` is an > IntegerField. > > Is it a typo ? > What database backend are you using ? Sqlite, I guess ? > > Olivier --~--~-~--~~~---~--~~ 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: A IntegerField can't have value=0 when blank=False???
On Sun, 2007-08-19 at 17:31 +, SH wrote: > I wanted to ask here before I post a ticket. > > If you have an integer field in your model, it can't equal zero if the > field is required (blank=False) That would definitely be a bug. Regards, Malcolm -- Everything is _not_ based on faith... take my word for it. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
A IntegerField can't have value=0 when blank=False???
I wanted to ask here before I post a ticket. If you have an integer field in your model, it can't equal zero if the field is required (blank=False) Here's the code out of Field.validate_full that causes this: if not self.blank and not field_data: return [_('This field is required.')] Am I missing something here??? Starr --~--~-~--~~~---~--~~ 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: Question: trailing escaped character in a href=""?
Hi, On 19 août, 19:07, Drasty <[EMAIL PROTECTED]> wrote: > class Thing(models.Model): > words = models.TextField() > note = models.IntegerField() > > def note_anchor(self): > return self.note > > (Input:) > > words = 'Blah blah.' > note = '1' In your example, you input `note` as a string, whereas `note` is an IntegerField. Is it a typo ? What database backend are you using ? Sqlite, I guess ? Olivier --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Question: trailing escaped character in a href=""?
I'm getting an escaped double quotation mark (", rendered as '%22') at the end of some stuff that I'm using to reference an anchor on the same page. This isn't a problem in templates, since the links and corresponding anchors are generated. But if I want to enter a link in, say, a TextField to one of those anchors, it becomes a bit tedious. I'm wondering if there's a way for me to get rid of that apparently automatically generated character. Here's an example, with the escaped character in the "Output" section: (Code:) class Thing(models.Model): words = models.TextField() note = models.IntegerField() def note_anchor(self): return self.note (Template:) Note {{ thing.note }} {{ thing.words }} (Input:) words = 'Blah blah.' note = '1' (Output:) Note 1 Blah blah. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ImageField via admin
Hello! I have simple class with ImageField, but cann't add any object: class Book(models.Model): name = models.CharField(_('Book Title'), maxlength=200) book_number = models.IntegerField() image = models.ImageField(upload_to='%Y/%m/%d/', core=True, blank=True) comment = models.TextField(_('Book Comment'), blank=True, null=True) author = models.CharField(_('Author'), maxlength=100, blank=True) year_rate = models.IntegerField() class Meta: verbose_name = _('Book') verbose_name_plural = _('Books') class Admin: list_display = ('book_number', 'name', 'year_rate') def __unicode__(self): return u"%s %s %s" % (self.book_number, self.name, self.year_rate) the error: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" in _checklogin 51. if 'post_data' in request.POST: File "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in _get_post 135. self._load_post_and_files() File "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in _load_post_and_files 113. self._post, self._files = http.parse_file_upload(self.environ['wsgi.input'], self.environ) File "/usr/lib/python2.4/site-packages/django/http/__init__.py" in parse_file_upload 71. raw_message = '\r\n'.join(['%s:%s' % pair for pair in header_dict.items()]) AttributeError at /admin/books/book/add/ '_fileobject' object has no attribute 'items' What the problem it can be? -- Всего наилучшего! Григорий greg [at] anastasia [dot] ru Письмо отправлено: 2007/08/19 18:05 -- Всего наилучшего! Григорий greg [at] anastasia [dot] ru Письмо отправлено: 2007/08/19 18:11 --~--~-~--~~~---~--~~ 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: TIME_ZONE setting: How does it work?
On Sun, 2007-08-19 at 19:54 +1000, Malcolm Tredinnick wrote: [...] > So, either use something like "CET-2" or use the more descriptive names. > These names used to be in the PostgreSQL documentation, but I just > noticed that they have been removed in the latest version. So check a > slightly older version of the PostgreSQL documentation (using a similar > link to that in settings.py above TIME_ZONE) for some examples. Probably the best list at the moment is http://en.wikipedia.org/wiki/List_of_tz_zones_by_name with an explanation at http://en.wikipedia.org/wiki/Zoneinfo One thing I forgot to mention and it's important: A big advantage of using the zoneinfo name for your timezone is the underlying C library will then return the daylight-saving-aware version of the time. Whereas if you use something like 'XYZ-1' it will *always* be one hour ahead of UTC, since it is a location-independent specification -- no daylight savings rules come into play. So, as a general rule, use the zoneinfo form (Europe/Vienna, etc). Regards, Malcolm -- On the other hand, you have different fingers. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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: TIME_ZONE setting: How does it work?
On Sun, 2007-08-19 at 11:15 +0200, Michael Elsdoerfer wrote: > I'm having some trouble with time zones on my production machine (debian, > apache prefork with mod_python). On Windows, everything works as expected. > I'm running the trunk from maybe two weeks ago. More accurately, on Windows, Django's timezone stuff does absolutely nothing. Setting timezones on Windows requires code we don't have (there's an open invitation for somebody to write the necessary code if they need it), so we don't modify the environment at all. > Basically, I have TIME_ZONE = 'GMT+1', but while datetime.datetime.today() > in a vanilla python shell returns the correct date, the same in manage.py > shell does not (off by 3 hours). You've fallen into a common trap with POSIX timezone specifications, which is what are being used here. The string "GMT+1" actually means (in POSIX terms) "my timezone is called 'GMT' and it is one hour *west* of the Prime Meridian." The format is parsed as "name + offset" where offset is negative for East and positive for West -- it's the number of hours you add to localtime to get UTC, instead of vice-versa. Based on your e-mail headers, it looks like you are in the Central European timezone and, since it's summer time, one hour behind UTC (west of the Prime Meridian) is three hours behind your current timezone, which is what you are seeing. So, either use something like "CET-2" or use the more descriptive names. These names used to be in the PostgreSQL documentation, but I just noticed that they have been removed in the latest version. So check a slightly older version of the PostgreSQL documentation (using a similar link to that in settings.py above TIME_ZONE) for some examples. > While I try to figure this out, allow me a more general question. It seems > every time I change the time zone, the date that gets written to my MySQL > database changes. > > Frankly, what I would have expected is: The values stored in the backend > remain the same, only when read are interpreted differently. Isn't that how > it *should* work? Although I am always confused by time zones, so maybe I'm > way off here. Django doesn't support datetime fields with timezones. Instead, it writes the time to the database using the local time (as configured via the TIME_ZONE setting). This isn't particularly optimal in a number of cases, but reflects Django's historical usage where the server was only serving one timezone and never changing, etc. I would expect that to be fixed in some fashion in the future, because it's hardly uncommon to have to store multiple time-zoned information (even the Lawrence guys are discovering this, I gather). There are also problems with corrupting the environment for other processes by setting the TZ environment variable. Tom Tobin has opened a ticket in Trac, volunteering to take on this effort. I am fully behind it in the broader sense (although he doesn't seem to have proposed using timezone-aware database fields yet, which is the best solution a lot of times). > What am I missing? Don't let your assumptions lead you around by the nose. :-) Cheers, Malcolm -- Honk if you love peace and quiet. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
TIME_ZONE setting: How does it work?
I'm having some trouble with time zones on my production machine (debian, apache prefork with mod_python). On Windows, everything works as expected. I'm running the trunk from maybe two weeks ago. Basically, I have TIME_ZONE = 'GMT+1', but while datetime.datetime.today() in a vanilla python shell returns the correct date, the same in manage.py shell does not (off by 3 hours). While I try to figure this out, allow me a more general question. It seems every time I change the time zone, the date that gets written to my MySQL database changes. Frankly, what I would have expected is: The values stored in the backend remain the same, only when read are interpreted differently. Isn't that how it *should* work? Although I am always confused by time zones, so maybe I'm way off here. What am I missing? Thanks, Michael --~--~-~--~~~---~--~~ 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: UnicodeEncodeError in template rendering
On Sun, 2007-08-19 at 08:19 +, cesco wrote: > Thanks a lot Malcolm, I think we are getting there:-) > > > So, have a look at the debug screen and click on the "local variables" > > link just below this last line in the extended traceback. What is "s" > > here (in particular, it would be good know what type(s) is)? Also, what > > is the value of 'encoding'? > > Here are the values. > encoding: u'utf-8' > errors: u'strict' > s: > strings_only: False [...] > > Hope I was able to report all the information. If the problem is, like > you suspect, the patch I applied, do you have any suggestion on how to > solve the problem? Maybe modify the patch itself following the > guidelines for transition to Unicode? As suspected, it's the Thumbnail field that isn't handling non-ASCII filenames well. Use the instructions in [1] to port the URL display stuff (this is unicode.txt in the source tree, as well). The simple 5-step plan for porting to Unicode won't be quite enough in this case. Just giving the model a unicode method probably isn't enough, because you are still responsible for encoding the URL correctly. [1] http://www.djangoproject.com/documentation/unicode/#uri-and-iri-handling Regards, Malcolm -- Monday is an awful way to spend 1/7th of your life. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 install mysql-python
Yes the problem was with python-devel. After installing all the depndebcies, it went through fine. On Aug 19, 1:20 pm, Thejaswi Puthraya <[EMAIL PROTECTED]> wrote: > On Aug 19, 1:16 pm, shabda <[EMAIL PROTECTED]> wrote: > > > But even that is not helping. I am on a centOS box, with python > > 2.3.4. > > Since you are on CentOS and yum works...use yum to install python- > devel,mysql-devel,zlib-devel,openssl-devel > > and then try compiling MySQL-python...I believe it should work. > > Cheers > Thejaswi Puthraya --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
live bookmark equivalent in IE
Hi guys, we created some RSS feeds from our website using the django syndication framework and things are working fine from firefox! And we want the same functionality to be available in other browsers, specially Internet explorer. We checked several addons for IE but still couldnt find anything that is as fast and efficient as the livebookmarks of firefox, i.e. just clicking on our link to the feed simply leading to the addition of the RSS feed. I know this is not directly related to django but maybe some of you have come across some addon for Internet explorer that is very similar to live bookmarks? thanks a lot! Oumer --~--~-~--~~~---~--~~ 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 install mysql-python
On Aug 19, 1:16 pm, shabda <[EMAIL PROTECTED]> wrote: > But even that is not helping. I am on a centOS box, with python > 2.3.4. Since you are on CentOS and yum works...use yum to install python- devel,mysql-devel,zlib-devel,openssl-devel and then try compiling MySQL-python...I believe it should work. Cheers Thejaswi Puthraya --~--~-~--~~~---~--~~ 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: UnicodeEncodeError in template rendering
Thanks a lot Malcolm, I think we are getting there:-) > So, have a look at the debug screen and click on the "local variables" > link just below this last line in the extended traceback. What is "s" > here (in particular, it would be good know what type(s) is)? Also, what > is the value of 'encoding'? Here are the values. encoding: u'utf-8' errors: u'strict' s: strings_only: False > what is the current value of 'b' (and it's type) > in the previous line of the traceback? Again, using the "locals" link on > the debug page should be able to tell you this. b: Hope I was able to report all the information. If the problem is, like you suspect, the patch I applied, do you have any suggestion on how to solve the problem? Maybe modify the patch itself following the guidelines for transition to Unicode? Thanks a ton Francesco --~--~-~--~~~---~--~~ 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 install mysql-python
Trying the solution given at http://mail.python.org/pipermail/pythonmac-sig/2003-February/007223.html But even that is not helping. I am on a centOS box, with python 2.3.4. Tried the following things, 1. Added to setup.py thread_safe_library = NO (NameError: name 'NO' is not defined) removed that line. 2. Added, include_dirs = [ '/usr/include/mysql', '/usr/local/include/mysql', '/usr/local/mysql/include/mysql' ] library_dirs = [ '/sw/lib/mysql', '/sw/lib' ] $ python setup.py build . . _mysql.c:2815: error: request for member `ob_type' in something not a structure or union _mysql.c:2827: error: `Py_eval_input' undeclared (first use in this function) _mysql.c:2834: error: syntax error before ')' token _mysql.c:2838: error: syntax error before ')' token _mysql.c:2878: warning: assignment makes pointer from integer without a cast _mysql.c:2883: error: `PyExc_ImportError' undeclared (first use in this function) error: command 'gcc' failed with exit status 1 3. cd /sw/lib/mysql (that file is not on my system) So unabl;e to build the MySQL-python-1.2.2 library. On Aug 19, 12:52 pm, shabda <[EMAIL PROTECTED]> wrote: > I am trying to setup django with mysql, After installing django and > mysql I am trying to set up mysql-python. > So I give the command > $ easy_install MySQL-python > And am getting a ton of errors. > On the pagehttp://www.djangobook.com/en/beta/chapter02/, under > comments for mysql it says, > "Don't forget when building MySQLDB MySQL needs to be in the path. If > it isn't you will get tons of errors. ;)" > I think this might be my problem. How do I do 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: How to install mysql-python
On Aug 19, 12:52 pm, shabda <[EMAIL PROTECTED]> wrote: > I am trying to setup django with mysql, After installing django and > mysql I am trying to set up mysql-python. > So I give the command > $ easy_install MySQL-python > And am getting a ton of errors. > On the pagehttp://www.djangobook.com/en/beta/chapter02/, under > comments for mysql it says, > "Don't forget when building MySQLDB MySQL needs to be in the path. If > it isn't you will get tons of errors. ;)" > I think this might be my problem. How do I do this? Mysqldb has certain dependencies to be to be fulfilled like "build-requires = python-devel mysql-devel zlib-devel openssl- devel" (pasting from setup.cfg). Check if you have these dependencies installed. Certain Linux Distributions like Debian, Ubuntu offer the latest Mysqldb package through their package managers (don't try this if you are on Fedora). I would recommend you install it from http://sourceforge.net/projects/mysql-python Cheers Thejaswi Puthraya --~--~-~--~~~---~--~~ 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: Ajax Form Submission Trouble
> Thanks a bunch, but would that go into the markup or into the > comments.js file? I'm a js newb (really bad one). I'm guessing into > the js file, the submit button doesn't have an id. Here is my current > comments.js filehttp://dpaste.com/17243/ It would go into your template and not into your js file...it is recommended that you have an id for your submit button. Cheers Thejaswi Puthraya --~--~-~--~~~---~--~~ 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: Ajax Form Submission Trouble
On Aug 19, 1:29 am, Thejaswi Puthraya <[EMAIL PROTECTED]> wrote: > > I'm using mochikit > > Try, > > onclick="$('button_id').disabled=true;" > > It is 'disabled' and not 'disable'. > Check out button properties > athttp://www.w3schools.com/htmldom/dom_obj_button.asp > According the W3Schools...disabled works since IE5.0...so I see no > reason why it shouldn't work in IE7.0 > > Cheers > Thejaswi Puthraya Thanks a bunch, but would that go into the markup or into the comments.js file? I'm a js newb (really bad one). I'm guessing into the js file, the submit button doesn't have an id. Here is my current comments.js file http://dpaste.com/17243/ --~--~-~--~~~---~--~~ 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 install mysql-python
I am trying to setup django with mysql, After installing django and mysql I am trying to set up mysql-python. So I give the command $ easy_install MySQL-python And am getting a ton of errors. On the page http://www.djangobook.com/en/beta/chapter02/, under comments for mysql it says, "Don't forget when building MySQLDB MySQL needs to be in the path. If it isn't you will get tons of errors. ;)" I think this might be my problem. How do I do 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: UnicodeEncodeError in template rendering
On Sun, 2007-08-19 at 00:27 -0700, cesco wrote: > Thanks for your replies. > > Just to avoid any doubt, I'm using __unicode__ instead of __str__ and > I'm using the latest development version of django (post unicode > merge). > > > What is most important to know is (a) what is the data that it is > > trying to render (both type and content). > > It's trying to render an object of the class > 'my_project.offers.models.Offer', which contains, among other fields, > a "name" field (that is models.CharField, which in some cases contains > danish characters) and a picture field (that is models.ImageField). > > In the page I'm trying to render I display > 1. a thumbnail of such image using the patch from > http://code.djangoproject.com/ticket/4115 > which is located in django.contrib.thumbnails. This might be the problem. Looking at the last patch on #4115, it hasn't been updated to handle the Unicode changes on trunk. It provides a __str__ method (which isn't wrong), but it doesn't ensure that the output of get_url() is UTF-8 encoded. Maybe there should be a call to django.utils.encoding.iri_to_uri() in there or maybe more changes are needed. [...] > Exception Type: UnicodeEncodeError > Exception Value: 'ascii' codec can't encode character u'\xe6' in > position 27: ordinal not in range(128) > Exception Location: C:\Python25\lib\site-packages\django\utils > \encoding.py in force_unicode, line 39 > Unicode error hint: The string that could not be encoded/decoded was: > roanlæg > > Traceback (most recent call last): > File "C:\Python25\lib\site-packages\django\template\__init__.py" in > render_node > 754. result = node.render(context) > File "C:\Python25\lib\site-packages\django\template\defaulttags.py" in > render > 134. nodelist.append(node.render(context)) > File "C:\Python25\lib\site-packages\django\template\defaulttags.py" in > render > 134. nodelist.append(node.render(context)) > File "C:\Python25\lib\site-packages\django\template\loader_tags.py" in > render > 96. return self.template.render(context) > File "C:\Python25\lib\site-packages\django\template\__init__.py" in > render > 181. return self.nodelist.render(context) > File "C:\Python25\lib\site-packages\django\template\__init__.py" in > render > 739. return ''.join([force_unicode(b) for b in bits]) > File "C:\Python25\lib\site-packages\django\utils\encoding.py" in > force_unicode > 39. s = unicode(str(s), encoding, errors) This is interesting (the last line). It means that whatever "s" is here, it doesn't have a __unicode__ method. Again, this isn't necessarily bad, but it's not clear that it should be raising an encoding exception. So, have a look at the debug screen and click on the "local variables" link just below this last line in the extended traceback. What is "s" here (in particular, it would be good know what type(s) is)? Also, what is the value of 'encoding'? If 's' doesn't look very interesting (i.e. it claims to be a string or something like that), what is the current value of 'b' (and it's type) in the previous line of the traceback? Again, using the "locals" link on the debug page should be able to tell you this. If you can't see the type of s, print it out to a file by changing that line to something like: try: s = unicode(str(s), encoding, errors) except: # print type(s) and repr(s) to a file raise I'm not completely sure why the "ascii" encoding comes into play here unless there is no explicit __str__ method on whatever 's' is. So this should help us get the necessary information to go a bit further. Find out that information and report back; we should be able to work this out. Regards, Malcolm -- If Barbie is so popular, why do you have to buy her friends? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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: UnicodeEncodeError in template rendering
Thanks for your replies. Just to avoid any doubt, I'm using __unicode__ instead of __str__ and I'm using the latest development version of django (post unicode merge). > What is most important to know is (a) what is the data that it is > trying to render (both type and content). It's trying to render an object of the class 'my_project.offers.models.Offer', which contains, among other fields, a "name" field (that is models.CharField, which in some cases contains danish characters) and a picture field (that is models.ImageField). In the page I'm trying to render I display 1. a thumbnail of such image using the patch from http://code.djangoproject.com/ticket/4115 which is located in django.contrib.thumbnails. 2. the name of the picture/offer which may contain danish characters. Every time I reload the page, 6 offers objects are pulled randomly from all the available ones. If those objects contain a danish character in their name (like 'æ') then I get the UnicodeEncodeError (please, note the previous title of this post was UnicodeDecodeError while it's actually a UnicodeEncodeError). If the objects don't contain any danish character then I don't get any problem. If I print to a file the repr() of the object then I get the right danish characters. Only in the template rendering for some reason there is this problem. I'm using sqlite3 with the development server and python 2.5 Following are the information I had given before (which I repeat here for completeness) and the full traceback I get from the template error. Exception Type: UnicodeEncodeError Exception Value: 'ascii' codec can't encode character u'\xe6' in position 27: ordinal not in range(128) Exception Location: C:\Python25\lib\site-packages\django\utils \encoding.py in force_unicode, line 39 Unicode error hint: The string that could not be encoded/decoded was: roanlæg Traceback (most recent call last): File "C:\Python25\lib\site-packages\django\template\__init__.py" in render_node 754. result = node.render(context) File "C:\Python25\lib\site-packages\django\template\defaulttags.py" in render 134. nodelist.append(node.render(context)) File "C:\Python25\lib\site-packages\django\template\defaulttags.py" in render 134. nodelist.append(node.render(context)) File "C:\Python25\lib\site-packages\django\template\loader_tags.py" in render 96. return self.template.render(context) File "C:\Python25\lib\site-packages\django\template\__init__.py" in render 181. return self.nodelist.render(context) File "C:\Python25\lib\site-packages\django\template\__init__.py" in render 739. return ''.join([force_unicode(b) for b in bits]) File "C:\Python25\lib\site-packages\django\utils\encoding.py" in force_unicode 39. s = unicode(str(s), encoding, errors) UnicodeEncodeError at / 'ascii' codec can't encode character u'\xe6' in position 27: ordinal not in range(128) I'm struggling with this problem from quite some time. Any help would be very appreciated. Thanks Francesco --~--~-~--~~~---~--~~ 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: Ajax Form Submission Trouble
> I'm using mochikit Try, onclick="$('button_id').disabled=true;" It is 'disabled' and not 'disable'. Check out button properties at http://www.w3schools.com/htmldom/dom_obj_button.asp According the W3Schools...disabled works since IE5.0...so I see no reason why it shouldn't work in IE7.0 Cheers Thejaswi Puthraya --~--~-~--~~~---~--~~ 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 install django on Apache/Linux
On 8/19/07, shabda <[EMAIL PROTECTED]> wrote: > I am *very* confused here, I have only installed mod_python, and > nothing specific to django. SO how would the line > PythonHandler django.core.handlers.modpython work? If you have Django installed on the server and on the Python path, it will work. > And what do I specify in > SetEnv DJANGO_SETTINGS_MODULE mysite.settings > If my site is under /var/www/html/python, with the settings file as / > var/www/html/python/foo/settings.py should I write, > SetEnv DJANGO_SETTINGS_MODULE foo.settings > (or) SetEnv DJANGO_SETTINGS_MODULE python.foo.settings If 'python' is the directory that's on the Python path, you want 'foo.settings'. Keep in mind, though, that it's generally a *bad* idea to place your Python code in the document root of the server (assuming that's what you've done since you say it's in /var/www/html); if anything ever goes wrong with mod_python and it serves those as plain-text files instead of routing to the Django handler, your code could be exposed for all the world to see. And remember that the Python code can live anywhere on the server, as long as: 1. The directory it's in is on the Python import path, and 2. Apache has the appropriate permissions to read that directory (it won't need to be able to write, just read). -- "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 -~--~~~~--~~--~--~---
How to install django on Apache/Linux
I have apache installed on linux with mod_php, mysql. I am trying to get django working here, and am following the intsallation steps at http://www.djangobook.com/en/beta/chapter21/ . Step 1. Install mod_python did yum install mod_python. Checked that mod_python is installed. Step 2. Add this to your httpd.conf SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonDebug On I am *very* confused here, I have only installed mod_python, and nothing specific to django. SO how would the line PythonHandler django.core.handlers.modpython work? And what do I specify in SetEnv DJANGO_SETTINGS_MODULE mysite.settings If my site is under /var/www/html/python, with the settings file as / var/www/html/python/foo/settings.py should I write, SetEnv DJANGO_SETTINGS_MODULE foo.settings (or) SetEnv DJANGO_SETTINGS_MODULE python.foo.settings --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---