- Timestamp:
- Aug 30, 2011, 8:18:09 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/models.py
r9637 r9638 5 5 6 6 from django.core import validators 7 from django.core.files.storage import FileSystemStorage 7 8 from django.db import models 8 9 from django.dispatch import receiver 9 10 from django.utils.encoding import smart_unicode 10 11 from django.utils.translation import ugettext_lazy as _ 12 13 14 # http://djangosnippets.org/snippets/976/ 15 class OverwriteStorage(FileSystemStorage): 16 def get_available_name(self, name): 17 """ 18 Returns a filename that's free on the target storage system, and 19 available for new content to be written to. 20 """ 21 # If the filename already exists, remove it as if it was a true file system 22 if self.exists(name): 23 self.delete(name) 24 return name 11 25 12 26 class BinaryField(models.Field): … … 142 156 class MeetBestand(models.Model): 143 157 meetrondje = models.ForeignKey(MeetRondje) 144 bestand = models.FileField(upload_to='scan-data/%Y/%m/%d' )158 bestand = models.FileField(upload_to='scan-data/%Y/%m/%d',storage=OverwriteStorage()) 145 159 is_imported = models.BooleanField(default=False) 146 160 class Meta:
Note:
See TracChangeset
for help on using the changeset viewer.