0

This class is for the doctor info

class doc_info(models.Model):
    doc_name = models.TextField()
    speciality = models.TextField()
    exp = models.TextField()
    contact = models.TextField()
    def __str__(self):
        return self.doc_name

This class is for user information

class usr_info(models.Model):
    age = models.TextField()
    blood_group = models.TextField()
    height = models.TextField()
    weight = models.TextField()

    vision = models.TextField()
    address = models.TextField()
    note = models.TextField()
    last_updated = models.DateTimeField(auto_now = True)
    name = models.ForeignKey(User ,on_delete = models.CASCADE)

Here I am trying to add multiple docs to user_info

    recent_doc = models.ManyToManyField(doc_info)

    def __str__(self):
        return self.recent_doc

I am getting SyntaxError: positional argument follows keyword argument

Amit Vyas
  • 31
  • 1
  • 1
  • 5
  • ValueError: Cannot add "": instance is on database "None", value is on database "default" This shows up whenever I try to add – Amit Vyas Aug 09 '20 at 13:49
  • Start by fixing class name it should start with Uppercase character, and make it in Kamel World format – ahmed barbouche Aug 09 '20 at 13:50
  • When you are getting this error? Is this error occurs during `makemigrations` command? – Mubashar Javed Aug 09 '20 at 15:28
  • As mentioned by @ahmedbarbouche make sure to make your class name CamelCase. And make sure to run `python manage.py makemigrations` and then `python manage.py migrate` commands. – Mubashar Javed Aug 09 '20 at 15:34
  • @ahmedbarbouche ok will do that and check and get back to you but can you tell me why camecasing? is that mandatory in Django? – Amit Vyas Aug 09 '20 at 19:19
  • @Mubasharjaved no problem is there in makemigrations and migrate it is coming when I try to run query and in that when I try to add doc_name in usr_info. – Amit Vyas Aug 09 '20 at 19:21
  • https://stackoverflow.com/questions/385895/django-model-naming-convention – ahmed barbouche Aug 09 '20 at 21:43

0 Answers0