django-2.0

Django 2.0.7 - Syntax Error while doing Rename Field migration

谁都会走 提交于 2019-12-12 13:43:11
问题 I've got the following Django class: class Contacto(models.Model): responsable_documento = models.CharField(primary_key=True, max_length=40) responsable_tipo_documento = models.CharField(max_length=20) responsable_nombre = models.CharField(max_length=50, blank=True) responsable_apellido = models.CharField(max_length=60, blank=True) responsable_telefono = models.CharField(max_length=20, blank=True) responsable_telefono_particular = models.CharField(max_length=20, blank=True) responable_email

Django 2 email unsubscribe link

一曲冷凌霜 提交于 2019-12-11 15:14:21
问题 I want to add an unsubscribe link in emails being sent to the user. I am unsure on how to achieve it. I want the user to be able to unsubscribe without having to log in. Any suggestions on how to achieve this would be appreciated. Thanks 回答1: I'll assume you know how to send an email with django, and other basic things. For every email you send to them, you have to build the unsubscribe link first, like the following. Note that the following has a url pattern, and a model that takes a uuid

Mock() function gives TypeError in django2

假如想象 提交于 2019-12-11 08:14:10
问题 I'm following this tutorial. When I run test_views.py I have an error that shouldn't be there according the author: TypeError: quote_from_bytes() expected bytes . My views and my test_views are the same like the book, but I'm using django 2.0.6 instead django 1.11 so my url.py change, so maybe here's the problem. Edit: at a second look the problem appears to be in the mock() function. When I use patch('lists.views.List') the Print(list_) in my view gives <MagicMock name='List()' id='79765800'

Is it possible to add 2nd slug to URL path in Django?

拥有回忆 提交于 2019-12-11 06:34:14
问题 I'm using Django version 2.1. I want to create this type of URL Path in my Project: www.example.com/bachelor/germany/university-of-frankfurt/corporate-finance Is it possible to do it in Django? 回答1: Yes, say for example that you have a slug for an Author , and one for a Book , you can define it as: # app/urls.py from django.urls import path from app.views import book_details urlpatterns = [ path('book/<slug: author_slug >/<slug: book_slug >/', book_details), ] Then the view looks like: # app

Is Django-haystack 2.6.1 compatible with Django 2.0?

▼魔方 西西 提交于 2019-12-10 11:53:32
问题 My question is simple (as per title). Is the current Django-haystack compatible with the newest Django 2.0? Is anyone using this combination? The requirements in the docs and at PYPI suggest that it is: https://django-haystack.readthedocs.io/en/master/#requirements https://pypi.python.org/pypi/django-haystack/2.6.1 But the following user faces issues as well as I do when trying to use it with Django 2.0: Django 2.0 haystack whoosh update index, rebuild index throw error The same setup works

Django 2.0 haystack whoosh update index, rebuild index throw error

走远了吗. 提交于 2019-12-10 10:13:06
问题 I am using django 2.0 with haystack+whoosh as a search. I configured as it is said in the documentation. Occurred problem is when i run ./manage.py rebuild_index it shows this error: Traceback (most recent call last): File "./manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line utility.execute() File "/home/zorig/.virtualenvs/ftm/lib

Django modeltranslation - can't get and see original fields

断了今生、忘了曾经 提交于 2019-12-08 11:29:36
问题 I'm trying to use django-modeltranslation in my project. For now, just for Tag model with one field - name . I've created and registered TranslationOptions , then makemigrations and migrate . Now I can't access the original name text. It seems to be replaced with '' (empty string) but it isn't: In [6]: Tag.objects.first() Out[6]: <Tag: > In [7]: Tag.objects.first().name Out[7]: u'' In [8]: Tag.objects.first().__dict__ Out[8]: {'_state': <django.db.models.base.ModelState at 0x7fc96ad41710>,

Python - Create multiple user types and email as the username field in Django 2

浪子不回头ぞ 提交于 2019-12-06 12:23:07
问题 I'm working on a project using Python(3.7) and Django(2.2) in which I have to implement multiple types of users as: Personal Account - below 18 Personal Account - above 18 Parent Account Coach Account Admin along with that, I also need to use email as the username field for login/authentication. The strategy I'm trying to use is to build a custom base model as User inherited from AbstractBaseUser and also created a custom User Manager to make the email as username but it's not working. Here's

Django 2.0 haystack whoosh update index, rebuild index throw error

筅森魡賤 提交于 2019-12-06 03:25:35
I am using django 2.0 with haystack+whoosh as a search. I configured as it is said in the documentation. Occurred problem is when i run ./manage.py rebuild_index it shows this error: Traceback (most recent call last): File "./manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line utility.execute() File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/django/core/management/__init__.py", line 365, in execute self.fetch_command

Django 2.0: sqlite IntegrityError: FOREIGN KEY constraint failed

跟風遠走 提交于 2019-12-04 22:22:18
问题 I'm working on adding Django 2.0 support to the django-pagetree library. During automated testing, using an sqlite in-memory database, I'm getting a bunch of errors like this: File "/home/nnyby/src/django-pagetree/pagetree/tests/test_models.py", line 638, in setUp 'children': [], File "/home/nnyby/src/django-pagetree/pagetree/models.py", line 586, in add_child_section_from_dict ... File "/home/nnyby/src/django-pagetree/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line