AttributeError at /scoutstablefilter/

type object 'ScoutTable' has no attribute '_default_manager'

Request Method: GET
Request URL: http://localhost:8000/scoutstablefilter/
Django Version: 3.0.3
Exception Type: AttributeError
Exception Value:

type object 'ScoutTable' has no attribute '_default_manager'

Exception Location:
C:\Users\nader\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\views\generic\list.py
in get_queryset, line 33
Python Executable:
C:\Users\nader\AppData\Local\Programs\Python\Python38-32\python.exe
Python Version: 3.8.1
Python Path:

['C:\\Dev\\python\\scouts',
 
'C:\\Users\\nader\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip',
 'C:\\Users\\nader\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs',
 'C:\\Users\\nader\\AppData\\Local\\Programs\\Python\\Python38-32\\lib',
 'C:\\Users\\nader\\AppData\\Local\\Programs\\Python\\Python38-32',
 'C:\\Users\\nader\\AppData\\Roaming\\Python\\Python38\\site-packages',
 
'C:\\Users\\nader\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages']

Server time: Wed, 25 Mar 2020 17:59:25 +0000
Traceback Switch to copy-and-paste view
<http://localhost:8000/scoutstablefilter/#>

   -
   
C:\Users\nader\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\exception.py
    in inner
   1.

                  response = get_response(request)

      …
   ▶ Local vars <http://localhost:8000/scoutstablefilter/#>
   -
   
C:\Users\nader\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py
    in _get_response
   1.

                      response =
self.process_exception_by_middleware(e, request)

      …
   ▶ Local vars <http://localhost:8000/scoutstablefilter/#>
   -
   
C:\Users\nader\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py
    in _get_response
   1.

                      response = wrapped_callback(request,
*callback_args, **callback_kwargs)

      …
   ▶ Local vars <http://localhost:8000/scoutstablefilter/#>
   -
   
C:\Users\nader\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\views\generic\base.py
    in view
   1.

                  return self.dispatch(request, *args, **kwargs)

      …
   ▶ Local vars <http://localhost:8000/scoutstablefilter/#>
   -
   
C:\Users\nader\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\views\generic\base.py
    in dispatch
   1.

              return handler(request, *args, **kwargs)

      …
   ▶ Local vars <http://localhost:8000/scoutstablefilter/#>


On Wed, Mar 25, 2020 at 4:19 PM Nader Elsisi <naderels...@gmail.com> wrote:

