Another interesting blog about Django: http://djangotricks.blogspot.com/.
How to find out sizes of PostgreSQL databases and tables
pred 12 rokmi
class AccountingDocument(models.Model):That's it, no evolution needed, just run python manage.py syncdb in project directory.
type = models.ForeignKey('AccountingDocumentType', help_text='Typ účtovného dokladu.')
identifier = models.CharField(max_length=40, help_text='Číslo účtovného dokladu, jedinečný identifikátor, ktorý mu jeho vystavovateľ pridelil, napr. číslo faktúry.')
date_issued = models.DateField()
time_issued = models.TimeField(null=True, blank=True)
currency = models.ForeignKey('Currency')
value_without_VAT = models.FloatField(help_text='Suma účtovného dokladu bez DPH.')
VAT_rate = models.FloatField(default=19, help_text='Sadzba DPH.')
issuer = models.ForeignKey('BusinessUnit', related_name='AD_issuer')
recipient = models.ForeignKey('BusinessUnit', null=True, blank=True, related_name='AD_recipient')
scanned_items_file = models.FileField(null=True, blank=True, upload_to=settings.ACCOUNTING_DOCUMENTS_FILE_PATH)
class Meta:
unique_together = ("type", "identifier", "issuer")
# This is a list of lists of fields that must be unique when considered together.
# It's used in the Django admin and is enforced at the database level (i.e., the appropriate UNIQUE statements are included in the CREATE TABLE statement).
# For convenience, unique_together can be a single list when dealing with a single set of fields.
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/home/django/DSBIS/media/'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = 'http://localhost/DSBIS-media/'
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/admin-media/'
...
# application specific settings:
ACCOUNTING_DOCUMENTS_FILE_PATH = 'accounting_documents/'
class AccountingDocument(models.Model):
...
scanned_items_image = models.ImageField(null=True, blank=True, upload_to=settings.ACCOUNTING_DOCUMENTS_FILE_PATH)
scanned_items_file = models.FileField(null=True, blank=True, upload_to=settings.ACCOUNTING_DOCUMENTS_FILE_PATH)
scanned_items_file_path = models.FilePathField(null=True, blank=True, path=settings.ACCOUNTING_DOCUMENTS_FILE_PATH)
...
...
admin.site.register(AccountingDocument)
admin.site.register(AccountingDocumentType)
...
...
# Uncomment the next line to enable the admin:
(r'^admin/(.*)', admin.site.root),
...
AliasMatch /([^/]*\.css) /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/css/$1Do not forget restart Apache after those changes.
# to be able serve images for admin site (backslash at the end of next line is important):
Alias /admin-media/ /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/
<Directory /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media>
Order deny,allow
Allow from all
</Directory>
# to be able serve images for DSBIS application:
Alias /DSBIS-media/ /home/django/DSBIS/media/
<Directory /home/django/DSBIS/media>
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /home/django/DSBIS/apache/django.wsgi
<Directory /home/django/DSBIS/apache>
Order allow,deny
Allow from all
</Directory>
sudo /etc/init.d/apache2 restartIf user under which Apache runs is not allowed to write to destination directory, fix it (e.g. by using chown, chgrp or chmod).