[program:yoursite]
command=uwsgi --ini /etc/uwsgi.ini
autostart=true
autorestart=true
stderr_logfile = /tmp/uwsgi-err.log
stdout_logfile = /tmp/uwsgi.log
[uwsgi]
chdir = /home/projectroot
wsgi-file = /home/projectroot/wsgi.py
home = /home/projectroot/.env
logto = /var/log/uwsgi.log
master = true
processes = 10
socket = /tmp/yoursite.sock
vacuum = true
touch-reload = /tmp/yoursite.reload
server {
listen 80;
server_name yoursite.com;
access_log /home/var/log/nginx/yoursite.nginx.access.log;
error_log /home/var/log/nginx/yoursite.nginx.error.log;
location / {
uwsgi_pass unix:///tmp/yoursite.sock;
include uwsgi_params;
}
location /static/ {
alias /home/yoursite/assets/;
}
}
from django.contrib import admin
from .models import InviteBonus, TreeNode
class InviteBonusAdmin(admin.ModelAdmin):
list_display = ('id', 'inviter', 'line', 'newbie', 'use_date', 'total', 'paid')
list_filter = ('use_date', )
search_fields = ('inviter__company_id', )
admin.site.register(InviteBonus, InviteBonusAdmin)
admin.site.register(TreeNode)
from enhanced_cbv.views import ListFilteredView
from .models import MyModel
from .filters import MyFilter
class MiViewWithFilter(ListFilteredView):
filter_set = MyFilter
model = MyModel
import django_filters
from .models import MyModel
class MyFilter(django_filters.FilterSet):
def __init__(self, *args, **kwargs):
super(MyFilter, self).__init__(*args, **kwargs)
self.fields['email'].label = "New Email Label"
class Meta:
model = MyModel
fields = {'name': ['exact', 'icontains'],
'price': ['exact', 'gte', 'lte'],
}
class TrackForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(TrackForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.layout.append(Submit('save', 'save'))
class Meta:
model = Track
from django.utils.encoding import smart_unicode
class Lesson(models.Model):
....
def __unicode__(self):
smart_unicode(return self.name)
class Model(model.Model):
_image=models.ImageField(upload_to='folder')
thumb=models.ImageField(upload_to='folder')
description=models.CharField()
def set_image(self, val):
self._image = val
self._image_changed = True
# Or put whole logic in here
small = rescale_image(self.image,width=100,height=100)
self.image_small=SimpleUploadedFile(name,small_pic)
def get_image(self):
return self._image
image = property(get_image, set_image)
# this is not needed if small_image is created at set_image
def save(self, *args, **kwargs):
if getattr(self, '_image_changed', True):
small=rescale_image(self.image,width=100,height=100)
self.image_small=SimpleUploadedFile(name,small_pic)
super(Model, self).save(*args, **kwargs)