> models.py
> class Contact(models.Model):
>     gender_CHOICES = (
>         ('M', 'Male'),
>         ('F', 'Female'),
>     )
>
>     # Field name made lowercase.
>     id = models.IntegerField(db_column='id', primary_key=True)
>     # Field name made lowercase.
>     name = models.CharField(
>         db_column='name', max_length=80, blank=True, null=True)
>     # Field name made lowercase.
>     family = models.ForeignKey(
>         'Family', on_delete=models.CASCADE, db_column='familyid', blank=
> True, null=True)
>     # Field name made lowercase.
>     isdeceased = models.BooleanField(
>         db_column='isdeceased', blank=True, null=True)
>     deceased_date = models.DateField(blank=True, null=True)
>     # Field name made lowercase.
>     phone = models.CharField(
>         db_column='phone', max_length=50, blank=True, null=True)
>     email = models.EmailField(blank=True, null=True)
>     # Field name made lowercase.
>     gender = models.CharField(
>         db_column='gender', max_length=1, choices=gender_CHOICES, blank=
> True, null=True)
>
>     # Field name made lowercase.
>     fullname = models.CharField(
>         db_column='fullname', max_length=255, blank=True, null=True)
>     alias = models.CharField(
>         db_column='alias', max_length=50, blank=True, null=True)
>
>     birth_date = models.DateField(blank=True, null=True)
>     health_issues = models.TextField(
>         db_column='health_issues',  blank=True, null=True)
>
>     isscout = models.BooleanField(
>         db_column='isscout', blank=True, null=True)
>
>     isparent = models.BooleanField(
>         db_column='isparent', blank=True, null=True)
>
>     isleader = models.BooleanField(
>         db_column='isleader', blank=True, null=True)
>
>     fatherid = models.ForeignKey(
>         'self', blank=True, null=True, related_name='father', on_delete
> =models.CASCADE)
>     motherid = models.ForeignKey(
>         'self', blank=True, null=True, related_name='mother', on_delete
> =models.CASCADE)
>     spouseid = models.ForeignKey(
>         'self', blank=True, null=True, related_name='spouse', on_delete
> =models.CASCADE)
>     date_married = models.DateField(blank=True, null=True)
>     # Field name made lowercase.
>     # title = models.CharField(
>     #     db_column='title', max_length=50, blank=True, null=True)
>
>     def __str__(self):
>         return self.name
>
>     class Meta:
>         managed = True
>         db_table = 'contacts'
>         ordering = ['name']
> class Contact(models.Model):
>     gender_CHOICES = (
>         ('M', 'Male'),
>         ('F', 'Female'),
>     )
>
>     # Field name made lowercase.
>     id = models.IntegerField(db_column='id', primary_key=True)
>     # Field name made lowercase.
>     name = models.CharField(
>         db_column='name', max_length=80, blank=True, null=True)
>     # Field name made lowercase.
>     family = models.ForeignKey(
>         'Family', on_delete=models.CASCADE, db_column='familyid', blank=
> True, null=True)
>     # Field name made lowercase.
>     isdeceased = models.BooleanField(
>         db_column='isdeceased', blank=True, null=True)
>     deceased_date = models.DateField(blank=True, null=True)
>     # Field name made lowercase.
>     phone = models.CharField(
>         db_column='phone', max_length=50, blank=True, null=True)
>     email = models.EmailField(blank=True, null=True)
>     # Field name made lowercase.
>     gender = models.CharField(
>         db_column='gender', max_length=1, choices=gender_CHOICES, blank=
> True, null=True)
>
>     # Field name made lowercase.
>     fullname = models.CharField(
>         db_column='fullname', max_length=255, blank=True, null=True)
>     alias = models.CharField(
>         db_column='alias', max_length=50, blank=True, null=True)
>
>     birth_date = models.DateField(blank=True, null=True)
>     health_issues = models.TextField(
>         db_column='health_issues',  blank=True, null=True)
>
>     isscout = models.BooleanField(
>         db_column='isscout', blank=True, null=True)
>
>     isparent = models.BooleanField(
>         db_column='isparent', blank=True, null=True)
>
>     isleader = models.BooleanField(
>         db_column='isleader', blank=True, null=True)
>
>     fatherid = models.ForeignKey(
>         'self', blank=True, null=True, related_name='father', on_delete
> =models.CASCADE)
>     motherid = models.ForeignKey(
>         'self', blank=True, null=True, related_name='mother', on_delete
> =models.CASCADE)
>     spouseid = models.ForeignKey(
>         'self', blank=True, null=True, related_name='spouse', on_delete
> =models.CASCADE)
>     date_married = models.DateField(blank=True, null=True)
>
>
>     def __str__(self):
>         return self.name
>
>     class Meta:
>         managed = True
>         db_table = 'contacts'
>         ordering = ['name']
>
>
> class Scout(Contact):
>     objects = models.Manager()
>
>     contact = models.OneToOneField('Contact', on_delete=models.CASCADE,
> db_column='contact_id',
>                                    parent_link=True, related_name=
> 'scoutcontact')  # Field name made lowercase.
>     current_class = models.ForeignKey(
>         OvClass, on_delete=models.CASCADE, blank=True, null=True)
>     current_grade = models.IntegerField(null=True, blank=True)
>     g1_id = models.ForeignKey(
>         'self', on_delete=models.CASCADE, blank=True, null=True,
> related_name='g1')
>     g2_id = models.ForeignKey(
>         'self', on_delete=models.CASCADE, blank=True, null=True,
> related_name='g2')
>     hobbies = models.TextField(
>         db_column='hobbies',  blank=True, null=True)
>     skills = models.TextField(
>         db_column='skills',  blank=True, null=True)
>     reason = models.TextField(
>         db_column='reason',  blank=True, null=True)
>     date_joined = models.DateField(blank=True, null=True)
>     grade_joined = models.IntegerField(blank=True, null=True)
>     start_academic_year = models.IntegerField(blank=True, null=True)
>
>
>
>     class Meta:
>         managed = True
>         db_table = 'scout'
>         default_manager_name = 'objects'
>         # ordering = ['name']
>
>
>
>
> tables.py
> class ScoutTable(tables.Table):
>     objects = models.Manager()
>
>     select_chkbox = tables.CheckBoxColumn(accessor="pk", attrs={
> "th__input": {"onclick": "toggle(this)"}, "td__input": {"onclick":
> "countbox(this)"}},
>                                           orderable=False)
>
>     SN = tables.Column(empty_values=(), orderable=False)
>     name = tables.LinkColumn('update-scout', args=[A('pk')])
>     # name = tables.LinkColumn('update-contact', args=[A('pk')])
>     # delete = tables.TemplateColumn(TEMPLATE, orderable=False)
>     delete = tables.LinkColumn('delete_item', args=[A('pk')], attrs={
>         'a': {'class': 'btn btn-small btn-dark'}
>     })
>
>
>     def __init__(self, *args, **kwargs):
>         super(ScoutTable, self).__init__(*args, **kwargs)
>         self.counter = itertools.count(1)
>         # self.cells = CellAccessor(self)
>
>
>
>     #
>
>     def render_SN(self, record):
>
>         pg = getattr(self, 'paginator', None)
>         if pg:
>             v = next(self.counter)
>             # 'Row %d' % next(self.counter)
>             return v + self.paginator.per_page * (self.page.number-1)
>         else:
>             return next(self.counter)
>
>
>     class Meta:
>
>         model = Scout
>         default_manager_name = 'objects'
>
>         fields = ('select_chkbox', 'SN', 'id', 'name', 'family',
>                   'phone', 'email',
>                   )
>
>
>         # managed = True
>         attrs = {"class": "table-striped table-bordered", 'width': '100%'}
>         empty_text =
> "There are no Contact matching the search criteria..."
>
>
> On Wed, Mar 25, 2020 at 2:12 PM Motaz Hejaze <trapper...@gmail.com> wrote:
>
>> it will be much easier if you share your models and the error
>>
>> On Wed, Mar 25, 2020 at 8:06 PM Nader Elsisi <naderels...@gmail.com>
>> wrote:
>>
>>> I have a tables2 table. And I got this error. I searched the net and
>>> followed a lot
>>> But couldn't fix it.
>>>
>>> The tables2 object is for a inherited model and linked through onetoone
>>> foreign key.
>>>
>>> The main object table2 is working fine. But this inherited model has
>>> more attributes and fewer objects than the main object.
>>>
>>>
>>> I checked the naming of fields.
>>> Tried to setup the default manager.
>>>
>>> Thanks for your help
>>>
>>> --
>>> 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+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CA%2BkREvpv1g-7JzCYNSzjvVXJ7cQwt14pMuimf_NSuspEABucXQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CA%2BkREvpv1g-7JzCYNSzjvVXJ7cQwt14pMuimf_NSuspEABucXQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHV4E-fXbM3ET6oQyX66pe6n%2B%3DPN_8koPTzhOYb-1EFoi9MRtQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAHV4E-fXbM3ET6oQyX66pe6n%2B%3DPN_8koPTzhOYb-1EFoi9MRtQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BkREvqHmJunnfUXUa%2BawA5Bcj2ctcBVtTRv%2B9EH2w3t%2BMcgJw%40mail.gmail.com.

Reply via email to