-1

I'm a newbie to django world. While doing and academic project i'm required to implement tree structure in django.

The concept is to make a user hierarchy so that one use can come as subordinate of another user.

Here is my models.py

from django.db import models

from django.contrib.auth.models import User

import mptt

from mptt.models import MPTTModel, TreeForeignKey



class App_model(models.Model):
    case_id = models.CharField(max_length=30)
    p_stn= models.CharField(max_length=50)
    case_description= models.TextField()
    officer= models.ForeignKey(User)
    date_created=models.DateTimeField(auto_now=True,auto_now_add=False)


class Testmptt(MPTTModel):
    name = models.ForeignKey(App_model)
    parent =TreeForeignKey('self',null=True,blank=True,related_name='children',db_index=True)

mptt.register(Testmptt)

My settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'debug_toolbar',
    'mptt',
    'django_mptt_admin',

My admin.py

from officerapp.models import App_model

from django_mptt_admin.admin import DjangoMpttAdmin

class App_modelAdmin(DjangoMpttAdmin):
    pass

admin.site.register(App_model,App_modelAdmin)

Problem is that when i use admin interface it shows error while loading form the server.

Screenshot of this error is here in the following link.

https://onedrive.live.com/redir?resid=89B428B7D40DE3FF!193&authkey=!AOg-TdOHiPfvfuA&v=3&ithint=photo%2cpng

Any one to help ?

1 Answers1

0

My guess is that you are using the MPTTAdmin class on your non-MPTT model - so the admin page is looking for a bunch of fields that App_model doesn't have. You need to use the MPTTAdmin on your Testmptt model instead.

MBrizzle
  • 1,783
  • 1
  • 18
  • 31