I need one help. I am getting the below error while migrating the model file using Python and Django. I am explaining the errors below.
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 327, in execute
self.check()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
issues.extend(super(Command, self)._run_checks(**kwargs))
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/usr/local/lib/python2.7/dist-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/opt/lampp/htdocs/carClinic/carClinic/urls.py", line 7, in <module>
url(r'^admin/', admin.site.urls),
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py", line 280, in urls
return self.get_urls(), 'admin', self.name
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py", line 264, in get_urls
url(r'^%s/%s/' % (model._meta.app_label, model._meta.model_name), include(model_admin.urls)),
AttributeError: 'Personal' object has no attribute 'urls'
I am explaining my code below.
models.py:
from __future__ import unicode_literals
from django.db import models
from django.contrib import admin
from datetime import datetime
class Service(models.Model):
"""In this class the columns for service table has declared"""
cname = models.CharField(max_length=200)
date_of_service = models.DateTimeField(default=datetime.now, blank=True)
vechile_no = models.CharField(max_length=200)
service_type = models.CharField(max_length=200)
class Personal(models.Model):
"""In this class the columns for Person table has declared"""
name = models.CharField(max_length=200)
address = models.CharField(max_length=200)
phone = models.CharField(max_length=15)
driving_license = models.CharField(max_length=200)
email = models.CharField(max_length=200)
date = models.DateTimeField(default=datetime.now, blank=True)
admin.site.register(Service, Personal)
urls.py:
from django.conf.urls import url, include
from django.contrib import admin
admin.autodiscover()
urlpatterns = [
url(r'^admin/', admin.site.urls),
]
Here I need to display both classes inside admin panels. Please help me to resolve this issue.