Problem with inheritance in Django models

0

In my Django application I am working with calendars. For my purposes I have to use the classes Event and Occurrence of the module Django-Scheduler but adding new fields. I would like to know how to inherit from those classes to build my own models and add more fields in addition to those brought by parent classes.

I tried to do this in my models.py file:

from schedule.models import Event, Occurrence

class Evento(Event):
    evento_padre = models.ForeignKey('self', on_delete=models.CASCADE)

class Ocurrencia(Occurrence):
    plan = models.ManyToManyField(Plan)

But when I run the manage.py makemigrations I get this error:

  

SystemCheckError: System check identified some issues:

     

ERRORS:
     calendar.Event.event_ptr: (fields.E300) Field defines a relation with model 'Event', which is either not installed, or is abstract.
     calendar.Occurrence.occurrence_ptr: (fields.E300) Field defines a relationship with model 'Occurrence', which is either not installed, or is abstract.

    
asked by Ethan 16.06.2017 в 21:08
source

1 answer

1

I'm not sure, but when the error tells you that the class is not installed, as your error message says: 'Occurrence', which is either not installed, or is abstract. It means that Django does not find that class and this may be because it is not added to settings.py in instaled_apps . Probably add 'django-scheduler' .

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django-scheduler',
]
    
answered by 29.07.2017 / 20:46
source