This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ContentTypeRestrictedFileField(models.FileField): | |
""" | |
Tomado de http://nemesisdesign.net/blog/coding/django-filefield-content-type-size-validation/ | |
Same as FileField, but you can specify: | |
* content_types - list containing allowed content_types. Example: ['application/pdf', 'image/jpeg'] | |
* max_upload_size - a number indicating the maximum file size allowed for upload. | |
2.5MB - 2621440 | |
5MB - 5242880 | |
10MB - 10485760 | |
20MB - 20971520 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GoogleMapMarker(object): | |
def __init__(self, latitude, longitude): | |
self.latitude = latitude | |
self.longitude = longitude | |
def __unicode__(self): | |
return '%f,%f'%(self.latitude, self.longitude) | |
def __len__(self): | |
return len(self.__unicode__()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GitHub username:armonge | |
Day job:Web Developer | |
Favorite open source project:Django | |
Open Source contributions (if any): | |
Stranded on an island, what 3 items do you take:Flashlight,matches, satellite phone | |
Tie-breaker, pick a number between 1 and 20,000:32433 |
NewerOlder