Model security error in shell

12 views
Skip to first unread message

Juan D.

unread,
Aug 7, 2020, 7:47:12 AM8/7/20
to Django users
Hi. This is something that only occurs in the shell environment, not in the web. If I have this model:

class Phone_App(models.Model):
    phone= models.ForeignKey(Phone, on_delete=models.CASCADE)
    app_name = models.ForeignKey(App, on_delete=models.CASCADE)
    downloads = models.IntegerField(default=0, editable=False)
    apk_file = ContentTypeRestrictedFileField(upload_to=get_upload_path,
                                content_types=['application/vnd.android.package-archive', ],
                                max_upload_size=214958080,
                                max_length=500)

I can create apps with None fields:
Phone_App.objects.create(phone=self.r1_v1, app_name=self.app1)

Also, with:
class Phone(models.Model):
    phone_name = models.CharField(max_length=200, null=False, blank=False)
    version = models.CharField(max_length=20, blank=True, null=True)

    class Meta:
            unique_together = ('phone_name', 'version',)

I can create objects using:

Robot.objects.create(version="Version test")

What's wrong? Thx!
Reply all
Reply to author
Forward
0 new messages