Skip to content

Instantly share code, notes, and snippets.

View agungid's full-sized avatar

M Agung Sutrisno agungid

View GitHub Profile
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'nama_tabel',
'USER': 'username',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '',
}
}
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)
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')
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)
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)