[EMAIL PROTECTED] ha scritto:
[...]
class GeoLocation(models.Model):
> [...]
+ # the longitude of the location
+ longitude = models.IntegerField()
+ # the latitude of the location
+ latitude = models.IntegerField()
+ # the geo location detail, in JSON format as returned by the geocoder
+ geo_location = models.CharField(maxlength=256)
+
+ def get_coordinates(self):
+ return self.latitude, self.longitude
+ coordinates = property(get_coordinates)
- return super(GeoLocation, self).save()
+ def get_address(self):
+ return self.geo_location['address']
Questo credo sia un errore.
geo_location รจ una stringa, si deve fare prima un json.loads
Inoltre non sono sicuro che il campo 'address' sia sempre presente nel
valore restituito dal geo coder.
> [...]
Modified: code/pythonisti/trunk/pythonisti/apps/geo/views.py
==============================================================================
--- code/pythonisti/trunk/pythonisti/apps/geo/views.py (original)
+++ code/pythonisti/trunk/pythonisti/apps/geo/views.py Sun Jan 21 18:30:52 2007
@@ -10,10 +10,11 @@
locations = models.GeoLocation.objects.all()
content = []
- for item in locations:
+ for location in locations:
content.append({
- 'info': item.username.username,
- 'location': simplejson.loads(item.geolocation)
+ # XXX: to fix
+ 'info': location.users.all() or "anonymous",
+ 'location': simplejson.loads(location.geo_location)
})
Come detto, gli utenti anonimi non hanno un profilo
Quel metodo .all su users cosa restituisce?
[...]
class Place(models.Model):
- country = models.ForeignKey(Country)
+ country = models.ForeignKey(Country, related_name="places")
address = models.CharField(blank=True, maxlength=50)
city = models.CharField(blank=False, maxlength=50)
- # the region, area of living
- administrative_area = models.CharField(blank=True, maxlength=50)
# the province or district
- sub_administrative_area = models.CharField(blank=True, maxlength=50)
+ sub_administrative_area = models.CharField(blank=True, maxlength=50,
+ verbose_name="Province or district")
+ # the region, area of living
+ administrative_area = models.CharField(blank=True, maxlength=50,
+ verbose_name="Region, county or area of living")
# this makes sense in federal countries like USA
state = models.CharField(blank=True, maxlength=50)
# the post/zip code itself
- postcode = models.CharField(blank=True, maxlength=10)
+ postcode = models.CharField(blank=True, maxlength=10,
+ verbose_name="Post/Zip code")
+
Che dici, magari possiamo fin da ora usare stringhe traducibili per i
vari campi?
> [...]
Saluti Manlio Perillo
_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python