'NoneType' object has no attribute '_meta'
ERROR LOG :
'NoneType' object has no attribute '_meta'
Request Method: POST
Request URL: http://127.0.0.1:8000/api/action-groups/
Django Version: 1.11.20
Python Executable: /var/www/united4earth/venv/bin/python3
Python Version: 3.6.7
Python Path: ['/var/www/united4earth', '/var/www/djangoldp', '/var/www/html', '/var/www/united4earth', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/var/www/united4earth/venv/lib/python3.6/site-packages']
Server time: ven, 15 Mar 2019 11:56:54 +0100
Installed Applications:
['data_manager',
'djangoldp',
'djangoldp_conversation',
'guardian',
'registration',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/var/www/united4earth/venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
58. return view_func(*args, **kwargs)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/viewsets.py" in view
116. return self.dispatch(request, *args, **kwargs)
File "/var/www/djangoldp/djangoldp/views.py" in dispatch
135. response = super(LDPViewSet, self).dispatch(request, *args, **kwargs)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
495. response = self.handle_exception(exc)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/views.py" in handle_exception
455. self.raise_uncaught_exception(exc)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
492. response = handler(request, *args, **kwargs)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/mixins.py" in create
20. serializer.is_valid(raise_exception=True)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/serializers.py" in is_valid
236. self._validated_data = self.run_validation(self.initial_data)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/serializers.py" in run_validation
434. value = self.to_internal_value(data)
File "/var/www/united4earth/venv/lib/python3.6/site-packages/rest_framework/serializers.py" in to_internal_value
489. primitive_value = field.get_value(data)
File "/var/www/djangoldp/djangoldp/serializers.py" in get_value
353. container_id = Model.container_id(self.parent.instance)
File "/var/www/djangoldp/djangoldp/models.py" in container_id
47. view_name = '{}-list'.format(instance._meta.object_name.lower())
Exception Type: AttributeError at /api/action-groups/
Exception Value: 'NoneType' object has no attribute '_meta'
POST JSON :
{
"@context": "http://owl.openinitiative.com/oicontext.jsonld",
"@graph": [
{
"@id": "./",
"http://happy-dev.fr/owl/#actiongroups": {
"@id": "http://127.0.0.1:8000/api/action-groups/2/"
},
"http://happy-dev.fr/owl/#dates": {
"@id": "_:b4983"
},
"http://happy-dev.fr/owl/#description": "``` 'NoneType' object has no attribute '_meta'",
"http://happy-dev.fr/owl/#frequency": "``` 'NoneType' object has no attribute '_meta'",
"http://happy-dev.fr/owl/#kind": "``` 'NoneType' object has no attribute '_meta'",
"http://happy-dev.fr/owl/#loomios": {
"@id": "_:b4984"
},
"http://happy-dev.fr/owl/#objective": "``` 'NoneType' object has no attribute '_meta'",
"http://happy-dev.fr/owl/#place": "``` 'NoneType' object has no attribute '_meta'",
"http://happy-dev.fr/owl/#representatives": {
"@id": "http://127.0.0.1:8000/api/representatives/4/"
},
"http://happy-dev.fr/owl/#title-informations": "Informations du groupe (2/3)",
"http://happy-dev.fr/owl/#title-modules": "Modules de support (3/3)",
"http://happy-dev.fr/owl/#title-objectives": "Définition de l'objectif (1/3)",
"http://www.w3.org/2000/01/rdf-schema#label": "``` 'NoneType' object has no attribute '_meta'"
},
{
"@id": "_:b4983",
"http://happy-dev.fr/owl/#date": "2019-03-22"
},
{
"@id": "_:b4984",
"http://happy-dev.fr/owl/#title": "``` 'NoneType' object has no attribute '_meta'",
"http://happy-dev.fr/owl/#url": "https://git.happy-dev.fr/startinblox/djangoldp-packages/djangoldp/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D="
}
]
}
DATA MODEL :
class ActionGroup(models.Model):
name = models.CharField(max_length=255, verbose_name=u"Nom du groupe")
objective = models.CharField(max_length=255, verbose_name=u"Objectif")
description = models.TextField(blank=True, null=True, verbose_name=u"Description")
place = models.TextField(blank=True, null=True, verbose_name=u"Lieu")
frequency = models.TextField(blank=True, null=True, verbose_name=u"Fréquence")
kind = models.TextField(blank=True, null=True, verbose_name=u"Type d'action")
image = models.URLField(verbose_name=u"Image", default=settings.SITE_URL + "static/img/action_group_blank.png")
representatives = models.ManyToManyField(Representative, blank=True, related_name='action_groups')
members = models.ManyToManyField(User, blank=True)
actiongroups = models.ManyToManyField("self", blank=True)
dates = models.ManyToManyField(ActionDate, blank=True)
author = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='created_groups', blank=True, null=True)
conversation = models.ManyToManyField(Thread, blank=True)
loomios = models.ManyToManyField(LoomioTopic, blank=True)
slug = models.SlugField(blank=True, null=True, unique=True)
class Meta:
auto_author = 'author'
permissions = (
('view_actiongroup', 'Read'),
('control_actiongroup', 'Control'),
)
def nextdate(self):
nextdate = self.dates.filter(date__gte=datetime.today()).order_by("date").first()
if nextdate:
return str(nextdate)
elif len(self.dates.all()) == 0:
return 0
else:
return "exhausted"
def __str__(self):
return self.name