djangosqlitedjango-modelsfedora-25

System check identified 3 issues (0 silenced)


what could the issue with my model.py .i have tried everything nothing happens.and i think i defined my foreign key the right way .could it be a problem with my defining or do i have to use memberid.user in my foreginkey or what would be effect.any contribution is welcomed.

Performing system checks...

Unhandled exception in thread started by <function wrapper at 0x7f6a926d69b0>
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
    self.check(display_num_errors=True)
  File "/usr/lib64/python2.7/site-packages/django/core/management/base.py", line 405, in check
    raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
tithe.tithe.memberid: (fields.E300) Field defines a relation with model 'memberid', which is either not installed, or is abstract.
tithe.tithe.memberid: (fields.E307) The field tithe.tithe.memberid was declared with a lazy reference to 'tithe.memberid', but app 'tithe' doesn't provide model 'memberid'.
tithe.tithe: (models.E012) 'unique_together' refers to the non-existent field 'IntegerField'.

System check identified 3 issues (0 silenced).
Performing system checks...

Unhandled exception in thread started by <function wrapper at 0x7f3d3ccdc9b0>
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
    self.check(display_num_errors=True)
  File "/usr/lib64/python2.7/site-packages/django/core/management/base.py", line 405, in check
    raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
tithe.tithe.memberid: (fields.E300) Field defines a relation with model 'User', which is either not installed, or is abstract.
tithe.tithe.memberid: (fields.E307) The field tithe.tithe.memberid was declared with a lazy reference to 'tithe.user', but app 'tithe' doesn't provide model 'user'.
tithe.tithe: (models.E012) 'unique_together' refers to the non-existent field 'IntegerField'.

this my model.py code

from django.utils import timezone
from django.db import models

# Create your models here.
class tithe(models.Model):
    memberid = models.ForeignKey('User')
    membername = models.CharField(max_length=45)
    receitcode = models.CharField(max_length=45)
    tithes = models.IntegerField()
    combinedoffering = models.IntegerField()
    campmeetingoffering = models.IntegerField()
    churchbuilding = models.IntegerField()
    conference = models.IntegerField()
    localchurch = models.IntegerField()
    funds = models.IntegerField()
    total = models.IntegerField()
    created_date = models.DateTimeField(
            default=timezone.now)
    published_date = models.DateTimeField(
            blank=True, null=True)

    def publish(self):
        self.published_date = timezone.now()
        self.save()

    def __str__(self):
        return self.receitcode

    class Meta:
        unique_together = ["receitcode","IntegerField"]
        ordering = ["published_date","membername"]

Solution

  • The first two warnings are because Django cannot find the model 'User' that you refer to in the memberid foreign key.

    I recommend you use settings.AUTH_USER_MODEL to reference the user model. This will work whether or not you have a custom user model.

    memberid = models.ForeignKey(settings.AUTH_USER_MODEL)
    

    See the docs for more info on referencing the user model.

    Note that it would be better to call name your field member. That way, the related instance will be member and the related id will be member_id. At the moment, the related instance is memberid, and the related id is memberid_id.

    The final warning is because you do not have a field IntegerField in the model. If you want the receitcode field to be unique by itself, then remove the unique_together line and change the field to:

    receitcode = models.CharField(max_length=45, unique=True)