django-1.8

Django 1.8 ArrayField append & extend

[亡魂溺海] 提交于 2019-12-30 03:51:04
问题 Django 1.8 will come with new advanced field types including ArrayField these rely on PostgreSQL and are implemented at a DB level. PostgreSQL's array field implements an append method. However I can't find any documentation on appending an item to an ArrayField . This would clearly be very useful as it would allow the field to be updated without transferring its entire contents from the db then back to it. Is this possible? If not will it be possible in future? Any pointers to docs I've

Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually

我是研究僧i 提交于 2019-12-28 12:59:45
问题 I am trying to migrate from Django 1.6 to Django 1.8 . I was using South for managing migrations in Django 1.6. I have successfully created new migration files by python manage.py makemigrations . while running python manage.py migrate --fake-initial , I am getting this error Traceback (most recent call last): File "manage.py", line 39, in <module> execute_from_command_line(sys.argv) File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site- packages/django/core/management/__init__.py"

Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually

元气小坏坏 提交于 2019-12-28 12:58:12
问题 I am trying to migrate from Django 1.6 to Django 1.8 . I was using South for managing migrations in Django 1.6. I have successfully created new migration files by python manage.py makemigrations . while running python manage.py migrate --fake-initial , I am getting this error Traceback (most recent call last): File "manage.py", line 39, in <module> execute_from_command_line(sys.argv) File "/home/jonty/.virtualenvs/squadrun/local/lib/python2.7/site- packages/django/core/management/__init__.py"

Django 1.8.4 makemigrations CreateModel changes field's order

坚强是说给别人听的谎言 提交于 2019-12-25 06:39:08
问题 We've just switched to Django 1.8.4 (from 1.6, so first time using migrations), and we've noticed an issue when using the makemigrations command. The issue happens when creating a new model that contains Foreign Keys. The command generates a migration file with the field order changed: it sets all the FKs last, and reorganizes them by alphabetical order. Here's an example : class AnotherRandomModel(models.Model): attr1 = models.FloatField() class AnotherRandomModel2(models.Model): attr1 =

Django templates, including page(s) that injects code into parent block

牧云@^-^@ 提交于 2019-12-24 11:28:52
问题 Is it possible to include a template (with include django template tag) within another template and "inject" some content to the page that includes (parent) through block tag, or something similar? Let's say I have the following file structure within my project: App/ (...) templates/ base.html index.html _include1.html _include2.html _include3.html _include4.html Code for base.html : <!DOCTYPE html> <html> <head lang="en"> (...) </head> <body> <script type="application/javascript"> $(function

Django ORM Left Join With GROUP BY and SUM

我的未来我决定 提交于 2019-12-24 04:16:17
问题 I am using Django 1.8. I have a User model and a UserAction model. A user has a type. UserAction has a time, which indicates how long the action took. They look like this: class User(models.Model): user_type = models.IntegerField() class UserAction: user = models.ForeignKey(User) time = models.IntegerField() Now what I want to do is get ALL users of a certain type along with the sum of the time of their actions.So it would look something like this: {user:1,total_time=5000}, {user:2,total_time

STATIC_ROOT setup in Django 1.8

女生的网名这么多〃 提交于 2019-12-22 01:06:52
问题 I was tried n I can't set-up as per official documents... I am attaching IMG here, pls give me suggestions, Where is the problem.enter image description here Or, give me simple steps for it with dictionary tree structure. Thank you. # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static_root', 'static') STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), # '/var/www/static/',

Selecting specific fields using select_related in Django

落花浮王杯 提交于 2019-12-21 06:50:57
问题 I have two models Article and Blog related using a foreign key. I want to select only blog name while extracting the article. articles = Articles.objects.all().select_related('blog__name') The query generated shows that it selected all the fields from the Blog model. I tried using only() and defer() with select_related but both didn't work out. articles = Articles.objects.all().select_related('blog__name').only('blog__name', 'title', 'create_time') The above query resulted in error: Invalid

Django 1.8 LookupError AUTH_USER_MODEL

六眼飞鱼酱① 提交于 2019-12-21 05:16:06
问题 I'm using a custon user model as such in my app called fowl . When I run syncdb or makemigrations or migrate I get a LookupError . Please help In settings.py I have defined AUTH_USER_MODEL as 'fowl.User' fowl/models.py from django.db import models from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager from django.utils import timezone from django.core.mail import send_mail from django.utils.translation import ugettext_lazy as _ class UserManager

Django app works fine, but getting a TEMPLATE_* warning message

江枫思渺然 提交于 2019-12-20 09:27:27
问题 When I use runserver, it gives this warning message: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DEBUG. Quoth the Django Documentation: "TEMPLATE_DEBUG Deprecated since version 1.8: Set the 'debug' option in the OPTIONS of a DjangoTemplates backend instead." Here is my settings.py with my futile attempts to fix it: DEBUG =