Saturday, April 23, 2016

Re: Question about admin.StackedInline



On Friday, April 22, 2016 at 12:37:40 PM UTC-4:30, Said Akhmedbayev wrote:
Thank you in advance!

I am new to Django, trying to build a small app for my friend. The app mock-up is here 

Basically, the app will include Units/Lessons with Subsection, each Subsection will end with several questions.

Here my models.py

from django.db import models


# Create your models here.
class Unit(models.Model):
    title = models.CharField(max_length=150, blank=True, null=True)
    unit_number = models.PositiveIntegerField(blank=True, null=True, default=1)

    def __str__(self):
        return self.title



class SubSection(models.Model):
    subsection_text = models.TextField(default='SUBSECTION TEXT')
    question = models.ForeignKey(Unit, related_name='subsection_to_question')


class Question(models.Model):
    question_text = models.CharField(max_length=2000, default='QUESTION TEXT')
    subsection = models.ForeignKey(SubSection, related_name='question_to_subsection',)

And here is my admin.py

from django.contrib import admin
from .models import Unit, SubSection


# Register your models here.
class SubSectionInline(admin.StackedInline):
    model = SubSection


@admin.register(Unit)
class UnitAdmin(admin.ModelAdmin):
    inlines = [
        SubSectionInline,
    ]

Here is what I see in the admin 

It is all nice, but it is not exactly what I want :-). Here is what I want to see, it is photoshop mock-up


My questions are:

Is this even possible to do with the approach I took?

If it is possible, can you please help me to figure out how to make it?

Hi,
You should take a look at the django-nested-admin project: https://pypi.python.org/pypi/django-nested-admin/3.0.0
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b00157dd-9ade-4f6d-a462-c433ba1f8ad3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment