Creating Quiz App with Django Framework: Testing Your Knowledge on a Website

Posted by

Creating Quizz App With Django

Django Freymvorkida Test Yechuvchi Websayt Ya’ni Quizz App Yasaymiz

Python dastur tilida yozilgan Django freymvorkining yordamida quizz app yasashni o’rganamiz.

Step 1: Django Loyihasi Ochildi

Django loyihasini ochildikdan so’ng, quizz app uchun yangi bir app yarating:

python manage.py startapp quizzes

Step 2: Modelsni Yaratish

Quizz app uchun modelsni yaratish:

  
  from django.db import models

  class Question(models.Model):
      question_text = models.CharField(max_length=200)
      pub_date = models.DateTimeField('date published')

  class Choice(models.Model):
      question = models.ForeignKey(Question, on_delete=models.CASCADE)
      choice_text = models.CharField(max_length=200)
      votes = models.IntegerField(default=0)
  
  

Step 3: Admin Panelga Modelni qo’shish

Admin panelga modelni qo’shish uchun admin.py fayliga quyidagi kodni qo’shing:

  
  from django.contrib import admin
  from .models import Question

  admin.site.register(Question)
  
  

Step 4: URLsni Yaratish

Quizzes app uchun urls.py faylini yaratish:

  
  from django.urls import path
  from . import views

  urlpatterns = [
      path('', views.index, name='index'),
  ]
  
  

Step 5: Viewsni Yaratish

Quizzes app uchun views.py faylini yaratish:

  
  from django.shortcuts import render

  def index(request):
      return render(request, 'quizzes/index.html')
  
  

Step 6: Templatesni Yaratish

Quizz app uchun templates papkasida index.html faylini yaratish:

  
  <html>
  <head>
      <title>Quizzes App</title>
  </head>
  <body>
      <h1>Welcome to Quizzes App!</h1>
  </body>
  </html>
  
  

Step 7: Serverni Boshlash

Quizz appni serverda boshlash uchun quizz app nomi bilan serverni ishga tushirish:

python manage.py runserver

0 0 votes
Article Rating
17 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@elyorrozmetov4318
5 months ago

omadizi bersin, ko'pro loyihala qiling, o'zbek tilida hali hech kim proekt qilmagan

@user-js8gk5nv6x
5 months ago

alloh rozi bulsin brat

@JavohirWeb
5 months ago

Videoni qaysi dasturda yozasiz?

@UmarDeveloper
5 months ago

Bro frontend kodlarni yo githubga joylamapsiz yoki videoda korsatmapsiz

@sizgafoydali
5 months ago

Assalomu alaykum localhostda huddi shu test dasturi javoblari bitta adminga junatiladigan qilsa bo'ladimi. Yani bitta kampyuterdan runserver qilib turib o'quvchilar ishlagan testlarini server kampyuterda dashboardda ko'rinadigan qilsa bo'adimi.

@sizgafoydali
5 months ago

Darslaringiz zo'r hammasini qoldirmay kuzatib boraman. Siz bilan bog'lanishni iloji bormi?

@mustafobekmurodov2391
5 months ago

Assalomu alaykum aka bu praektni frontend shablonini qayerdan olsakbo'ladi agar bo'lsa tashab qo'ying aka

@marcelobc2230
5 months ago

thanks a lot friend…

@burhonabdullayev9372
5 months ago

Assalamu alaykum Akbarjon hali ham chiqarmadzku DRf da

@muhammadjonmuxtorov8991
5 months ago

👏👏👏

@burhonabdullayev9372
5 months ago

Assalamu alaykum yaxshimisz Abbarjon shuni Drf da ham qilib korsating iloji bolsa

@fazliddinbahromov7288
5 months ago

Raxmat katta. Alloh o'zi rozi bo'sin. Herokuga depoy qilishni ham o'rgatinng

@ruslannurmurodov9856
5 months ago

E gap yog`e . Zor qilib siz. Deploy ha qiling zor loyiha bolibdi 🙂

@atakhanovcode
5 months ago

3:26 😁

@koica-gr6gt
5 months ago

👍👍👍

@nematillonematov6498
5 months ago

👍👏👏

@nematillonematov6498
5 months ago

🔥🔥🔥🔥🔥