Re: i18n variable string translation
Another problem I am facing is it seems some pages are not being translated until I hit certain page, after that everything is fine. I am not exactly sure what the problem is but if you guys experience this problem, would appreciate some insights. -Aaron On Wed, Jun 16, 2010 at 4:47 PM, Aaron Lee <waifun...@gmail.com> wrote: > Thanks, the lazy translation solves the problem. > > -Aaron > > > On Wed, Jun 16, 2010 at 2:59 PM, Antoni Aloy <antoni.a...@gmail.com>wrote: > >> Try to use lazy translation. >> >> El 16/06/2010 23:09, "Aaron" <waifun...@gmail.com> escribió: >> >> >> Well what happened was I have a forms.py >> >> which has >> >> CONSTANT = _("Hello World") >> x = {'var': CONSTANT } >> >> and in the django.po, I do have a translation >> >> msgid "Hello World" >> msgstr "xxx" >> >> But it doesn't show up on the website, all the other translations >> work, so I am wondering what am I missing >> >> -Aaron >> >> >> >> On Jun 16, 1:35 pm, Baurzhan Ismagulov <i...@radix50.net> wrote: >> > On Wed, Jun 16, 2010 at 01:00:3... >> > Baurzhan Ismagulovhttp://www.kz-easy.com/ >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: i18n variable string translation
Thanks, the lazy translation solves the problem. -Aaron On Wed, Jun 16, 2010 at 2:59 PM, Antoni Aloywrote: > Try to use lazy translation. > > El 16/06/2010 23:09, "Aaron" escribió: > > > Well what happened was I have a forms.py > > which has > > CONSTANT = _("Hello World") > x = {'var': CONSTANT } > > and in the django.po, I do have a translation > > msgid "Hello World" > msgstr "xxx" > > But it doesn't show up on the website, all the other translations > work, so I am wondering what am I missing > > -Aaron > > > > On Jun 16, 1:35 pm, Baurzhan Ismagulov wrote: > > On Wed, Jun 16, 2010 at 01:00:3... > > Baurzhan Ismagulovhttp://www.kz-easy.com/ > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
i18n variable string translation
Hi guys, In http://www.djangobook.com/en/2.0/chapter19, there is a paragraph Translation works on variables. Again, here’s an identical example: def my_view(request): sentence = 'Welcome to my site.' output = _(sentence) return HttpResponse(output) (The caveat with using variables or computed values, as in the previous two examples, is that Django’s translation-string-detecting utility, django-admin.py makemessages, won’t be able to find these strings. More on makemessages later.) It's a bit confusing, one one hand it says Translation works on variables, on the other hand, it says makemessages won't be able to find these strings. Which one is right? The makemessages section didn't mention how to "fix" this problem neither. Any ideas? -Aaron -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: unable to create en-gb for localisation
Thanks, for some reason en_GB works (but not en-gb) and I don't see a en_GB stub under django/conf/locale. So it seems it works in a mysterious way -Aaron On Thu, Apr 22, 2010 at 12:24 PM, Ramiro Morales <cra...@gmail.com> wrote: > On Thu, Apr 22, 2010 at 3:48 PM, Aaron Lee <waifun...@gmail.com> wrote: > > Hi, > > > > I am trying to create a UK version of my site and ran into some problems. > > I am manually setting my LANGUAGE_CODE to 'en-gb' and use > > django-admin.py makemessages -l en-gb and then run compilemessages > > > > For some reason it's not picking up the localised string, I am pretty > sure > > my setup is correct because I did the same experiment for uk (Ukraine). > > > > Looking at Django's conf/locale I couldn't find an example of Great > Britain > > English translation setup. Any idea what may go wrong? Thanks > > Make sure you are creating a stub en-gb translation for Django. See the > second note box ("Locale restrictions") here: > > > http://docs.djangoproject.com/en/1.1/topics/i18n/localization/#topics-i18n-localization > > -- > Ramiro Morales | http://rmorales.net > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
unable to create en-gb for localisation
Hi, I am trying to create a UK version of my site and ran into some problems. I am manually setting my LANGUAGE_CODE to 'en-gb' and use django-admin.py makemessages -l en-gb and then run compilemessages For some reason it's not picking up the localised string, I am pretty sure my setup is correct because I did the same experiment for uk (Ukraine). Looking at Django's conf/locale I couldn't find an example of Great Britain English translation setup. Any idea what may go wrong? Thanks -Aaron -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django memcached errors
Lately I have been seeing the following errors from memcached [fa...@1246486554.949771] mcm_get_line():1542: memcache(4) protocol error: no \r before \n [fa...@1246486554.949771] mcm_get_line():1542: memcache(4) protocol error: no \r before \n [fa...@1246486554.949771] mcm_fetch_cmd():1154: memcache(4) protocol error: protocol, expected a response [fa...@1246486554.953771] mcm_server_send_cmd():2706: failed to send command to the memcache server: Bad address: Bad address I am using the latest Django from trunk, libmemcache-1.4.0.rc2, cmemcache-0.95. I also searched over Google and it seems like a mystery of how and why it happens. At then end they fall back to python-memcached even though it's slower. Anyone know what the problem is? I wasn't able to reproduce it so it's hard to track down. -Aaron --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Django DB strange behavior
Thanks James and Karen, Yes indeed it was the problem, I updated the my.cnf to have transaction_isolation set to READ-COMMITTED and it works fine now. Is there any benefit of this approach of the other (connection autocommit) i.e. performance-wise ? -Aaron On Sat, Apr 25, 2009 at 7:24 AM, Karen Tracey <kmtra...@gmail.com> wrote: > On Sat, Apr 25, 2009 at 5:07 AM, Aaron Lee <waifun...@gmail.com> wrote: > >> Today I just stumble upon a very strange bug and I am not sure if that's >> Django bug or not. >> >> Here's the context: >> I have a model Job which has a status field. >> >> For debugging, I run python manage.py shell and do >> >> jobs = Job.objects.filter(status__in=['A']) >> >> *I am using MySQL 5.0 InnoDb* >> >> Re-running this command will NOT get updated result even if a new job with >> status 'A' is inserted to the DB (I explicitly turned off buffer_pool cache >> and no query cache) >> I then open another terminal and do python manage.py shell and run this >> command and I got the newly updated result set. >> > > This is due to InnoDB's default transaction isolation level of "repeatable > read" combined with Django's default autocommit behavior that does not > "commit" queries. So your manage.py shell is running in a single > transaction that is not committed until you do some sort of update from it, > meaning (in the absence of any update) that all queries will return whatever > they returned the first time you ran them. See this thread: > > > http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06d > > for details on how to change either the transaction isolation level or the > connection's autocommit setting to allow a query-only script/shell to see > updates made by a different transaction. > > Karen > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django DB strange behavior
Today I just stumble upon a very strange bug and I am not sure if that's Django bug or not. Here's the context: I have a model Job which has a status field. For debugging, I run python manage.py shell and do jobs = Job.objects.filter(status__in=['A']) *I am using MySQL 5.0 InnoDb* Re-running this command will NOT get updated result even if a new job with status 'A' is inserted to the DB (I explicitly turned off buffer_pool cache and no query cache) I then open another terminal and do python manage.py shell and run this command and I got the newly updated result set. So in summary: - calling Job.objects.filter(status__in=['A']) does NOT get the latest result from the DB, running the SQL statement directly in mysql client does result the correct result. - do the same query on another shell (i.e. a new python manage.py shell) correct gets the updated result, but repeated execute gets back stale data - checking the connection.queries[-1] shows a new SQL was sent to the DB. - I even turned on MySQL proxy to intercept the incoming query and verify that a new query was sent. - ALTER TABLE jobsdone_job ENGINE=MyISAM does the magic and everything works correctly i.e. repeated execution yields the latest data from the DB. So is there some InnoDB specific thing in Django that does some "smart" caching? -Aaron --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: admin sorting in ManyToMany fields
Just to be clear, the ManyToManyField will have 'a', 'c', 'b' listed under Person1's admin interface with 'a' and 'c' highlighted. What I want to achieve is to order the name => 'a', 'b', 'c' with 'a', 'c' highlighted for Person1 and 'b' highlighted for Person2. -Aaron On Wed, Jan 28, 2009 at 6:02 PM, Aaron Lee <waifun...@gmail.com> wrote: > > > On Wed, Jan 28, 2009 at 4:44 PM, Malcolm Tredinnick < > malc...@pointy-stick.com> wrote: > >> >> On Wed, 2009-01-28 at 06:49 -0800, Aaron Lee wrote: >> > I tried doing that but it didn't work, the order of names within the >> > PersonAdmin still shows the Name according to pk order. >> >> Firstly, realise that your question doesn't have a "correct" answer. >> Ordering by multi-valued fields always have that problem. For example: >> >>Person1 >>- Name.name = 'a' >>- Name.name = 'c' >>Person2 >>- Name.name = 'b' >> > > What I want to achieve is when I edit Person1 in the admin interface, I > want to order the Name.name i.e. 'a', 'c' > instead of according to 'a','c''s primary key in Name. So I am a bit > confused why Person2 comes into the picture. > Think about a person can have multiple names e.g. screenname, nickname, > username etc ... > > I believe that's a legitimate use of ManyToManyField? > > >> >> Now, depending upon which "name" value is chosen for Person1, it might >> sort ahead of or behind Person2. However, things are even worse than >> that. What will happen, in fact, is that the SQL results will include >> Person1 twice -- once for name='a' and once for name='c', since any >> ordering columns are part of the select result. >> >> However, if you're certain that the group of things you are selecting >> don't have multiple entries in the related many-to-many table (in which >> case, why are you using a ManyToManyField and not a ForeignKey?), you >> can order by any related field you like: >> >>class Person(models.Model): >> ... >> class Meta: >> ordering = ['name__name'] >> >> This is documented in the order_by() documentation for querysets (since >> Meta.ordering is just an order_by() application): >> >> http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields >> >> Regards, >> Malcolm >> >> >> >> >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: admin sorting in ManyToMany fields
On Wed, Jan 28, 2009 at 4:44 PM, Malcolm Tredinnick < malc...@pointy-stick.com> wrote: > > On Wed, 2009-01-28 at 06:49 -0800, Aaron Lee wrote: > > I tried doing that but it didn't work, the order of names within the > > PersonAdmin still shows the Name according to pk order. > > Firstly, realise that your question doesn't have a "correct" answer. > Ordering by multi-valued fields always have that problem. For example: > >Person1 >- Name.name = 'a' >- Name.name = 'c' >Person2 >- Name.name = 'b' > What I want to achieve is when I edit Person1 in the admin interface, I want to order the Name.name i.e. 'a', 'c' instead of according to 'a','c''s primary key in Name. So I am a bit confused why Person2 comes into the picture. Think about a person can have multiple names e.g. screenname, nickname, username etc ... I believe that's a legitimate use of ManyToManyField? > > Now, depending upon which "name" value is chosen for Person1, it might > sort ahead of or behind Person2. However, things are even worse than > that. What will happen, in fact, is that the SQL results will include > Person1 twice -- once for name='a' and once for name='c', since any > ordering columns are part of the select result. > > However, if you're certain that the group of things you are selecting > don't have multiple entries in the related many-to-many table (in which > case, why are you using a ManyToManyField and not a ForeignKey?), you > can order by any related field you like: > >class Person(models.Model): > ... > class Meta: > ordering = ['name__name'] > > This is documented in the order_by() documentation for querysets (since > Meta.ordering is just an order_by() application): > > http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields > > Regards, > Malcolm > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: admin sorting in ManyToMany fields
I tried doing that but it didn't work, the order of names within the PersonAdmin still shows the Name according to pk order. -Aaron On Wed, Jan 28, 2009 at 1:03 AM, knight <alexar...@gmail.com> wrote: > > Hi, > > You can do it by adding: > > class Meta: >ordering = ['name'] > > to you Name class. > Regards, Alex A. > > On Dec 24 2008, 9:17 am, "Aaron Lee" <waifun...@gmail.com> wrote: > > Hi I have a ManyToMany field names in my class and I would like to show > the > > names in sorted order (according to 'name') in the admin interface when I > > edit a Person. Right now it's showing by the pk order of Name. What's the > > right way to override this order? Thanks > > class Name(models.Model): > > name = models.CharField() > > > > class Person(models.Model): > > code = models.CharField() > > names = models.ManyToManyField(Name) > > > > class PersonAdmin(admin.ModelAdmin): > > list_display = ('code',) > > ordering = ('code',) > > > > admin.site.register(Person, PersonAdmin) > > > > -Aaron > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: proper way to use S3Storage and Django ImageField
Yes avatar.image.url works, thanks again. -Aaron On Mon, Jan 19, 2009 at 5:17 PM, creecode <creec...@gmail.com> wrote: > > I think you may be correct on that my tip was incorrect. Forget what > I said! :-) > > Have you tried getting the url like avatar.image.url? I use a line > like this in some of my code that uses S3Storage and it works. > > image_url = my_model_instance.image.url.replace ( ':80', '' ) > > On Jan 19, 4:01 pm, "Aaron Lee" <waifun...@gmail.com> wrote: > > Thanks for your tip, I believe your suggestion will end up having my.jpg > > under > > my-bucket-name.s3.amazonaws.com.s3.amazonaws.com/userprofile/my.jpg > > > > I think the AWS_STORAGE_BUCKET_NAME should just be userprofile > > > So how do you access the image, do you manually construct the URL? > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: proper way to use S3Storage and Django ImageField
Thanks David, but it seems awkward to call avatar.image.storage.url(str(avatar.image)) to retrieve the URL for an ImageField. Do you have a better way? -Aaron On Mon, Jan 19, 2009 at 4:02 PM, David Larlet <lar...@gmail.com> wrote: > > > Le 19 janv. 09 à 22:53, Aaron Lee a écrit : > > > > But I am still getting the exception saying the backend doesn't > > support absolute paths. > > In django/db/models/fields/files.py line 52 _get_path > > return self.storage.path(self.name) > > > > and my self.name is userprofile/cs1.jpg > > > > Any suggestions? > > Hi Aaron, > > Sorry for my late answer, I was on holidays, what about > instance.url()? (that's the recommended way to do, .path() is for > local storages) > > Regards, > David > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: proper way to use S3Storage and Django ImageField
Yes and yes, here are my settings in settings.py # Storage Settings DEFAULT_FILE_STORAGE = 'libs.storages.S3Storage.S3Storage' AWS_ACCESS_KEY_ID='xxx' AWS_SECRET_ACCESS_KEY='xxx' AWS_STORAGE_BUCKET_NAME='userprofile' from S3 import CallingFormat AWS_CALLING_FORMAT=CallingFormat.SUBDOMAIN AWS_HEADERS = { 'Expires': 'Sat, 10 Jan 2049 00:00:00 GMT', 'Cache-Control': 'max-age=86400', } # and I also verified that I have a bucket called "userprofile" in my Amazon account. In the DB I have mysql> select * from userprofile_avatar; ++-+-+-+---+ | id | image | user_id | date| valid | ++-+-+-+---+ | 4 | userprofile/cs1.jpg | 2 | 2009-01-19 13:46:12 | 0 | ++-+-+-+---+ But I am still getting the exception saying the backend doesn't support absolute paths. In django/db/models/fields/files.py line 52 _get_path return self.storage.path(self.name) and my self.name is userprofile/cs1.jpg Any suggestions? -Aaron On Mon, Jan 19, 2009 at 4:22 PM, Merrick <merr...@gmail.com> wrote: > > I am using S3Storage with an imagefield successfully. It sounds like > you have not specified the storage engine and keys etc... in > settings.py as creecode pointed out. > > I recall testing that the directory will be created on the fly if it > does not exist. > > On Jan 19, 12:40 pm, creecode <creec...@gmail.com> wrote: > > Hello Aaron, > > > > I can confirm that it can work. I'm using it but I don't know enough > > to diagnose your problem. > > > > Have you created the userprofile "directory" in your S3 bucket? > > > > Have you added the following to your settings.py? > > > > DEFAULT_FILE_STORAGE = 'S3Storage.S3Storage' > > > > AWS_ACCESS_KEY_ID > > AWS_SECRET_ACCESS_KEY > > AWS_STORAGE_BUCKET_NAME > > AWS_CALLING_FORMAT > > > > Have you installed any software S3Storage depends on? > > > > On Jan 19, 8:02 am, "Aaron Lee" <waifun...@gmail.com> wrote: > > > > > So I guess S3Storage doesn't work with ImageField? Can anyone confirm > that? > > > > Toodle-l. > > creecode > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: proper way to use S3Storage and Django ImageField
So I guess S3Storage doesn't work with ImageField? Can anyone confirm that? -Aaron On Thu, Jan 15, 2009 at 10:30 AM, Aaron <waifun...@gmail.com> wrote: > > ping? > > On Jan 12, 9:53 am, "Aaron Lee" <waifun...@gmail.com> wrote: > > Hi all and David, > > > > I followed thehttp://code.larlet.fr/doc/django-s3-storage.html > > installation and created a simple model > > > > class Avatar(models.Model): > > """ > > Avatar model > > """ > > image = models.ImageField(upload_to="userprofile") > > user = models.ForeignKey(User) > > > > By using the upload_to="userprofile" (which is also the example given on > the > > django-s3-storage.html) > > the path would be something like userprofile/my.jpg > > which would trigger the file storage backend exception > > > > File "/usr/local/src/djtrunk.latest/django/core/files/storage.py", line > 81, > > in path > > raise NotImplementedError("This backend doesn't support absolute paths.") > > where name is userprofile/my.jpg > > > > What's the recommended way of using S3 with ImageField? > > > > -Aaron > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
proper way to use S3Storage and Django ImageField
Hi all and David, I followed the http://code.larlet.fr/doc/django-s3-storage.html installation and created a simple model class Avatar(models.Model): """ Avatar model """ image = models.ImageField(upload_to="userprofile") user = models.ForeignKey(User) By using the upload_to="userprofile" (which is also the example given on the django-s3-storage.html) the path would be something like userprofile/my.jpg which would trigger the file storage backend exception File "/usr/local/src/djtrunk.latest/django/core/files/storage.py", line 81, in path raise NotImplementedError("This backend doesn't support absolute paths.") where name is userprofile/my.jpg What's the recommended way of using S3 with ImageField? -Aaron --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
How to populate a form field with a Select widget
I would like to populate a form field which uses a Select widget with choices in views.py. I understand I can pass the initial arg to the form but I couldn't find the correct value to pass. The choices is a list of tuple CHOICES = ( ('P', 'Pending'), ('A', 'Active'), ('D', 'Done')) Any hints? -Aaron --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
admin sorting in ManyToMany fields
Hi I have a ManyToMany field names in my class and I would like to show the names in sorted order (according to 'name') in the admin interface when I edit a Person. Right now it's showing by the pk order of Name. What's the right way to override this order? Thanks class Name(models.Model): name = models.CharField() class Person(models.Model): code = models.CharField() names = models.ManyToManyField(Name) class PersonAdmin(admin.ModelAdmin): list_display = ('code',) ordering = ('code',) admin.site.register(Person, PersonAdmin) -Aaron --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
template tags for simple comparison
I found this wiki and seems pretty useful in general, is there any reason why it's not included in Django by default? http://code.djangoproject.com/wiki/BasicComparisonFilters --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: GeoDjango question about US zipcode lookup and spatial query
On Sat, Nov 29, 2008 at 12:24 PM, Justin Bronn <[EMAIL PROTECTED]> wrote: > > > I do have a few basic questions > > - on slide 37, there's a Zipcode model, how does one populate this model? > > Are we using fe_2007_us_zcta500.shp? If so, is there a program which > > converts the zipcode shape from the shape file? > > Yes, you use that shapefile. The script that loads the data is also > in the presentation, go to slide 68 (in the `LayerMapping` section). > Thanks Justin, I was using MySQL and it looks like I do need Postgres to get the best gis support. Do people normally switch their DB backend entirely or do they start a new project for geo stuff and connect the main site to this as a separate backend? I can see the pros and cons of each approach. Just want to hear about people's experience I followed the example and did: def test_zipcode(): zipcode_mapping = { 'code' : 'ZCTA5CE00', 'mpoly' : 'MULTIPOLYGON', } zipcode_shp = '/usr/local/share/census/fe_2007_us_zcta500.shp' lm = LayerMapping(Zipcode, zipcode_shp, zipcode_mapping) lm.save(verbose=True) and tried a few zipcode in Admin interface. I see several problems and want to make sure it's a data error rather than installation error: 1. There's no 08544 zipcode after the layer mapping. 08544 should point to Princeton NJ. 2. I do see 08540 and 08542. 08542 seems correct but 08540 shows North Pole?? 3. I also did a shp2pgsql dump with srid=4269 which seems the closest match of the prj file as compared to spatial_ref_sys in the pgsql db. shp2pgsql -s 4269 fe_2007_us_zcta500 zipcode > zipcode.sql and 08544 is not there. If so, it does look like the zipcode is incomplete even though the dataset is fairly recent and from census. Do you have recommendation on what maybe a better DataSource? > > > - on slide 41, there is an Address model, does GeoDjango provide > geocoding > > which converts it to (lat, lon) for spatial query? If not, does it mean > that > > one has to query Google/Yahoo/MSFT WebServices? > > No, GeoDjango does not provide geocoding services. Geopy [1] is a > popular Python geocoding interface. > Let say I want to do something similar to your example of HoustonCrimeMap, and I use Geopy to perform the geocoding to get back the (lat, lon) for each crime event location and I also want to show the events within a certain radius R from a point P. Do you store the lat lon as a Point for each event and construct a polygon of a circle(P,R) and check if the event point is contained inside the polygon? What do you recommend as the best practice? Thanks -Aaron > > Regards, > -Justin > > [1] http://code.google.com/p/geopy/ > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
GeoDjango question about US zipcode lookup and spatial query
Hi all, I am checking out GeoDjango and going through the installation and presentation. I esp. like this one which is very well done http://geodjango.org/presentations/GeoDjango%20-%20A%20world-class%20Geographic%20Web%20Framework%20(DjangoCon%20-%20Sept.%206,%202008).pdf I do have a few basic questions - on slide 37, there's a Zipcode model, how does one populate this model? Are we using fe_2007_us_zcta500.shp? If so, is there a program which converts the zipcode shape from the shape file? - on slide 41, there is an Address model, does GeoDjango provide geocoding which converts it to (lat, lon) for spatial query? If not, does it mean that one has to query Google/Yahoo/MSFT WebServices? Thanks -Aaron --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
confused about django-tagging usage
Hi, I am a bit confused about the best practices for using the django-tagging. >From the docs/overview.txt. It seems you can either have the tags stored inside a model OR you can have them stored on the tagging_tag table. E.g. class Link(models.Model): ... def add_tag(self, tagname): Tag.objects.add_tag(self, tagname) def get_tags(self): Tag.objects.get_for_object(self) vs class Link(models.Model): ... tags = TagField() Assuming the tags are common and have significant overlap across the objects, it seems better to store them outside the model? I guess the advantage of using TagField is you can generate a ModelForm automatically and be represented by a tagging.forms.TagField. But then you can also workaround it by having something like class LinkForm(forms.ModelForm): tags = TagField() class Meta: model = LinkForm But you probably have to do some manual work to populate this field from your views by calling the get_tags() to fill this out? Just curious on what your experiences are. -Aaron --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---