Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Please remove spaces #162

Open
thesayfulla opened this issue Jan 27, 2024 · 2 comments
Open

[Bug] Please remove spaces #162

thesayfulla opened this issue Jan 27, 2024 · 2 comments

Comments

@thesayfulla
Copy link

When I use your package I got spaces, please solve it!

image

@OskarPersson
Copy link
Owner

OskarPersson commented Jan 27, 2024

Please provide a complete example which illustrates this issue

@thesayfulla
Copy link
Author

My models.py file

from django.db import models
from django.contrib.auth import get_user_model

from ckeditor.fields import RichTextField

User = get_user_model()


class Category(models.Model):
    title = models.CharField(max_length=255)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "Category"
        verbose_name_plural = "Categories"


class Test(models.Model):
    title = models.CharField(max_length=255)
    information = RichTextField()
    category = models.ForeignKey(Category, on_delete=models.CASCADE)
    time = models.TimeField()
    popular = models.IntegerField(default=0)

    def __str__(self):
        return self.title


class Quiz(models.Model):
    test = models.ForeignKey(Test, on_delete=models.CASCADE)
    question = models.CharField(max_length=255)

    class Meta:
        verbose_name = "Quiz"
        verbose_name_plural = "Quizzes"

    def __str__(self):
        return self.question


class Answer(models.Model):
    quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE)
    answer = models.CharField(max_length=255)
    is_correct = models.BooleanField()

    def __str__(self):
        return f"{self.answer} - {self.is_correct}"


class Result(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    test = models.ForeignKey(Test, on_delete=models.CASCADE)
    correct = models.IntegerField()
    wrong = models.IntegerField()
    point = models.FloatField()

    def __str__(self):
        return f"{self.user.get_username()} - {self.test.title} - {self.point}"

My admin.py file

from django.contrib import admin

from nested_inline.admin import NestedStackedInline, NestedModelAdmin

from .models import Category, Test, Quiz, Answer, Result


class AnswerInline(NestedStackedInline):
    model = Answer


class QuizInline(NestedStackedInline):
    model = Quiz

    inlines = [AnswerInline]


class TestAdmin(NestedModelAdmin):
    model = Test
    inlines = [QuizInline]


admin.site.register(Category)
admin.site.register(Test, TestAdmin)
admin.site.register(Quiz)
admin.site.register(Answer)
admin.site.register(Result)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants