django-1.7

django-timezone-field gets error unicode object has no attribute zone

丶灬走出姿态 提交于 2019-12-13 04:16:52
问题 I was not able to do a migration on one of my model objects that use django-timezone-field in django 1.7 I found a solution here: https://github.com/mfogel/django-timezone-field/issues/12 I installed the forked version of django-time-field which fixed this problem: https://github.com/mfogel/django-timezone-field/issues/12 I now get the error: unicode object has no attribute zone and 'unicode' object has no attribute 'localize' I am calling the field like this: timezone.activate(customer.time

django models choices list

倾然丶 夕夏残阳落幕 提交于 2019-12-13 00:29:22
问题 I am using django 1.7.2 and I have been given some code for a choices list to be placed in a model. Here is the code: YOB_TYPES = Choices(*( ((0, 'select_yob', _(' Select Year of Birth')), (2000, 'to_present', _('2000 to Present'))) + tuple((i, str(i)) for i in xrange(1990, 2000)) + (1, 'unspecified', _('Prefer not to answer'))) ) .... year_of_birth_type = models.PositiveIntegerField(choices=YOB_TYPES, default=YOB_TYPES.select_yob, validators=[MinValueValidator(1)]) .... The above code gives

One url for two different views

守給你的承諾、 提交于 2019-12-12 09:25:56
问题 I'm developing a site that have two types of User, and the project's owners want two different home (templates) after the user is authenticated, so, I tried this: url # home a url(r'^home/$', HomeAView.as_view(), name='home-a'), # home b url(r'^home/$', HomeBView.as_view(), name='home-b'), And some like that at into my log_in view: if user.typeUser == "HA": print('Go to Home A') return redirect(reverse('sesion:home-a')) else: print('Go to Home B') return redirect(reverse('sesion:home-b')) So

What is wrong with my custom model field?

感情迁移 提交于 2019-12-12 04:50:04
问题 I try to implement an image field that you can assign a string to and it will automatically fetch the image from that URL. Reading it afterwards, it will hold the path to the local copy. Therefore, I inherited from Django's ImageField and its descriptor class. import uuid import urllib.request from django.core.files.base import ContentFile from django.db import models from django.db.models.fields.files import ImageFileDescriptor, ImageFieldFile class UrlImageFileDescriptor(ImageFileDescriptor

TypeError at /UserRegis/ __init__() got an unexpected keyword argument 'username'

心不动则不痛 提交于 2019-12-11 13:58:56
问题 The question I meet is that, when I use UserReg.objects.create(), it will report things above. And I really had look up the solution for seaveral hours, but it doesn't work. So I want to know where I am wrong and how can I fixed it ? PS:forgive me poor English,thanks a lot. I'm sorry about it, these code just a part of all codes, and I just post some. my total project is project/ app1/... app2/... other_general(manage.py etc) ======I will post all files======= app1/models.py from django.db

django python - relation does not exist

谁都会走 提交于 2019-12-11 10:11:53
问题 I am running django 1.7 & python 2.7. In my postgressql db, I had some surplus tables. I now believe that the surplus tables were made surplus when I changed the names of many of my tables some time ago, before I upgraded to django 1.7. The surplus table names did not have any data in them. After I checked my migrations and after searching my project for the surplus table names and finding no reference, I deleted/droped the tables. I am able to update existing records and add new records, but

Django 1.7 - Modifying a model's property

空扰寡人 提交于 2019-12-11 09:56:17
问题 Previously in Django 1.6 and earlier versions, I used to do the following to make User 's email attribute unique: class User(AbstractUser): USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['username'] User._meta.get_field_by_name('email')[0]._unique=True I'm migrating to Django 1.7 but this code is raising the following error: django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet. traced all the way back to User._meta.get_field_by_name('email')[0]._unique=True . How should I migrate

Are numerically keyed choices no longer possible in Django 1.7?

ぃ、小莉子 提交于 2019-12-11 02:57:49
问题 I tried to implement this as a choices variable for a model: >>> choices = ( ... (1, 'Primary'), (2, 'Secondary'), (3, 'Tertiary') ... ) But it failed with this quasi-cryptic error: characters.CharacterArcanumLink.priority: (fields.E005) 'choices' must be an iterable containing (actual value, human readable name) tuples. Lets see, choices is an iterable? Check. containing (actual value, human readable name) tuples? Check: The Actual value is an integer, and the 'human readable name' is a

Django tuple checking: TEMPLATE_DIRS should be tuple?

两盒软妹~` 提交于 2019-12-11 02:27:05
问题 I'm trying Django 1.7. This is my TEMPLATE_DIRS setting: TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'templates').replace('\\', '/') ) which is fine for Django 1.6, but doesn't work for Django 1.7. Can someone explains this? Thx!! 回答1: You need a trailing , for it to be a tuple, see below, the last , TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'templates').replace('\\', '/'), ) When there's a single element in the tuple you need to leave a trailing comma at the end

Upgrading to Django 1.7: Getting AppRegistryNotReady for translation infrastructure

你离开我真会死。 提交于 2019-12-11 01:17:11
问题 I'm upgrading from Django 1.6 to 1.7 and when I try to do manage.py runserver I get the following trace: Traceback (most recent call last): File "manage.py", line 9, in <module> execute_from_command_line(sys.argv) File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line utility.execute() File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line