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
4 months ago

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

@user-js8gk5nv6x
4 months ago

alloh rozi bulsin brat

@JavohirWeb
4 months ago

Videoni qaysi dasturda yozasiz?

@UmarDeveloper
4 months ago

Bro frontend kodlarni yo githubga joylamapsiz yoki videoda korsatmapsiz

@sizgafoydali
4 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
4 months ago

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

@mustafobekmurodov2391
4 months ago

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

@marcelobc2230
4 months ago

thanks a lot friend…

@burhonabdullayev9372
4 months ago

Assalamu alaykum Akbarjon hali ham chiqarmadzku DRf da

@muhammadjonmuxtorov8991
4 months ago

👏👏👏

@burhonabdullayev9372
4 months ago

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

@fazliddinbahromov7288
4 months ago

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

@ruslannurmurodov9856
4 months ago

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

@atakhanovcode
4 months ago

3:26 😁

@koica-gr6gt
4 months ago

👍👍👍

@nematillonematov6498
4 months ago

👍👏👏

@nematillonematov6498
4 months ago

🔥🔥🔥🔥🔥