django-1.9

RuntimeError: populate() isn't reentrant on CentOS 7 | django 1.9 | python3

你。 提交于 2019-12-11 03:18:00
问题 Im deploying a django application on a intranet environment. I've already set up a testing server and everything is fine (after breaking my head fixing errors). This time, im seting up the production server and after configuring everything, i got an error 500, here is the httpd/logs/error_log : traceback [Thu Oct 27 09:44:15.480662 2016] [:error] [pid 15250] [remote 10.105.40.106:200] mod_wsgi (pid=15250): Target WSGI script '/home/rortega/smce/smce/wsgi.py' cannot be loaded as Python module.

foreign key as initial value not passed to the ModelForm in django

為{幸葍}努か 提交于 2019-12-10 22:57:11
问题 I need to pass the value (based on category_id) for a ForeignKey to the ModelForm but it's not working. My field remains "--------" and proper value is not set from the drop-down field. Value for the Category must BE SELECTED and other values must be not hided from user to choice. As the result category value successfuly passed to template but drop-down field Category not set! As I can see other guys solved it via constructor for ModelForm, but I feel there must be native django solution.

django.core.exceptions.ImproperlyConfigured: Enable 'django.contrib.auth.context_processors.auth'

南笙酒味 提交于 2019-12-10 14:48:31
问题 I started a new project and am getting: django.core.exceptions.ImproperlyConfigured: Enable 'django.contrib.auth.context_processors.auth' in your TEMPLATES setting in order to use the admin application. I followed the django docs for 1.9: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, } ] What could be the issue (how does it want me configure)? Thank you 回答1: You need to add it into context

How to calculate distance between two PointField?

狂风中的少年 提交于 2019-12-10 11:08:26
问题 I use Postgis with Django to store geographic points. I have a model like the following: from django.contrib.gis.db import models class Event(models.Model) position = models.PointField() I have two events(ev1, ev2). Here is the position value of each: SRID=4326;POINT (-73.6335140000000052 45.5472019999999986) SRID=4326;POINT (-73.6267909999999972 45.5459189999999978) My goal is to get distance in meters between those two points. If i do: ev1.position.distance(ev2.position) I get 0

Use signals in Django 1.9

我与影子孤独终老i 提交于 2019-12-10 10:04:23
问题 In Django 1.8, I was able to do the following with my signals, and all was well: __init__.py: from .signals import * signals.py: @receiver(pre_save, sender=Comment) def process_hashtags(sender, instance, **kwargs): html = [] for word in instance.hashtag_field.value_to_string(instance).split(): if word.startswith('#'): word = render_to_string('hashtags/_link.html', {'hashtag': word.lower()[1:]}) html.append(word) instance.hashtag_enabled_text = ' '.join(html) In Django 1.9, I get this error:

AttributeError: 'str' object has no attribute 'regex' django 1.9

喜夏-厌秋 提交于 2019-12-10 02:20:56
问题 I am working with django 1.9 and I am currently coding - in Windows Command Prompt - python manage.py makemigrations and the error: AttributeError: 'str' object has no attribute 'regex' I have tried coding: url(r'^$', 'firstsite.module.views.start', name="home"), url(r'^admin/', include(admin.site.urls)), url(r'^$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login'), url(r'^signup/$', 'exam.views.signup', name='signup'), url(r'^signup/submit/$', 'exam.views

django-registration (1048, “Column 'last_login' cannot be null”)

本秂侑毒 提交于 2019-12-09 18:10:41
问题 I'm trying to use django-registration in my simple project. settings.py # DJANGO REGISTRATION ACCOUNT_ACTIVATION_DAYS = 7 AUTH_USER_EMAIL_UNIQUE = True EMAIL_HOST = 'localhost' EMAIL_PORT = 1025 EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = '' EMAIL_USE_TLS = False DEFAULT_FROM_EMAIL = 'example@gmail.com' urls.py url(r'^accounts/', include('registration.backends.hmac.urls')), Registration template: {% extends "index.html" %} {% block content %} <h1>Registration</h1> <form method="post" action=""

Perform model operations (only once) at server init

谁说我不能喝 提交于 2019-12-08 05:55:21
问题 I have a rather peculiar requirement: The app should be able to display its own uptime as total hours. This means I need to step away from the request-response cycle and update the current timestamp in the relevant model. With this in mind, I followed the instructions given here, putting the code in my app's ready() method in apps.py . The problem, of course, is that I ran into the Apps aren't loaded yet error. How do I work around this? Another approach that comes to mind is do away with

Django-Haystack: 'NoneType' object has no attribute '_default_manager'

六眼飞鱼酱① 提交于 2019-12-07 04:56:22
问题 I am trying to add a haystack search to my base.html to include it globally on my site. It errors though when i submit a search I am getting: Django-Haystack: 'NoneType' object has no attribute '_default_manager' I have added it to INSTALLED_APPS and my urls.py. ./manage.py rebuild_index runs fine. models.py: class Site(models.Model): site_name = models.CharField(max_length=100, blank=False, null=False) site_manager = models.CharField(max_length=100, blank=False, null=False) address_1 =

Perform model operations (only once) at server init

╄→гoц情女王★ 提交于 2019-12-07 02:54:31
I have a rather peculiar requirement: The app should be able to display its own uptime as total hours. This means I need to step away from the request-response cycle and update the current timestamp in the relevant model. With this in mind, I followed the instructions given here , putting the code in my app's ready() method in apps.py . The problem, of course, is that I ran into the Apps aren't loaded yet error. How do I work around this? Another approach that comes to mind is do away with models and write the timestamp to a file, but this is a brittle method that will not scale. What if I