This file contains 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
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.mysql', | |
'NAME': 'nama_tabel', | |
'USER': 'username', | |
'PASSWORD': 'password', | |
'HOST': 'localhost', | |
'PORT': '', | |
} | |
} |
This file contains 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
from django.conf import settings | |
from django.conf.urls.static import static | |
if settings.DEBUG: | |
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) |
This file contains 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
SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) | |
STATIC_URL = '/static/' | |
STATIC_ROOT = 'static' | |
MEDIA_URL = '/media/' | |
MEDIA_ROOT = os.path.join(SITE_ROOT, 'media') |
This file contains 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
from __future__ import unicode_literals | |
import os | |
from uuid import uuid4 | |
from django.db import models | |
def file_image(instance, filename): | |
ext = filename.split('.')[-1] | |
filename = "%s.%s" % (str(uuid4()), ext) | |
return os.path.join('upload', filename) |
This file contains 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
from __future__ import unicode_literals | |
import os | |
from uuid import uuid4 | |
from django.db import models | |
class Karyawan (models.Model): | |
nama = models.CharField(max_length=100) | |
alamat = models.TextField(blank=True) |