django-1.9

Django upgrade from 1.8 to 1.9 is breaking on model import in init

痞子三分冷 提交于 2020-04-30 06:57:27
问题 I have run into the same problem that @JohnnyQ has commented on here. My __init__.py is referring to multiple imports that in-turn are referring to models and these are required. The code works perfectly fine with django 1.8.x but breaks when Django is upgraded to 1.9.x. I am guessing it to be some class-loading sequence issue. What has changed in 1.9 w.r.t to model imports in apps triggering the AppRegistryNotReady exception? The traceback is here: Traceback (most recent call last): File "

Django upgrade from 1.8 to 1.9 is breaking on model import in init

╄→гoц情女王★ 提交于 2020-04-30 06:57:05
问题 I have run into the same problem that @JohnnyQ has commented on here. My __init__.py is referring to multiple imports that in-turn are referring to models and these are required. The code works perfectly fine with django 1.8.x but breaks when Django is upgraded to 1.9.x. I am guessing it to be some class-loading sequence issue. What has changed in 1.9 w.r.t to model imports in apps triggering the AppRegistryNotReady exception? The traceback is here: Traceback (most recent call last): File "

CSRF verification Failed - Referer is insecure while host is secure

早过忘川 提交于 2020-02-20 08:18:26
问题 I upgraded Django from 1.8 to 1.9. Afterwards, I get this error on my localhost after the Django admin login: Referer checking failed - Referer is insecure while host is secure . Everything works fine in production. Below is a snippet of my settings.py file: SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True 回答1: Those lines in your settings.py file are fine on production because you're using an SSL certificate attached to your

Django 1.9 unittest error for messages but i dont see the error for 1.10.4 and 1.8

寵の児 提交于 2019-12-25 09:35:03
问题 The test fails with the error in Django 1.9 env, but tests run perfectly well in 1.10.4 and 1.8. Can someone throw some light here ! Here is the error add_message raise MessageFailure('You cannot add messages without installing ' MessageFailure: You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware Check https://travis-ci.org/invaana/Hydronium/builds/182190626 for complete errors views.py def contact(request): if request.method == "POST": form =

Group objects by dates

一曲冷凌霜 提交于 2019-12-25 07:58:19
问题 clicks = SellerClick.objects.extra({'date' : "date(timestamp)"}).values('date').annotate(count=Count('timestamp')) The model has a datetime field called timestamp that was are using. I first, convert the datetime field to just a date field. Then the rest is guessing. I need to group by, and then count how many objects are of each date. So the desired result would be a date, then a count, based on how many objects have that date in the timestamp field. 回答1: I prefer to use annotate over extra

Group objects by dates

安稳与你 提交于 2019-12-25 07:58:05
问题 clicks = SellerClick.objects.extra({'date' : "date(timestamp)"}).values('date').annotate(count=Count('timestamp')) The model has a datetime field called timestamp that was are using. I first, convert the datetime field to just a date field. Then the rest is guessing. I need to group by, and then count how many objects are of each date. So the desired result would be a date, then a count, based on how many objects have that date in the timestamp field. 回答1: I prefer to use annotate over extra

page() takes 1 positional argument but 2 were given

北战南征 提交于 2019-12-24 01:44:58
问题 I am trying to design an api for search functionality. Search is based on place name.What i want is localhost:8000/api/v1/rent/search/?format=json&q="california" but i am getting an error which i have attached below { "error_message": "page() takes 1 positional argument but 2 were given", "traceback": "Traceback (most recent call last):\n\n File \"/home/tushant/.virtualenvs/rent/lib/python3.4/site-packages/tastypie/resources.py\", line 211, in wrapper\n response = callback(request, *args, *

extends not working in Django 1.9

我的未来我决定 提交于 2019-12-24 01:25:25
问题 When I add {% extends "X.html" %} to my child templates (the parent being "base.html"), only the parent template is loaded. When I take it away, the child template is loaded. I have another app where I have a seemingly identical inheritance structure, so I'm stumped. Here is "base.html": <!DOCTYPE html> {% load staticfiles %} <html> <head> {% block js %} <script src="{{ STATIC_URL }}js/jquery.1.12.4.min.js"></script> <script src="{{ STATIC_URL }}js/p5.js" {% endblock %} <title>myapp</title> <