django-1.8

Update to Django 1.8 - AttributeError: django.test.TestCase has no attribute 'cls_atomics'

和自甴很熟 提交于 2019-12-10 00:34:31
问题 I updated a Django 1.7 project to Django 1.8 and now get errors when I run the tests (that are subclasses of django.test.TestCase ). Traceback (most recent call last): File "env\lib\site-packages\django\test\testcases.py", line 962, in tearDownClass cls._rollback_atomics(cls.cls_atomics) AttributeError: type object 'SomeTests' has no attribute 'cls_atomics' If I debug through the test I can step through all lines without problems, but after the last line the exception is thrown. This is an

Django tutorial, Getting: TypeError at /admin/ argument to reversed() must be a sequence

柔情痞子 提交于 2019-12-09 03:36:49
问题 I'm working my way through the django tutorial for version 1.8 and I am getting an error that I am stuck on and can't seem to figure out. I thought I was following the tutorial pretty much to the T. I have the following tree set up: . ├── dj_project │ ├── __init__.py │ ├── __init__.pyc │ ├── settings.py │ ├── settings.pyc │ ├── urls.py │ ├── urls.pyc │ ├── wsgi.py │ └── wsgi.pyc ├── manage.py └── polls ├── admin.py ├── admin.pyc ├── __init__.py ├── __init__.pyc ├── migrations │ ├── 0001

Hourly grouping of rows using Django

别等时光非礼了梦想. 提交于 2019-12-07 23:19:10
问题 I have been trying to group the results of table into Hourly format using DateTimeField . SQL: SELECT strftime('%H', created_on), count(*) FROM users_test GROUP BY strftime('%H', created_on); This query works fine, but the corresponding Django query does not. Django queries I've tried: Test.objects.extra({'hour': 'strftime("%%H", created_on)'}).values('hour').annotate(count=Count('id')) # SELECT (strftime("%H", created_on)) AS "hour", COUNT("users_test"."id") AS "count" FROM "users_test"

Django DurationField default

岁酱吖の 提交于 2019-12-07 16:31:01
问题 I want to pass default value into DurationField from django 1.8. According to documentation it should be datetime.timedelta from datetime import timedelta pause = DurationField(default=timedelta(minutes=20)) But on makemigrations it says: ValueError: Cannot serialize: datetime.timedelta(0, 1200) There are some values Django cannot serialize into migration files. Ok. Maybe we should pass integer? pause = DurationField(default=int(timedelta(minutes=20).total_seconds())) or: pause =

Django 1.8 and MongoDB?

只愿长相守 提交于 2019-12-07 09:11:43
问题 This question is already asked on StackOverflow, The asked questions date back to 2013, Its 2015 now and Django has grown up fast. What is the situation of using mongodb with Django 1.8 as of 2015? Does Django support Monogodb out of the box (with db adapters)? or another distribution like django-nonrel should be used? 回答1: just my thoughts and somewhat subjective and opinionated but I would say it does not work very well. I quickly disbanded the idea of trying to run Django with MongoDB,

Hourly grouping of rows using Django

孤者浪人 提交于 2019-12-06 14:00:17
I have been trying to group the results of table into Hourly format using DateTimeField . SQL: SELECT strftime('%H', created_on), count(*) FROM users_test GROUP BY strftime('%H', created_on); This query works fine, but the corresponding Django query does not. Django queries I've tried: Test.objects.extra({'hour': 'strftime("%%H", created_on)'}).values('hour').annotate(count=Count('id')) # SELECT (strftime("%H", created_on)) AS "hour", COUNT("users_test"."id") AS "count" FROM "users_test" GROUP BY (strftime("%H", created_on)), "users_test"."created_on" ORDER BY "users_test"."created_on" DESC It

How to access model's class level variable in data migration?

荒凉一梦 提交于 2019-12-06 02:38:14
问题 Here is my model. Poll(models.Model): title = models.CharField(max_length=1024) MY_VAR = ['my_class_level_attribute'] # I want to access this Here is my data migration: def my_func(apps, schema_editor): Poll = apps.get_model('my_app', 'Poll') print Poll.MY_VAR class Migration(migrations.Migration): dependencies = [ ('webmerge', '0012_previous_migration'), ] operations = [ migrations.RunPython(my_func) ] The line print Poll.MY_VAR gives an attribute error. I think the issue might is in how get

Django DurationField default

自作多情 提交于 2019-12-05 20:22:16
I want to pass default value into DurationField from django 1.8. According to documentation it should be datetime.timedelta from datetime import timedelta pause = DurationField(default=timedelta(minutes=20)) But on makemigrations it says: ValueError: Cannot serialize: datetime.timedelta(0, 1200) There are some values Django cannot serialize into migration files. Ok. Maybe we should pass integer? pause = DurationField(default=int(timedelta(minutes=20).total_seconds())) or: pause = DurationField(default=20*60) makemigrations runs ok, but on object creation I see: for obj in self.query.objs File

Django 1.8 and MongoDB?

爱⌒轻易说出口 提交于 2019-12-05 13:06:38
This question is already asked on StackOverflow, The asked questions date back to 2013, Its 2015 now and Django has grown up fast. What is the situation of using mongodb with Django 1.8 as of 2015? Does Django support Monogodb out of the box (with db adapters)? or another distribution like django-nonrel should be used? just my thoughts and somewhat subjective and opinionated but I would say it does not work very well. I quickly disbanded the idea of trying to run Django with MongoDB, since it's auth system is heavily reliant upon a relational database to work. There are apparently ways around

Update to Django 1.8 - AttributeError: django.test.TestCase has no attribute 'cls_atomics'

*爱你&永不变心* 提交于 2019-12-04 22:11:36
I updated a Django 1.7 project to Django 1.8 and now get errors when I run the tests (that are subclasses of django.test.TestCase ). Traceback (most recent call last): File "env\lib\site-packages\django\test\testcases.py", line 962, in tearDownClass cls._rollback_atomics(cls.cls_atomics) AttributeError: type object 'SomeTests' has no attribute 'cls_atomics' If I debug through the test I can step through all lines without problems, but after the last line the exception is thrown. This is an example test: import django import unittest from django.test import TestCase import logging import sys