Internationalized URLs
Hello, I'm trying to find the best approach to have multiple languages urls on reusable apps but I can't find a good way to do it and I couldn't find any useful information around. I am not sure if the best is just to do something like this: url(r'^%s/$' % _('mymultipath'),myview,name='myviewname') or using multiple url files which violates the DRY principal or if there's a better approach, since I don't know what happens with the first example when we change the locale on the fly any opinions? Anderson --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Error with unittests for django.contrib.auth: ERROR: Error is raised if the provided email address isn't currently registered
Hello, I've run on the same problem and now I see that all my custom templates overrides the default template. I checked that if I rename my custom project/templates/registration folder to something else the test runs ok, but if I rename the template so it doesn't conflicts, it will work fine. When I print the settings.TEMPLATE_DIRS on AuthViewsTestCase, I see that it's correctly pointing to auth/templates path, but on any method of PasswordResetTest, it's pointing to the default templates folder. When I added the code to set the TEMPLATE_DIRS on PasswordResetTest, it worked fine, since we're overriding the setup method, and therefore it will not use the code of the parent class. So, is it expected, should the django's auth application use the default project templates and override the urlconf on PasswordResetTest? Anderson On Sep 21, 11:09 am, tom wrote: > Hi, > > i use django-1.1 withdjango.contrib.authand django-registration. > When i run theunittests, i become anerror. Anybody has an idea? > > ./manage.py test auth --settings=develsettings > /usr/lib/pymodules/python2.6/registration/models.py:4: > DeprecationWarning: the sha module is deprecated; use the hashlib > module instead > import sha > Creating test database... > Creating table django_admin_log > Creating table auth_permission > Creating table auth_group > Creating table auth_user > Creating table auth_message > Creating table django_content_type > Creating table django_session > Creating table django_site > Creating table project_project > Creating table logger_logger > Creating table sensor_sensor > Creating table data_originalfile > Creating table data_entry > Creating table data_measurand > Creating table message_loggerwarning > Creating table registration_registrationprofile > Installing index for admin.LogEntry model > Installing index for auth.Permission model > Installing index for auth.Message model > Installing index for project.Project model > Installing index for logger.Logger model > Installing index for sensor.Sensor model > Installing index for data.OriginalFile model > Installing index for data.Entry model > Installing index for data.Measurand model > Installing index for message.LoggerWarning model > FFE... > ==ERROR:Erroris > raised if the provided email address isn't currently > registered > -- > Traceback (most recent call last): > File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/ > views.py", line 52, in test_email_not_found > response = self.client.get('/password_reset/') > File "/usr/lib/pymodules/python2.6/django/test/client.py", line 281, > in get > response = self.request(**r) > File "/usr/lib/pymodules/python2.6/django/test/client.py", line 225, > in request > response = self.handler(environ) > File "/usr/lib/pymodules/python2.6/django/test/client.py", line 69, > in __call__ > response = self.get_response(request) > File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py", > line 134, in get_response > return self.handle_uncaught_exception(request, resolver, exc_info) > File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py", > line 166, in handle_uncaught_exception > return callback(request, **param_dict) > File "/usr/lib/pymodules/python2.6/django/views/defaults.py", line > 24, in server_error > return http.HttpResponseServerError(t.render(Context({}))) > File "/usr/lib/pymodules/python2.6/django/test/utils.py", line 29, > in instrumented_test_render > return self.nodelist.render(context) > File "/usr/lib/pymodules/python2.6/django/template/__init__.py", > line 779, in render > bits.append(self.render_node(node, context)) > File "/usr/lib/pymodules/python2.6/django/template/debug.py", line > 71, in render_node > result = node.render(context) > File "/usr/lib/pymodules/python2.6/django/template/loader_tags.py", > line 97, in render > return compiled_parent.render(context) > File "/usr/lib/pymodules/python2.6/django/test/utils.py", line 29, > in instrumented_test_render > return self.nodelist.render(context) > File "/usr/lib/pymodules/python2.6/django/template/__init__.py", > line 779, in render > bits.append(self.render_node(node, context)) > File "/usr/lib/pymodules/python2.6/django/template/debug.py", line > 71, in render_node > result = node.render(context) > File "/usr/lib/pymodules/python2.6/django/template/defaulttags.py", > line 244, in render > return self.nodelist_false.render(context) > File "/usr/lib/pymodules/python2.6/django/template/__init__.py", > line 779, in render > bits.append(self.render_node(node, context)) > File "/usr/lib/pymodules/python2.6/django/template/debug.py", line > 81, in render_node > raise wrapped > TemplateSyntaxError: Caught an exception while rendering: Reverse for > 'auth_login' wi
Re: Microsoft using Django?
Dãr, it was a IE bug displaying a error message from my own server. Sorry On 6 mar, 20:12, Anderson Santos wrote: > I tried to access a file from Microsoft website I got a Django error, are > they really using Django? (It's not phising or spam, just copy and paste the > link) > > http://download.microsoft.com/download/f/3/c/f3c93e70-ccdc-46c9-bbd4-... > > Cheers, > > Anderson --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Microsoft using Django?
I tried to access a file from Microsoft website I got a Django error, are they really using Django? (It's not phising or spam, just copy and paste the link) http://download.microsoft.com/download/f/3/c/f3c93e70-ccdc-46c9-bbd4-70d94bdd0cc9/IEDevToolBarSetup.msi/ Cheers, Anderson --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best practice to build a multilingual site
I was using i18ndynamic (http://djangoplugables.com/projects/ i18ndynamic/) for a website, on our new project I prefered not to use afraid of performance issues. We are going to achieve something like Cortland said, but we're still analyzing the possibilities. The main issue is an easy to use admin interface, and if you have image fields, how will be their behavior, one image per language, one image in general. So you really have to think what's the best approach for your project, consider taking a look into current implementations to have an idea, there's about three different approaches for that in djangoplugables.com . Cheers, Anderson On Oct 13, 4:20 pm, Cortland Klein <[EMAIL PROTECTED]> wrote: > It depends on if a particular News is shared across languages, or if > each language has its own news. > > For me, one of my projects has translations of objects where each > object should have all translations. Thus, I have something like a > News and then NewsTranslations with ForeignKey back to News. Then I > just do News.objects.filter(newstranslations__lang=lang) or whatever. > > In admin I'd then have NewsAdmin inline a NewsTranslationsInline or > something. > > On Oct 13, 2008, at 8:48 AM, Alex Rades wrote: > > > Hi, > > if we have a model like: > > > class News(models.Model): > > title = models.CharField(..) > > content = models.TextField(...) > > > Imagine i want to work with different language (this means adding > > multilingual content via admin and retrieving it from views/templates) > > What is the best way to develop this kind of multi language support? > > (Of course I dont want to add title_en title_es... ) > > > Thank you > > -- > Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791http://pixelcort.com/ > 2260 California Street #13 > Mountain View, CA, USA 94040 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Add custom filter in ChangeList admin page
Hello everyone I was looking for a documentation on how to create a new filter in ChangeList admin but no luck for an official documentation. I want to add personalized filters to some models, for example, filter only active records (which is not the default manager) and have some special grouping, I found a ticket #5833 that suggests working with FilterSpecs but it seems still pending, so, what is the best approach to customize the filters in Django Admin? Cheers Anderson --~--~-~--~~~---~--~~ 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 / Postgresql problem
No, problem still exists. sigh. On Oct 5, 10:10 am, "Anderson Santos" <[EMAIL PROTECTED]> wrote: > Hello, everyone > > I am getting a strange "permission denied" error on database server running > my site. > > I am trying to send bulk mail to a huge list, it was working fine few days > ago but now it's dropping connections everytime. I had postgresql log > configured just few days ago and it's full of "unexpected EOF on client > connection" and when sending the mailing as a standalone app I get the > following error " File > "/usr/local/lib/python2.5/site-packages/django/db/models/sql/query.py", line > 1608, in execute_sql > cursor.execute(sql, params) > psycopg2.OperationalError: could not send data to server: Permission denied" > > But in general it is OK, it sends the first emails but it just dies that way > at some point when doing a random query (not in a specif query). Sometimes > after 15 minutes execution, sometimes after 1 hour and half. I don't know if > I am missing something. Most of things I have to send are cached, but it > does some queries on database during the process to get user details and > stuff like that. > > The website navigation is fine, I don't get any server error while > navigating, but it seems raising "unexpected EOF on client connection" > everytime. > > But even tho, I can't understand that unexpect EOF on my postgresql log. The > server is just fine, accepting 250 connections and using much less then > that, apache has between 15 process alive (it's prefork) so it's not > resources and there are two servers (app+db) with a crossover connection so > I doubt it's a connection problem. > > I don't know if it's a database misconfiguration, psycopg2 bug (I am using > the version 2.0.7) or anything else I am missing. I also don't know how > django deals with connection, if it's one per query, on per request and now, > using it standalone, if it is by program so it makes even harder to me to > figure out. > > Any help will be appreciate. --~--~-~--~~~---~--~~ 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 / Postgresql problem
Finally I get rid of this problem. It seems to be a conflict between two Django directories. The web app was using one version and the cron was using from a different path, don't know why but that was giving me that problem, maybe it's related to Psycopg or something like that, since both django checkouts were the same revision. Anyway, I changed the name of django directory in site-packages and now seems to working very very well. So, if you get a strange problem, check if you are using a wrong django On Oct 5, 10:10 am, "Anderson Santos" <[EMAIL PROTECTED]> wrote: > Hello, everyone > > I am getting a strange "permission denied" error on database server running > my site. > > I am trying to send bulk mail to a huge list, it was working fine few days > ago but now it's dropping connections everytime. I had postgresql log > configured just few days ago and it's full of "unexpected EOF on client > connection" and when sending the mailing as a standalone app I get the > following error " File > "/usr/local/lib/python2.5/site-packages/django/db/models/sql/query.py", line > 1608, in execute_sql > cursor.execute(sql, params) > psycopg2.OperationalError: could not send data to server: Permission denied" > > But in general it is OK, it sends the first emails but it just dies that way > at some point when doing a random query (not in a specif query). Sometimes > after 15 minutes execution, sometimes after 1 hour and half. I don't know if > I am missing something. Most of things I have to send are cached, but it > does some queries on database during the process to get user details and > stuff like that. > > The website navigation is fine, I don't get any server error while > navigating, but it seems raising "unexpected EOF on client connection" > everytime. > > But even tho, I can't understand that unexpect EOF on my postgresql log. The > server is just fine, accepting 250 connections and using much less then > that, apache has between 15 process alive (it's prefork) so it's not > resources and there are two servers (app+db) with a crossover connection so > I doubt it's a connection problem. > > I don't know if it's a database misconfiguration, psycopg2 bug (I am using > the version 2.0.7) or anything else I am missing. I also don't know how > django deals with connection, if it's one per query, on per request and now, > using it standalone, if it is by program so it makes even harder to me to > figure out. > > Any help will be appreciate. --~--~-~--~~~---~--~~ 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-sphinx with postgresql
Hello Rob We are using Sphinx and Postgresql and it improved our searches with less resources. We have over 300k records in one table and a usual search takes only few milisecons. I believe it's being maintained but with current code it's working very well without any update. Hope it helps Anderson On Oct 8, 2:37 pm, "Rob Sutherland" <[EMAIL PROTECTED]> wrote: > Hi, > > I'm working on setting up the sphinx search tool with django-sphinx > and I have a few questions for any > current users out there. First, while googling I see a lot of links > tohttp://www.davidcramer.net/which don't > resolve and I see that David Cramer is listed as the package > maintainer. Is this package still being > actively maintained? Second, is anyone currently using it to index and > search a 100K record postgresql > table? > > Thanks in advance, > > Rob > > --http://www.oscl.ca --~--~-~--~~~---~--~~ 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 / Postgresql problem
Hello, everyone I am getting a strange "permission denied" error on database server running my site. I am trying to send bulk mail to a huge list, it was working fine few days ago but now it's dropping connections everytime. I had postgresql log configured just few days ago and it's full of "unexpected EOF on client connection" and when sending the mailing as a standalone app I get the following error " File "/usr/local/lib/python2.5/site-packages/django/db/models/sql/query.py", line 1608, in execute_sql cursor.execute(sql, params) psycopg2.OperationalError: could not send data to server: Permission denied" But in general it is OK, it sends the first emails but it just dies that way at some point when doing a random query (not in a specif query). Sometimes after 15 minutes execution, sometimes after 1 hour and half. I don't know if I am missing something. Most of things I have to send are cached, but it does some queries on database during the process to get user details and stuff like that. The website navigation is fine, I don't get any server error while navigating, but it seems raising "unexpected EOF on client connection" everytime. But even tho, I can't understand that unexpect EOF on my postgresql log. The server is just fine, accepting 250 connections and using much less then that, apache has between 15 process alive (it's prefork) so it's not resources and there are two servers (app+db) with a crossover connection so I doubt it's a connection problem. I don't know if it's a database misconfiguration, psycopg2 bug (I am using the version 2.0.7) or anything else I am missing. I also don't know how django deals with connection, if it's one per query, on per request and now, using it standalone, if it is by program so it makes even harder to me to figure out. Any help will be appreciate. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Change app name in Admin (Newforms-admin)
I was wondering how to translate application name in Admin page and I only found messages back to 2006 with a suggestion to include a variable "__verbose_name__" in the application's __init__.py file and no ticket at all. There are any news about it? Wouldn't be good if at least the newforms- admin provide a way to translate the application names in the admin interface? I have some applications in portuguese and japanese, in english by default but not all users are used to the english terms. I know, I can change the index template, but I mean for a robust way to translate applications without hacking templates. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Server profile
I am new to big scale apps and we are having a problem about server configuration. We have a shared server which is probably not holding the load of users and we probably have to find a more reliable server for the second time in a week. We have 4 facebook applications with over 3000 users per day (total) with the following deployment: Nginx for proxy to apache and serve media 1 Apache instance (mod_python) to serve 4 applications But when we have many users the server raises many strange errors that doesn't make sense, and after a while the error just disappears, so I believe it's a problem about our resources. For this situation, we expect to have 5000+ (up to 10.000) users per day, but not much more then this, what do you recommend for our server? RAM? processing? things like that. We have an account at Joyent and will probably stay with them. I probably understimated the requirements for applications of that size and I have no idea of the requirements for a Django app with such size. And is mod_python the best option for us? I do think so, but I am not sure if it will require much more resources and will become too expensive. Cheers, Anderson Santos --~--~-~--~~~---~--~~ 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: client.login() returns false
I knew that it was something stupid =P Thanks a lot =) On 9 set, 11:07, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 9/9/07, Anderson Santos <[EMAIL PROTECTED]> wrote: > > > > > Hello, I am trying to do a basic test authentication but I am unable > > to get it working. I made some changes to be sure that the user has > > been created, here's my testcase: > ... > > user = > > User(username='teste',password='teste',email='[EMAIL > > PROTECTED]',is_active=True) > > user.save() > > This line is the cause of your problem. The User model stores the > password in a hashed format. When you create a user using the model > itself, you must provide the password in a hashed form. > > There are two ways to fix this problem. > Method 1: Use User.set_password() to set the value of the password field: > > >>> user = User(username='teste',email='[EMAIL PROTECTED]',is_active=True) > >>> user.set_password('teste') > >>> user.save() > > The set_password method hashes the raw password and assigns the hashed > value to the user object. > > Method 2: Use the 'create_user' helper on the default User manager: > > >>> user = > >>> User.objects.create_user(username='teste',password='teste',email='[EMAIL > >>> PROTECTED]') > > This creates a User object, hashes the raw password provided, and > saves the object for you all in one call. > > 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: unicode upgrade breaks non-ascii content
I had to work on my old website again to fix it, since even doing iconv on my files and database didn't converted well. It was a pain, and sometimes I get unicode error on my django app. I wish it could be more easy (or less painy) to migrate apps. =) On 8 set, 06:25, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > hi, > > this is not a bug report, because unicode upgrade is not backwardly > compatible. When i did the upgrade, the finnish data in the site had > problems rendering. Fortunately only one or alphabets were affected. > For example: > > Jarske-Sjöstedt > became > Jarske-Sjöstedt > > retypeing the correct spelling and saving solved the problem. People > have reported the same problem in Polish too. > > -- > > regards > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
client.login() returns false
Hello, I am trying to do a basic test authentication but I am unable to get it working. I made some changes to be sure that the user has been created, here's my testcase: from django.contrib.auth.models import User class StoreTest(TestCase): def setUp(self): from basecommerce.apps.store.models import ProductCategory, Product self.pt1 = Product(title='product 1',main_img='main.jpg', price=Decimal("3.5")) self.pt1.save() def test_add_remove(self): user = User(username='teste',password='teste',email='[EMAIL PROTECTED]',is_active=True) user.save() teste_user = User.objects.get(username='teste') self.assertEquals(teste_user.username,'teste') ### the problem self.assertTrue(self.client.login(username='teste', password='teste')) So, I am creating the user, retrieving the user to be sure it was correctly created and when I assert the self.client.login() it just returns false. I have no idea why this is happening. I have the latest Django trunk and I am using WinXP. Here's the output of my manage.py test == FAIL: test_add_remove (basecommerce.apps.store.tests.StoreTest) -- Traceback (most recent call last): File "D:\Sites\BaseCommerce\trunk\basecommerce\apps\store\tests.py", line 73, in test_add_remove self.assertTrue(self.client.login(username='teste', password='teste')) AssertionError -- cheers, Anderson --~--~-~--~~~---~--~~ 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: Strange encoding behavior
Ahhh, finally! Thank you very much, it worked now =D I didn't know about the __unicode__ trick And I am not sure if it is it that you want to know, but I still not using the encoding header on the top of the files. I thought it was more to the enconding chars of the file and not an advanced settings for the application. Should I put it on the top of all my files? Cheers, Anderson On 31 ago, 08:37, Michael Radziej <[EMAIL PROTECTED]> wrote: > On Fri, Aug 31, Anderson Santos wrote: > > > Here the code: > > > class Download(models.Model): > > """ Disponibilização de arquivos para download """ > > > descricao = > > models.CharField(verbose_name='Descrição',maxlength=250) > > data_do_arquivo = models.DateField() > > caminho_do_arquivo = models.CharField(maxlength=400) > > atualizar_versao_com_grupo = > > models.BooleanField(verbose_name='Controlar a versão pelo sistema > > principal') > > versao = models.CharField(verbose_name='Versão do > > Arquivo',blank=True,null=True,maxlength=20) > > usuarios_permitidos = > > models.ManyToManyField(User,blank=True,null=True,filter_interface=models.HORIZONTAL) > > restringir_por_usuario = models.BooleanField(default=False) > > ordem = models.IntegerField(blank=True,null=True,default=0) > > > def __str__(self): > > return self.descricao > > Can you rename __str__(self) to __unicode__(self) and try again? And, BTW, > what is the line with '# -*- encoding'? > > Michael > > -- > noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - > Tel +49-911-9352-0 - Fax +49-911-9352-100http://www.noris.de- The > IT-Outsourcing Company > > Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - > Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689 --~--~-~--~~~---~--~~ 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: Strange encoding behavior
Here the code: class Download(models.Model): """ Disponibilização de arquivos para download """ descricao = models.CharField(verbose_name='Descrição',maxlength=250) data_do_arquivo = models.DateField() caminho_do_arquivo = models.CharField(maxlength=400) atualizar_versao_com_grupo = models.BooleanField(verbose_name='Controlar a versão pelo sistema principal') versao = models.CharField(verbose_name='Versão do Arquivo',blank=True,null=True,maxlength=20) usuarios_permitidos = models.ManyToManyField(User,blank=True,null=True,filter_interface=models.HORIZONTAL) restringir_por_usuario = models.BooleanField(default=False) ordem = models.IntegerField(blank=True,null=True,default=0) def __str__(self): return self.descricao def download_restrito(self,usuario): try: usuario = self.usuarios_permitidos.get(username=usuario) except: usuario = None return (not self.restringir_por_usuario or usuario) class Admin: list_display = ('descricao','versao','caminho_do_arquivo') list_filter = ('versao',) search_fields = ('descricao',) ordering = ('ordem','descricao',) list_per_page = 20 class Meta: ordering = ('ordem','descricao',) There's more issues about Unicode error on another application that never occured with Lighttpd. I am afraid that's something about mod_python. Regards, Anderson On 30 ago, 19:06, Michael Radziej <[EMAIL PROTECTED]> wrote: > On Thu, Aug 30, Anderson Santos wrote: > > > I am still having this issue. > > I have in my settings DEFAULT_CHARSET = "utf-8", and I created a new > > database with UTF-8 encoding (using PGAdmin). > > So I go to admin page, click on my model and then the "add" button, I > > include a special char (á, ç, etc) and I get a Unicode error on both, > > Linux and Windows. > > > The error message on Linux is: > > > 'utf8' codec can't decode bytes in position 1-2: unexpected end of > > data > > > The error message on Windows is: > > > 'utf8' codec can't decode bytes in position 1-3: invalid data > > > The problem is, it DOES saves the data and displays correctly on the > > listing admin page for the model. The error only occurs when I try to > > edit, on display. If the record don't have any special char, it works > > correctly. > > > Both occurs on force_unicode procedure > > > When I try to add from manage.py shell onlinux (with or without > > special chars), it raises an error "SET client_encoding to 'UNICODE'" > > in django/db/backends/postgresql/base.py > > > I really have no clue why it's happening. I just updated from svn so I > > have the latest django. > > > Any help will be really appreciate > > Can you please post the model class, including (if present) __unicode__() > and __str__() functions? > > Michael > > -- > noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - > Tel +49-911-9352-0 - Fax +49-911-9352-100http://www.noris.de- The > IT-Outsourcing Company > > Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - > Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689 --~--~-~--~~~---~--~~ 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: Strange encoding behavior
I am still having this issue. I have in my settings DEFAULT_CHARSET = "utf-8", and I created a new database with UTF-8 encoding (using PGAdmin). So I go to admin page, click on my model and then the "add" button, I include a special char (á, ç, etc) and I get a Unicode error on both, Linux and Windows. The error message on Linux is: 'utf8' codec can't decode bytes in position 1-2: unexpected end of data The error message on Windows is: 'utf8' codec can't decode bytes in position 1-3: invalid data The problem is, it DOES saves the data and displays correctly on the listing admin page for the model. The error only occurs when I try to edit, on display. If the record don't have any special char, it works correctly. Both occurs on force_unicode procedure When I try to add from manage.py shell onlinux (with or without special chars), it raises an error "SET client_encoding to 'UNICODE'" in django/db/backends/postgresql/base.py I really have no clue why it's happening. I just updated from svn so I have the latest django. Any help will be really appreciate cheers Anderson On 29 ago, 18:30, Anderson Santos <[EMAIL PROTECTED]> wrote: > Hello, > > I am migrating a stable lighttpd+fcgi django app to apache+mod_python > and I am dealing with a strange encoding behavior. Here what I did: > > With a plain migration from the working app to the new mod_python one > I got a lot of LATIN1 codec errors that never occured on the last > architecture. So, I decided to migrate everything to UTF-8. > > - I had a Latin1 encoded Postgresql database. I backed it up, created > a new one with utf-8 encoding and restored the data > - I changed the settings to DEFAULT_CHARSET = UTF-8 > > Now everything is fine: flatpages, admin in general, etc, except when > I click to edit a record on admin interface it raises the error: > > UnicodeDecodeError at /admin/suporte/download/95/ > 'utf8' codec can't decode bytes in position 8-10: invalid data > > Unicode error hint > > The string that could not be encoded/decoded was: aliza??o de B > > Template error > > In template /srv/djprojects/django_src_trunk/django/contrib/admin/ > templates/admin/change_form.html, error at line 15 > > Traceback (innermost last) > Switch back to interactive view > > * /srv/djprojects/django_src_trunk/django/template/__init__.py in > render_node >747. >748. def render_node(self, node, context): >749. return node.render(context) >750. >751. class DebugNodeList(NodeList): >752. def render_node(self, node, context): >753. try: >754. result = node.render(context) ... >755. except TemplateSyntaxError, e: >756. if not hasattr(e, 'source'): >757. e.source = node.source >758. raise >759. except Exception, e: >760. from sys import exc_info > > Traceback (most recent call last): > File "/srv/djprojects/django_src_trunk/django/template/__init__.py" in > render_node > 754. result = node.render(context) > File "/srv/djprojects/django_src_trunk/django/template/__init__.py" in > render > 790. return self.filter_expression.resolve(context) > File "/srv/djprojects/django_src_trunk/django/template/__init__.py" in > resolve > 603. obj = func(obj, *arg_vals) > File "/srv/djprojects/django_src_trunk/django/template/ > defaultfilters.py" in _dec > 25. args[0] = force_unicode(args[0]) > File "/srv/djprojects/django_src_trunk/django/utils/encoding.py" in > force_unicode > 39. s = unicode(str(s), encoding, errors) > > UnicodeDecodeError at /admin/suporte/download/95/ > 'utf8' codec can't decode bytes in position 8-10: invalid data > > """ > > But when displayed on admin list for the model, it displays the > encoding correctly, even the special chars. The line in template is > the following: > > > #... > {% if add %}{% trans "Add" %} {{ opts.verbose_name|escape }}{% else %} > {{ original|truncatewords:"18"|escape }}{% endif %} > #... > > When I click on a record that don't have special char, it works fine > for editing, the error just occur with records with special chars. > Again, the listing displays without problem, it seems to be a problem > to force unicode procedure on template system. > > I appreciate any help. > > Cheers, > > Anderson --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Strange encoding behavior
Hello, I am migrating a stable lighttpd+fcgi django app to apache+mod_python and I am dealing with a strange encoding behavior. Here what I did: With a plain migration from the working app to the new mod_python one I got a lot of LATIN1 codec errors that never occured on the last architecture. So, I decided to migrate everything to UTF-8. - I had a Latin1 encoded Postgresql database. I backed it up, created a new one with utf-8 encoding and restored the data - I changed the settings to DEFAULT_CHARSET = UTF-8 Now everything is fine: flatpages, admin in general, etc, except when I click to edit a record on admin interface it raises the error: UnicodeDecodeError at /admin/suporte/download/95/ 'utf8' codec can't decode bytes in position 8-10: invalid data Unicode error hint The string that could not be encoded/decoded was: aliza??o de B Template error In template /srv/djprojects/django_src_trunk/django/contrib/admin/ templates/admin/change_form.html, error at line 15 Traceback (innermost last) Switch back to interactive view * /srv/djprojects/django_src_trunk/django/template/__init__.py in render_node 747. 748. def render_node(self, node, context): 749. return node.render(context) 750. 751. class DebugNodeList(NodeList): 752. def render_node(self, node, context): 753. try: 754. result = node.render(context) ... 755. except TemplateSyntaxError, e: 756. if not hasattr(e, 'source'): 757. e.source = node.source 758. raise 759. except Exception, e: 760. from sys import exc_info Traceback (most recent call last): File "/srv/djprojects/django_src_trunk/django/template/__init__.py" in render_node 754. result = node.render(context) File "/srv/djprojects/django_src_trunk/django/template/__init__.py" in render 790. return self.filter_expression.resolve(context) File "/srv/djprojects/django_src_trunk/django/template/__init__.py" in resolve 603. obj = func(obj, *arg_vals) File "/srv/djprojects/django_src_trunk/django/template/ defaultfilters.py" in _dec 25. args[0] = force_unicode(args[0]) File "/srv/djprojects/django_src_trunk/django/utils/encoding.py" in force_unicode 39. s = unicode(str(s), encoding, errors) UnicodeDecodeError at /admin/suporte/download/95/ 'utf8' codec can't decode bytes in position 8-10: invalid data """ But when displayed on admin list for the model, it displays the encoding correctly, even the special chars. The line in template is the following: #... {% if add %}{% trans "Add" %} {{ opts.verbose_name|escape }}{% else %} {{ original|truncatewords:"18"|escape }}{% endif %} #... When I click on a record that don't have special char, it works fine for editing, the error just occur with records with special chars. Again, the listing displays without problem, it seems to be a problem to force unicode procedure on template system. I appreciate any help. Cheers, Anderson --~--~-~--~~~---~--~~ 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: Developing a flexible CMS
Hello everyone, I am talking to a friend to find a good solution for this question and finally write our own CMS. I am really thinking about how to create a flexible CMS and don't break django or don't rework a lot of stuff. So, what I do believe is that we have to focus on a Management System then Content, and a flexible system should be able to go as far as we want. So, I like the idea of a page, but I do believe that a "portlet" is more useful then a page content. So, with this in mind, we have to think about a subapplication to be shown on a page, and not a bit of a rock to put on the screen. But, of course, the simplest portlet will be just a "content-link", but if I want something more complex, I can do it and without the necessity of to write a new template tag, because, if I am not a programmer I will get stucked and Django solution won't be my solution. A CMS is to make my website easier to grow, and not to create barriers. And about managing multiple objects of a model, we MUST remember that THERE IS Django's Manager and that's what we have to work on. So, I think that our answer for this question resides on there. Django is flexible, powerful, but "young" and don't have "much" automated because WE don't know the perfect solution yet. But I don't believe it will be far from the actual implementation. Not rework, but improve Django, that's the way for a Real django powered CMS that I would like to see. On 27 jun, 01:03, sime <[EMAIL PROTECTED]> wrote: > Hi Kyle, I've run into the same problems before. I think you'll find > Django admin is great for simple operations involving single records > and the most basic relations. But for anything beyond that, you'll > probably need to roll your own admin page. > > On Jun 25, 1:15 am, Kyle Fox <[EMAIL PROTECTED]> wrote: > > > I hope I can explain this well, because I've been wracking my poor > > little brain trying to figure out how to do this :) > > > I'm trying to create a flexible CMS. I want it to be easy for users > > to create a Page, and attach all kinds of content ("components") to > > that page. These components would all be Model classes. Here are two > > simple examples of the components I had in mind: > > > class TextSnippet(models.Model): > > body = models.TextField() > > > class Photo(models.Model): > > image = models.ImageField(upload_to="photos") > > > The idea is that a user add an arbitrary number of these components to > > a Page model. A Page model is nothing more than a container to hold > > components, and a URL associated with the Page, something like: > > > class Page(models.Model): > > url = models.CharField( maxlength=100, unique=True, > > validator_list=[validators.isAlphaNumericURL]) > > > The problem is that I can't figure out a good way to associate > > instances of TextSnippet and Photo with a page. It's obviously a many- > > to-many between the components and pages (a component like a photo can > > be on many pages, and a page can have many components), but I also > > need to store more information about that particular page-component > > relationship, for example a IntegerField that specifies the > > component's position on that page. Here's what I've come up with so > > far: > > > class PageComponent(models.Model): > > page = models.ForeignKey(Page, related_name="components", > > edit_inline=models.TABULAR) > > content_type = models.ForeignKey(ContentType) > > object_id = models.IntegerField(core=True) > > position = models.IntegerField(default=0, blank=True) > > > It "works" not too bad. Conceptually (from the shell), I think it > > does what I want. However, I'm having a HECK of a time getting the > > Page form in the admin to work in an intuitive way. When adding > > components to a page, the user sees a drop-down list of content_types, > > and has to enter an object_id. It works for me because I know what to > > put for the object_id, but a regular user wouldn't > > > I think this would require me to write a custom form class for adding > > and editing a page, but with these relationships I really don't even > > know where to begin :S > > > If anyone can provide advice (or just flat out tell me if I'm thinking > > about this wrong), it would be much appreciated! > > > Thanks, > > Kyle --~--~-~--~~~---~--~~ 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: Long time process and FCGI
Thank you, again. Now I think I have enough information to find my way =D On 3/30/07, xgdlm <[EMAIL PROTECTED]> wrote: > > > I am just not sure about how to call the shell script. > > I would call the shell script withing a cronjob command : > python /path/to/sendmail.py > > this script would do someting roughly like : > - > if there_is_a_mailing_to_send : > for mail in mailtosend : > do >send mail > - > > > read from a database and send the e-mails will be in the same path as > > the view, how can I call it? > > in the view I won't call any system command. I would just write some > where (in a database or in a file) if there is a mailing to send. > > def startsending(request): > ''' do someting here so cronjob would know there is a mailign to > send ''' > there_is_a_mailing_to_send = True > return HttpResponse('Your e-mails are being send shortly") > > xav > > > > > --~--~-~--~~~---~--~~ 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: Long time process and FCGI
I was looking for how to execute a script and I was just thinking how to use django code and here is your e-mail! Thank you! I am just not sure about how to call the shell script. should I use the os.system(command) or the os.popen ? That seems that popen just return when I close the script and this is exactly what I want to avoid. and considering that a file called sendmail.py with all the script to read from a database and send the e-mails will be in the same path as the view, how can I call it? def startsending(request): os.system("sendmail.py") return HttpResponse('Your e-mails are being send") ? and I got an example that does a python script, on the end of the script it does: -- [script code] if __name__ == "__main__": while something: execute(command) [end of the script] -- if I call it from a view using os.system, it still will be the main so I have to use this code? Thanks for your help =) On 3/30/07, xgdlm <[EMAIL PROTECTED]> wrote: > > Hello, > > Sending email within a view seems to me quite a strange process :) > You should send your emails within a shell python (or whatever) > process. > > What I would do ... > I would within my view, write some kind of data to a database or a > text file or whatever. > Then, have a cronjob that check that data (should I send emails or > not ?) > Then if the answer is 'True' fire a script that sends emails. > > In this case your long process won't involve any fcgi/webserver > process. > > Of course you can use Django in shell python script. You juste have to > wrtite some script with the flowing caneva : > --- > #!/usr/bin/env python > > import sys > sys.path.append('/path/to/django/source') > sys.path.append('/path/to/projects') > > import os > > # assuming /path/to/your/projects/myproject/settings.py > os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings' > > from project.models import whatever > > django code > --- > > > Regards, > xav > > > > > --~--~-~--~~~---~--~~ 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: Long time process and FCGI
In my case, it's quite urgent (it must work today), so do you have any example to execute this external script? Is it simple python (*.py) files? I was reading the link you sent, it's really interesting and it could be useful in a visual progress process, I will try it with another project. Thanks in advance, 4nderson On 3/30/07, Atilla <[EMAIL PROTECTED]> wrote: > > Well, one thing that you could do is to execute an external script > from your view. Then you'd immediatelly return from the view, and the > script could mail them in the background. That is, of course, if you > don't need any feedback to be displayed. > > If you do need to do something like that, you'll need to make your > view provide some output every once in a while, so your webserver does > not time it out. However - that would cause your view to return data > to the browser quite slow. If you want it more interactive, you could > make the view generate output to a page with something AJAX-y, instead > of a normal web page. > http://my.opera.com/WebApplications/blog/show.dml/438711 - this idea > is quite nice, although I guess you don't need anything so flashy in > your case. > > > On 30/03/07, Anderson Santos Silva <[EMAIL PROTECTED]> wrote: > > > > That's exactly what I thought when I dealed with that, but I can't > > imagine a separated process running in the background and return a > > response to the user that his "action" was activated if every method > > waits to get back instead of a kind of thread operation. (Yes, I came > > from windows programming {delphi} to Web, so my knowledge is kind of > > limited with Python) > > > > Any suggestion? > > > > > > > > > > Atilla wrote: > > > Hello, > > > > > > By the looks of it, mod_fcgi has a limit as to how much time it could > > > wait for response from a script. Since you're doing a heavy operation > > > that takes a while, i guess it times out. > > > > > > The point is - if your executed action takes so much time, you're > > > clearly having a wrong conception on when and how you should be > > > executing it. It could be better off as an external process (that > > > still uses django in its code) that is triggered by certain actions in > > > your web-application, or scheduled by cron. In any case - it is not > > > the job of your django view to handle bulk transfers, it was not meant > > > to be doing that, even if the mod_fcgi didn't have the timeout. > > > > > > > > > On 30/03/07, Anderson Santos Silva <[EMAIL PROTECTED]> wrote: > > > > > >> Hello, I have a process that sends an e-mail to more then 5000 addresses > > >> (grouping it in 50 each time) and after a while it gives me the error: > > >> > > >> --- > > >> Internal Server Error > > >> > > >> The server encountered an internal error or misconfiguration and was > > >> unable to complete your request. > > >> > > >> Please contact the server administrator, [EMAIL PROTECTED] and > > >> inform them of the time the error occurred, and anything you might have > > >> done that may have caused the error. > > >> > > >> More information about this error may be available in the server error > > >> log. > > >> > > >> Additionally, a 404 Not Found error was encountered while trying to use > > >> an ErrorDocument to handle the request. > > >> > > >> > > > > > > > > > > > > > > > > > > > --~--~-~--~~~---~--~~ 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: Long time process and FCGI
That's exactly what I thought when I dealed with that, but I can't imagine a separated process running in the background and return a response to the user that his "action" was activated if every method waits to get back instead of a kind of thread operation. (Yes, I came from windows programming {delphi} to Web, so my knowledge is kind of limited with Python) Any suggestion? Atilla wrote: > Hello, > > By the looks of it, mod_fcgi has a limit as to how much time it could > wait for response from a script. Since you're doing a heavy operation > that takes a while, i guess it times out. > > The point is - if your executed action takes so much time, you're > clearly having a wrong conception on when and how you should be > executing it. It could be better off as an external process (that > still uses django in its code) that is triggered by certain actions in > your web-application, or scheduled by cron. In any case - it is not > the job of your django view to handle bulk transfers, it was not meant > to be doing that, even if the mod_fcgi didn't have the timeout. > > > On 30/03/07, Anderson Santos Silva <[EMAIL PROTECTED]> wrote: > >> Hello, I have a process that sends an e-mail to more then 5000 addresses >> (grouping it in 50 each time) and after a while it gives me the error: >> >> --- >> Internal Server Error >> >> The server encountered an internal error or misconfiguration and was >> unable to complete your request. >> >> Please contact the server administrator, [EMAIL PROTECTED] and >> inform them of the time the error occurred, and anything you might have >> done that may have caused the error. >> >> More information about this error may be available in the server error log. >> >> Additionally, a 404 Not Found error was encountered while trying to use >> an ErrorDocument to handle the request. >> >> > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Long time process and FCGI
Hello, I have a process that sends an e-mail to more then 5000 addresses (grouping it in 50 each time) and after a while it gives me the error: --- Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. --- Apache/1.3.37 Server at www.utopia-design.net Port 80 -- So, trying to realize what's wrong, I found this on the log of my server: [Thu Mar 29 14:26:17 2007] [warn] FastCGI: (dynamic) server "/home/curalouc/public_html/enercons/django.fcgi" (uid 32016, gid 32018) restarted (pid 21406) [Thu Mar 29 14:26:17 2007] [warn] FastCGI: scheduled the restart of the last (dynamic) server "/home/curalouc/public_html/enercons/django.fcgi" process: reached dynamicMaxClassProcs (10) [Thu Mar 29 14:26:12 2007] [warn] FastCGI: (dynamic) server "/home/curalouc/public_html/enercons/django.fcgi" (pid 20125) terminated by calling exit with status '0' [Thu Mar 29 14:26:12 2007] [warn] FastCGI: (dynamic) server "/home/curalouc/public_html/enercons/django.fcgi" (pid 20125) termination signaled [Thu Mar 29 14:22:59 2007] [error] [client 200.146.81.46] File does not exist: /home/curalouc/public_html/500.shtml And now, I just get stucked and I have no idea what I can do to send all those mails in a view, and I am not sure if this is the problem. When I tried the process with less then 10 mails, it was okay. Any help will be appreciate, regards 4nderson --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Removetags template filter
Hello everyone, I have a field with a tinymce editor, so it saves html tags inside the field and this text is send by e-mail with an html and an alternative text version. So, I have to remove all the <> tags, how can I get this in place of putting all possible html code that I can remember as a parameter? There is at least a python/django variable with that? Or another way to get this done? Template HTML Version {{ highlights }} Template Text Version {{ highlights|removetags:allhtmltags }} Thank you in advance Anderson --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with order_with_respect_to and self
Hello Malcoml. Here the copy and paste of the error: FieldDoesNotExist at /animallib/ Section has no field named 'self' Request Method: GET Request URL: http://utopia-design.net/animallib/ Exception Type: FieldDoesNotExist Exception Value: Section has no field named 'self' Exception Location: /home/curalouc/django_src/django/db/models/options.py in get_field, line 101 |Traceback (most recent call last): File "/home/curalouc/django_src/django/core/handlers/base.py" in get_response 68. callback, callback_args, callback_kwargs = resolver.resolve(request.path) File "/home/curalouc/django_src/django/core/urlresolvers.py" in resolve 162. sub_match = pattern.resolve(new_path) File "/home/curalouc/django_src/django/core/urlresolvers.py" in resolve 118. return self.callback, args, kwargs File "/home/curalouc/django_src/django/core/urlresolvers.py" in _get_callback 125. self._callback = getattr(__import__(mod_name, {}, {}, ['']), func_name) File "/home/curalouc/django_src/django/db/models/base.py" in __new__ 65. new_class._prepare() File "/home/curalouc/django_src/django/db/models/base.py" in _prepare 177. opts._prepare(cls) File "/home/curalouc/django_src/django/db/models/options.py" in _prepare 63. self.order_with_respect_to = self.get_field(self.order_with_respect_to) File "/home/curalouc/django_src/django/db/models/options.py" in get_field 101. raise FieldDoesNotExist, '%s has no field named %r' % (self.object_name, name) FieldDoesNotExist at /animallib/ Section has no field named 'self' And the model, in raw copy and paste class Section(models.Model): description = models.CharField(verbose_name='Description',maxlength=100) parent = models.ForeignKey('self',related_name='childs',blank=True, null=True) link = models.CharField(verbose_name="Section link",maxlength=300,help_text="The url of the document or custom page that will be shown") position = models.IntegerField(verbose_name="Order of appearence",blank=True, null=True) def __str__(self): return self.description class Admin: list_display = ('description','position') search_fields = ['description'] class Meta: order_with_respect_to = 'self' ordering = ['position','description'] Thanks for your help, 4nderson | Malcolm Tredinnick wrote: > On Mon, 2007-03-26 at 22:41 -0300, Anderson Santos Silva wrote: > >> I am working with the trunk, and I never tried the order_with_respect_to >> before, so I don't know how it works but it's on the official Django's >> documentation. >> Since my model is called Section, it's probably something about Python >> tricks to get a property dinamically. That sounds exciting, my first bug >> found =) >> I googled everything about this and I couldn't find anything similar and >> I don't know where to start to find why this bug happens. But all the >> examples that I found about this property (order_with_respect_to) uses a >> different model, maybe it's a clue. >> > > It may not be a bug. Let's gather some more information first. You said > that when you used "parent" as the attribute in order_with_respect_to, > it gave you an error. Could you please post the full traceback. Like I > said, the fragment you posted doesn't correspond to any place in the > code I can find, so I'd like to see a bit more information about how it > occurred. > > Thanks, > 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: Problem with order_with_respect_to and self
I am working with the trunk, and I never tried the order_with_respect_to before, so I don't know how it works but it's on the official Django's documentation. Since my model is called Section, it's probably something about Python tricks to get a property dinamically. That sounds exciting, my first bug found =) I googled everything about this and I couldn't find anything similar and I don't know where to start to find why this bug happens. But all the examples that I found about this property (order_with_respect_to) uses a different model, maybe it's a clue. Regards, Anderson Malcolm Tredinnick wrote: > On Mon, 2007-03-26 at 19:23 -0300, Anderson Santos Silva wrote: > >> Hello, I am having problem when I use the order_with_respect_to and >> a self related foreign key model: >> >> When I validate this, it raises "'str' object has no attribute >> 'get_section_order'" and when I use self or Section, it raises the error: >> "Section has no field named 'self'" >> > > What version of Django are you using? I cannot find the string > get_section_order anywhere in the source code in the latest version, so > I can't work out what is raising this error. > > There may be a genuine bug here, but I'm reluctant to dive too deep > until we've worked out why you are seeing an error message from beyond > the grave, so to speak. :-) > > Regards, > Malcolm > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problem with order_with_respect_to and self
Hello, I am having problem when I use the order_with_respect_to and a self related foreign key model: When I validate this, it raises "'str' object has no attribute 'get_section_order'" and when I use self or Section, it raises the error: "Section has no field named 'self'" class Section(models.Model): description = models.CharField(verbose_name='Description',maxlength=100) parent = models.ForeignKey('self',related_name='childs',blank=True, null=True) link = models.CharField(verbose_name="Section link",maxlength=300) position = models.IntegerField(verbose_name="Order of appearence",blank=True, null=True) def __str__(self): return self.description class Admin: list_display = ('description','position') search_fields = ['description'] class Meta: order_with_respect_to = 'parent' ordering = ['position','description'] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---