from django.db import models
from django.db.models import Q
from django.contrib.auth.models import User
from django.urls import reverse


class ProjectQuerySet(models.QuerySet):
    def projects_per_user(self, user):
        return self.filter(
            Q(project_owner=user.username)
        )


class Projects(models.Model):
    project_name = models.CharField(max_length=60)
    project_owner = models.CharField(default=User, max_length=60)
    project_created = models.DateTimeField(auto_now_add=True)
    project_description = models.CharField(max_length=255)
    project_level = models.IntegerField(default=0)

    objects = ProjectQuerySet.as_manager()

    def __str__(self):
        return str(self.pk)

[((349, 380), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(60)'}), '(max_length=60)\n', (365, 380), False, 'from django.db import models\n'), ((401, 446), 'django.db.models.CharField', 'models.CharField', ([], {'default': 'User', 'max_length': '(60)'}), '(default=User, max_length=60)\n', (417, 446), False, 'from django.db import models\n'), ((469, 508), 'django.db.models.DateTimeField', 'models.DateTimeField', ([], {'auto_now_add': '(True)'}), '(auto_now_add=True)\n', (489, 508), False, 'from django.db import models\n'), ((535, 567), 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(255)'}), '(max_length=255)\n', (551, 567), False, 'from django.db import models\n'), ((588, 618), 'django.db.models.IntegerField', 'models.IntegerField', ([], {'default': '(0)'}), '(default=0)\n', (607, 618), False, 'from django.db import models\n'), ((257, 287), 'django.db.models.Q', 'Q', ([], {'project_owner': 'user.username'}), '(project_owner=user.username)\n', (258, 287), False, 'from django.db.models import Q\n')]