• urls.py kodlari
  • View.py kodlari.
  • Dasturiy injiniring va raqamli iqtisodiyot




    Download 2,25 Mb.
    bet9/13
    Sana30.12.2023
    Hajmi2,25 Mb.
    #129150
    1   ...   5   6   7   8   9   10   11   12   13
    Bog'liq
    Individual Loyiha 2

    Admin.py kodlari
    from django.contrib import admin

    from .models import *


    @admin.register(Club)
    class ClubAdmin(admin.ModelAdmin):
    list_display = ( 'nom', 'davlat')
    list_filter = ('davlat',)
    search_fields = ('nom', 'davlat')

    @admin.register(Player)


    class PlayerAdmin(admin.ModelAdmin):
    list_display = ('ism', 'club')
    list_filter = ('club',)
    search_fields = ('ism',)
    autocomplete_fields = ('club',)

    @admin.register(Transfer)


    class TransferAdmin(admin.ModelAdmin):
    list_display = ('player', 'eski', 'yangi', 'mavsum', 'narxi')
    list_filter = ('mavsum',)
    search_fields = ('mavsum', 'narxi',)
    autocomplete_fields = ('player','eski', 'yangi')

    admin.site.register(Hozirgi_mavsum)


    urls.py kodlari

    from django.contrib import admin


    from django.urls import path
    from django.conf.urls.static import static
    from django.conf import settings
    from asosiy.views import *

    urlpatterns = [


    path('admin/', admin.site.urls),
    path('', about),
    path('club/', club),
    path('player/', player),
    path('latest-transfers/', latest_transfer),
    path('countries//', davlat),
    path('mavsum//', bitta_mavsum),
    path('playeru20/', u20),
    path('stats/', stats),
    path('transfer_record/', transfer_record),
    path('transfer-archive/', arxive),
    path('clubs//', bitta_club),

    ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


    View.py kodlari.
    from django.shortcuts import render, redirect
    from django.db.models import Sum

    from .models import *

    def about(request):
    return render(request, 'about.html')

    def club(request):


    data = {'club': Club.objects.annotate(umum_summa=Sum('futbolchilari__tr_narxi')).order_by('-umum_summa')}
    return render(request, 'clubs.html', data)

    def player(request):


    data = {'player':Player.objects.all().order_by('-tr_narxi')}
    return render(request, 'players.html', data)

    def latest_transfer(request):


    data = {'trans': Transfer.objects.order_by('-narxi')}
    return render(request, 'latest-transfers.html', data)
    def davlat(request,soz):
    data = {'davlat':Club.objects.filter(davlat=soz),
    'mamlakat':soz}
    return render(request, 'england.html', data)

    def u20(request):


    from datetime import date, timedelta
    bugun = date.today()
    boshi = bugun - timedelta(days=20*365)
    pl = Player.objects.filter(t_yil__range=[boshi, bugun])

    data = {
    'players':pl,


    'h_yil': bugun.year
    }
    return render(request, 'U-20 players.html', data)

    def arxive(request):


    h_mavsum = Hozirgi_mavsum.objects.last().hozirgi_mavsum
    data = {
    'Transferlar': Transfer.objects.filter(mavsum__lt=h_mavsum).values('mavsum').distinct().order_by('-mavsum')
    }
    return render(request, 'transfer-archive.html', data)

    def bitta_mavsum(request, soz):


    data = {
    'mavsumgaoid': Transfer.objects.filter(mavsum=soz)
    }
    return render(request, '2017-18season.html', data)

    def bitta_club(request,son):


    data = {
    'club': Player.objects.filter(club=Club.objects.get(id=son))
    }
    return render(request, 'country-clubs.html', data)
    def stats(request):
    return render(request, 'stats.html')

    def transfer_record(request):


    data = {
    'tra': Transfer.objects.filter(narxi__gt=50).order_by('-narxi')[0:100]
    }
    return render(request, 'transfer-records.html', data)



    Download 2,25 Mb.
    1   ...   5   6   7   8   9   10   11   12   13




    Download 2,25 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Dasturiy injiniring va raqamli iqtisodiyot

    Download 2,25 Mb.