#๐Ÿ”’ Django Migrations Recursion and File Not Found

14 messages ยท Page 1 of 1 (latest)

bronze veldt
#
(.venv) root@app:~/classani# python manage.py makemigrations --verbosity 3
File not found.
File not found.
Migrations for 'master':
  master/migrations/0001_initial.py
    - Create model Default
    - Create model Classroom
    - Create model Organisation
    - Create model User
    - Create model Staff
    - Create model Student
    - Create model Subject
    - Create model ClassSession
    - Create model Assessment
(.venv) root@app:~/classani# python manage.py migrate --verbosity 3
File not found.
File not found.
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, master, sessions
Running pre-migrate handlers for application master
Running pre-migrate handlers for application admin
Running pre-migrate handlers for application auth
Running pre-migrate handlers for application contenttypes
Running pre-migrate handlers for application sessions
Running migrations:
  No migrations to apply.
  Your models in app(s): 'master' have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
Running post-migrate handlers for application master
Running post-migrate handlers for application admin
Running post-migrate handlers for application auth
Running post-migrate handlers for application contenttypes
Running post-migrate handlers for application sessions
(.venv) root@app:~/classani# python manage.py makemigrations --verbosity 3
File not found.
File not found.
Migrations for 'master':
  master/migrations/0002_alter_organisation_org_code_alter_staff_placeholder_and_more.py
    - Alter field org_code on organisation
    - Alter field placeholder on staff
    - Alter field user_code on user
(.venv) root@app:~/classani# python manage.py migrate --verbosity 3
File not found.
File not found.
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, master, sessions
Running pre-migrate handlers for application master
Running pre-migrate handlers for application admin
Running pre-migrate handlers for application auth
Running pre-migrate handlers for application contenttypes
Running pre-migrate handlers for application sessions
Running migrations:
  No migrations to apply.
  Your models in app(s): 'master' have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
Running post-migrate handlers for application master
Running post-migrate handlers for application admin
Running post-migrate handlers for application auth
Running post-migrate handlers for application contenttypes
Running post-migrate handlers for application sessions
(.venv) root@app:~/classani# python manage.py makemigrations --verbosity 3
File not found.
File not found.
Migrations for 'master':
  master/migrations/0003_alter_organisation_org_code_alter_staff_placeholder_and_more.py
    - Alter field org_code on organisation
    - Alter field placeholder on staff
    - Alter field user_code on user
(.venv) root@app:~/classani# python manage.py makemigrations --verbosity 3
File not found.
File not found.
Migrations for 'master':
  master/migrations/0004_alter_organisation_org_code_alter_staff_placeholder_and_more.py
    - Alter field org_code on organisation
    - Alter field placeholder on staff
    - Alter field user_code on user
(.venv) root@app:~/classani# python manage.py makemigrations --verbosity 3
File not found.
File not found.
Migrations for 'master':
  master/migrations/0005_alter_organisation_org_code_alter_staff_placeholder_and_more.py
    - Alter field org_code on organisation
    - Alter field placeholder on staff
    - Alter field user_code on user
(.venv) root@app:~/classani#

it keeps saying it needs migrations, and when i make migrations it gives me the same thing every time and refuses to migrate for some reason.
works fine with sqlite on local machine.

swift sinewBOT
#

@bronze veldt

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

bronze veldt
#
# models.py
import random
from django.db import models

class Default(models.Model):
    _default_length = 256
    _default_length_name = 30
    _default_length_short = 12
    _default_length_very_short = 6
    _default_length_medium = 24
    _default_length_long = 32
    _default_length_very_long = 64
    _default_json_str = dict

    _id = models.UUIDField(editable=False)
    _name = models.CharField(max_length=_default_length, default="")
    _verbose = models.CharField(max_length=_default_length, default=_name)
    _properties = models.JSONField(default=_default_json_str)

class Organisation(Default, models.Model):
    org_code = models.CharField(primary_key=True, max_length=Default._default_length_medium,
                                default=str(random.randint(100000,999999)))
    org_abbrv = models.CharField(max_length=Default._default_length_very_short, default="")
    plan = models.CharField(max_length=Default._default_length_medium, choices={
        "TUT": "Tutor Plan",
        "EDU": "Educator Plan",
        "ENT": "Enterprise Plan",
    }, default="TUT")

class User(Default, models.Model):
    first_name = models.CharField(max_length=Default._default_length_long)
    middle_name = models.CharField(max_length=Default._default_length_long, null=True, blank=True)
    last_name = models.CharField(max_length=Default._default_length_long)

    org = models.ForeignKey(Organisation, default=None, on_delete=models.CASCADE)

    date_of_birth = models.DateField()

    user_code = models.CharField(primary_key=True, max_length=Default._default_length_very_short, default="???"+str(random.randint(100,999))) # e.g. BYG (Bob YanG) 000
    user_type = models.CharField(max_length=Default._default_length_medium, choices={
        "NIL": "Not Applicable",
        "STU": "Student",
        "STF": "Staff",
    }, default="NIL")

    auth_passhash = models.CharField(max_length=Default._default_length_very_long)

class Student(User, models.Model):
    year_level = models.IntegerField(default=-1)
     
class Staff(User, models.Model):
    placeholder = models.CharField(max_length=Default._default_length, default=str(random.randint(1000, 9999)))

class Classroom(Default, models.Model):
    longitude = models.FloatField(null=True, blank=True)
    latitude = models.FloatField(null=True, blank=True)
    capacity = models.IntegerField(null=True, blank=True, default=25)

class Subject(Default, models.Model): # a subject can only have ONE teacher (user) object
    subject_code = models.CharField(primary_key=True, unique=True, max_length=8) # e.g. COMP 12 00
    description = models.CharField(max_length=Default._default_length, null=True, blank=True)
    assigned_staff = models.ForeignKey(Staff, on_delete=models.CASCADE)
    students = models.ManyToManyField(Student)
     
class Assessment(Default, models.Model):
    description = models.CharField(max_length=Default._default_length, null=True, blank=True)
    category = models.CharField(max_length=Default._default_length_medium, choices={
        "A": "ASSESSMENT",
        "G": "GENERAL",
        "H": "HOMEWORK",
        "P": "PRACTICE",
        "U": "UNCATEGORISED"
    }, default="UNCATEGORISED")

    students = models.ManyToManyField(Student)
    in_subject = models.ForeignKey(Subject, on_delete=models.CASCADE)

    results_json = models.JSONField(default=Default._default_json_str)
    results_desc_json = models.JSONField(default=Default._default_json_str)

class ClassSession(Default, models.Model):
    in_subject = models.ForeignKey(Subject, on_delete=models.CASCADE)
    in_classroom = models.ForeignKey(Classroom, on_delete=models.CASCADE)
    substitute = models.ForeignKey(Staff, on_delete=models.CASCADE, null=True, blank=True)
    start_time = models.DateTimeField()
    duration = models.IntegerField(default=40)
wild jolt
bronze veldt
#

yes posted there

maiden hound
#

what I'd do: I'd use "git bisect".

If you're not using "git", well, ... ๐Ÿคท

bronze veldt
#

well i am using git but this is the first pull on the prod server

#

so there is no good commit to reference to in the first place

maiden hound
#

I guess simplify it one bit at a time until it works ๐Ÿ˜

bronze veldt
#

issue resolved

#

something was wrong with how i defined the abstract model, i needed to use

class Meta:
   abstract=True
``` in the default model
swift sinewBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Django Migrations Recursion and File Not Found