Omadbek Qosimov's blog
27 subscribers
43 photos
13 videos
5 files
47 links
Download Telegram
punycode domain nginx serverga joylashtirayotganda include proxy_params;
ni
yozish shart emas chunki

siz Xost sarlavhasini ikki marta kiritgansiz.


proxy_set_header Host $host;
include proxy_params;


Faylni ko'rib chiqsangiz, proxy_paramsu allaqachon o'rnatilganligini ko'rasiz. Uni qayta o'rnatish ikki qiymatning vergul bilan birlashtirilishiga olib keladi.

Ushbu fayl ichida siz ushbu faylni qo'shganingizda foydalaniladigan oldindan o'rnatilgan sarlavhalarni topasiz. O'zingizning konfiguratsiyangizda ushbu qatorlarni takrorlashingiz shart emas.


ubuntu@vmtest-ubuntu2004:~$ cat /etc/nginx/proxy_params
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;


Siz o'zingizning qo'shimchangizni proxy_set_header Host $host; konfiguratsiyadan olib tashlashingiz mumkin.


batafsil


#deploy #nginx #punycode
πŸ”₯3πŸŽ‰2❀1πŸ‘1
docker error
"chunked"


pip3 uninstall requests
pip3 install requests=2.28.1



#docker #chunked
πŸ”₯1
pg_hba.conf postgresga tashqi iplardan kirish uchun ruxsat ochish

#postgresql #network
πŸ‘2
πŸ‘2
Omadbek Qosimov's blog
Photo
recourse.py

from import_export import resources, fields
from .models import Order
from import_export.widgets import ForeignKeyWidget,ManyToManyWidget
from apps.depreciation.models import DepreciationItem
from apps.profile.models import User

class OrderResource(resources.ModelResource):
customer = fields.Field(
column_name='Customer Name',
attribute='user',
widget=ForeignKeyWidget(User, 'id'))
saler = fields.Field(
column_name='Saler Name',
attribute='user',
widget=ForeignKeyWidget(User, 'id'))

depreciation = fields.Field(column_name="Depreciation")
category = fields.Field(column_name='Category name')

class Meta:
model = Order
fields = ('id', 'status', 'customer','price','category','depreciation','created_at')

def dehydrate_category(self, order):
return order.product.depreciation_cat.title

def dehydrate_depreciation(self, order):
deprecation = DepreciationItem.objects.get(office = order.product.office,category = order.product.depreciation_cat)
return f"year:{deprecation.year}, office: {deprecation.office.title}, percantage: {deprecation.percentage}"
def dehydrate_customer(self, order):
if order.user:
return f"{order.user.first_name} {order.user.last_name}"
return order.user.username

def dehydrate_saler(self, order):
if order.saler:

return order.saler.get_full_name() if order.saler.get_full_name() else order.saler.username
return ""


admin.py

@admin.register(Order)
class OrderAdmin(AdminChartMixin, ImportExportModelAdmin):
list_display = ('product', 'user', 'status', 'created_at', 'updated_at')
list_filter = ('status', 'created_at', 'updated_at')
list_editable = ('status', )
list_chart_type = "pie"
list_chart_data = {}
list_chart_options = {"aspectRatio": 6}
list_chart_config = None
readonly_fields = ('saler',)
resource_class = OrderResource

def get_list_chart_data(self, queryset):
if not queryset:
return {}
data = queryset.values('status').annotate(count=Count('id'))
labels = [entry['status'] for entry in data]
counts = [entry['count'] for entry in data]

return {
"labels": labels,
"datasets": [
{
"data": counts,
"backgroundColor": [
"#79aec8", "#b6d6f2", "#aac3e4", "#8aafd4",
][:len(labels)],
},
],
}
def save_model(self, request, obj, form, change):
if obj.status == 'purchased' and not obj.saler:
obj.saler = request.user
super().save_model(request, obj, form, change)


pip install django-import-export

#csv #admin
πŸ‘1
for m2m changing for pre_save signal

#m2m #pre_save #bug
πŸ‘3
Order by property but its not optimization code

#property , #filter
πŸ‘2
πŸ‘2
πŸ”₯3