django-models

Detailview Object Relations

邮差的信 提交于 2020-05-30 07:29:26
问题 ;TLDR - After some solutions discovered, my final question is how can I, if at all, access models related to models related to the main detailview model? I'm trying to use a generic detailview to return an object and it's related object. In this example, a company like mcdonalds would have any sites (or locations). What I want the detailview to be able to show is the company detail, and the site detail related to the company. I'm stuck though. Dispite my efforts in not asking for help, I have

Detailview Object Relations

懵懂的女人 提交于 2020-05-30 07:29:14
问题 ;TLDR - After some solutions discovered, my final question is how can I, if at all, access models related to models related to the main detailview model? I'm trying to use a generic detailview to return an object and it's related object. In this example, a company like mcdonalds would have any sites (or locations). What I want the detailview to be able to show is the company detail, and the site detail related to the company. I'm stuck though. Dispite my efforts in not asking for help, I have

TypeError: on_delete must be callable

*爱你&永不变心* 提交于 2020-05-29 05:27:26
问题 Suddenly I am getting an error saying TypeError: on_delete must be callable. I don't know how to solve this error as I don't see field=models.ForeignKey(default=1, on_delete='CASCADE', to='main.Category'), mentioned anywhere in my code. File "/home/arch/myproject/main/migrations/0014_auto_20191025_1154.py", line 6, in <module> class Migration(migrations.Migration): File "/home/arch/myproject/main/migrations/0014_auto_20191025_1154.py", line 47, in Migration field=models.ForeignKey(default=1,

Django makemigrations AttributeError: 'str' object has no attribute '_meta'

梦想的初衷 提交于 2020-05-28 18:12:10
问题 I was playing with the django framework and I ran into an issue running the makemigration command. Here is a copy of the model and the stack trace it produces. I have seen a couple of posts with the same error but none has led me to resolve my problem here. I am working with django 1.9.4 from django.db import models import os, uuid # Create your models here. def video_directory_path(instance, folder): return os.path.join('video', str(instance.person.id), str(instance.video_id)) def photo

Problem with Django app unit tests under Visual Studio Code

自古美人都是妖i 提交于 2020-05-27 15:57:01
问题 I have a draft of the Django project with the added one application (e.g. my_app). In this app I have places tests.py file with one test: import unittest class Test_MyModel(unittest.TestCase): def test_dummy(self): self.assertEqual(1,1) In this case, this dummy test is discoverd by Visual Studio Code and could be executed in it, also it's possible to launch this test from command line: python manage.py test When I modify my file with unit test add import some model (placed in file models.py)

Problem with Django app unit tests under Visual Studio Code

血红的双手。 提交于 2020-05-27 15:56:07
问题 I have a draft of the Django project with the added one application (e.g. my_app). In this app I have places tests.py file with one test: import unittest class Test_MyModel(unittest.TestCase): def test_dummy(self): self.assertEqual(1,1) In this case, this dummy test is discoverd by Visual Studio Code and could be executed in it, also it's possible to launch this test from command line: python manage.py test When I modify my file with unit test add import some model (placed in file models.py)

Problem with Django app unit tests under Visual Studio Code

走远了吗. 提交于 2020-05-27 15:54:25
问题 I have a draft of the Django project with the added one application (e.g. my_app). In this app I have places tests.py file with one test: import unittest class Test_MyModel(unittest.TestCase): def test_dummy(self): self.assertEqual(1,1) In this case, this dummy test is discoverd by Visual Studio Code and could be executed in it, also it's possible to launch this test from command line: python manage.py test When I modify my file with unit test add import some model (placed in file models.py)

Problem with Django app unit tests under Visual Studio Code

早过忘川 提交于 2020-05-27 15:53:29
问题 I have a draft of the Django project with the added one application (e.g. my_app). In this app I have places tests.py file with one test: import unittest class Test_MyModel(unittest.TestCase): def test_dummy(self): self.assertEqual(1,1) In this case, this dummy test is discoverd by Visual Studio Code and could be executed in it, also it's possible to launch this test from command line: python manage.py test When I modify my file with unit test add import some model (placed in file models.py)

Problem with Django app unit tests under Visual Studio Code

為{幸葍}努か 提交于 2020-05-27 15:53:23
问题 I have a draft of the Django project with the added one application (e.g. my_app). In this app I have places tests.py file with one test: import unittest class Test_MyModel(unittest.TestCase): def test_dummy(self): self.assertEqual(1,1) In this case, this dummy test is discoverd by Visual Studio Code and could be executed in it, also it's possible to launch this test from command line: python manage.py test When I modify my file with unit test add import some model (placed in file models.py)

Problem with Django app unit tests under Visual Studio Code

穿精又带淫゛_ 提交于 2020-05-27 15:53:21
问题 I have a draft of the Django project with the added one application (e.g. my_app). In this app I have places tests.py file with one test: import unittest class Test_MyModel(unittest.TestCase): def test_dummy(self): self.assertEqual(1,1) In this case, this dummy test is discoverd by Visual Studio Code and could be executed in it, also it's possible to launch this test from command line: python manage.py test When I modify my file with unit test add import some model (placed in file models.py)