WebJul 21, 2014 · >>> from django.contrib.contenttypes.models import ContentType >>> ct = ContentType.objects.get (model='user') >>> ct_class = ct.model_class () >>> ct_instance = ct_class () >>> ct_instance.username = 'hellow' >>> ct_instance.save () Share Improve this answer Follow answered Mar 22, 2011 at 2:38 Blair 15.1k 7 46 56 Web179. This should do the trick: SET FOREIGN_KEY_CHECKS=0; DROP TABLE bericht; SET FOREIGN_KEY_CHECKS=1; As others point out, this is almost never what you want, even though it's whats asked in the question. A more safe solution is to delete the tables depending on bericht before deleting bericht.
Django Contenttype - 简书
WebOct 22, 2016 · Django loaddata UNIQUE constraint failed. I'm running python manage.py loaddata 'path/to/mydata.json' with an empty database ( User and UserProfile tables are created but not populated), however, I'm getting the following error: I checked (even after running this command) and the database is not populated at all. WebMay 25, 2014 · 3 Answers Sorted by: 9 You don't need to write additional code. Use TemplateResponseMixin and set content_type attribute to whatever you need: class MyView (TemplateResponseMixin): content_type='application/xml' ... Share Improve this answer Follow answered Nov 5, 2024 at 9:10 Georgy K 245 4 9 mac cosmetics zipper necklace
Django: How to create Content Types and Permissions for …
Web或者在上下文中适当地传递 内容\u obj. 您的 content\u obj.id 的计算结果为 None 您可能希望查看该对象是否确实存在。您需要向我们显示您的url.py,并查看“like”的url是否正确配置。 WebDjango升级:关系“django_content type”不存在. django.db.utils.ProgrammingError: relation "django_content_type" does not exist 我检查了数据库,并且存 … WebAug 27, 2024 · 我想将多个值传递给序列化器. #models.py class Attendance(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() attendance_of = GenericForeignKey() day = models.DateField() is_present = models.BooleanField(default=True) remark = … maccosmetics uae