Questions tagged [django-2.0]

Django 2.0 is a version of the Django framework, released December 2017. Please only use this tag if your question relates specifically to this version.

Django 2.0 requires Python 3.4, 3.5, or 3.6. It is the first version of Django to support only Python 3.

Here are some of the salient features of Django 2.0:

Django 2.0 was released in December 2017 and was supported until April 2019.

423 questions
4
votes
1 answer

Getting 404 not found using path() in Django

I was just checking out django, and was trying a view to list the books by passing id as an argument to the URL books/urls.py. But getting 404 page not found error. I'm not getting whats wrong in the url when I typed this url in the browser: …
Laxmikant
  • 2,046
  • 3
  • 30
  • 44
3
votes
1 answer

Migrating problems when porting Django project to Python 3 and Django 2

I've been porting a Django project to Python 3 and Django 2. I have had to add on_delete to all my models with foreign keys as required in Django 2. Now I have tried to make migrations for those changes have been getting TypeError: __init__()…
Taylor
  • 1,223
  • 1
  • 15
  • 30
3
votes
1 answer

Django ORM: create ranking based on related model count

I have 2 models in my database: Movie and Comment (it has a foreign key pointing to Movie). from django.db import models class Movie(models.Model): title = models.CharField(max_length=120, blank=False, unique=True) class…
umat
  • 607
  • 1
  • 13
  • 25
3
votes
1 answer

django admin move auth models to another section

I'm using Django 2.x I have created a custom user model by extending the AbstractModel in authentication application class User(AbstractUser): pass and updated in settings AUTH_USER_MODEL = 'authentication.User' This has resulted in two…
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
3
votes
1 answer

How to queryset filter with two or more lists?

I want to make a filter with two or more lists, to my model For example: I'm trying to do it like that from django.db.models import Q rq = ['a', 'b', 'c', 'd', 'e'...] transact = Transact.objects.filter( Q(request__in=rq) | Q(area__in=rq)) But…
Alex
  • 615
  • 8
  • 26
3
votes
0 answers

Django __search lookup causes FieldError

I have a database of Pattern objects and I want to get all patterns which has field Pattern.substring contained by sentence: "This sentence has to contain all returned Pattern objects". So it returns for example Pattern objects with these .substring…
Milano
  • 18,048
  • 37
  • 153
  • 353
3
votes
1 answer

Django 2.0.7 how URL app_name works

I'm working on a project built with python 3.4.3 and django 2.0.7 and I'm stuck with URLs files logic. I still haven't figured this error out: "ImportError: No module named 'fields'. Here's what I have: urls.py from django.urls import include,…
Diego Benetti
  • 97
  • 1
  • 8
3
votes
1 answer

Django - View or condition in urls chooses one of two url patterns with regard to whether the parameter has the value or is NONE

There are two models: groups and posts. The post can be of one of two kinds: assigned to the group, and not assigned to the group. The foreign key field in posts model, which assigns the group to the post, is optional. The post, which belongs to a…
Jakub Siwiec
  • 428
  • 4
  • 13
3
votes
3 answers

Django 2.0.7 - Syntax Error while doing Rename Field migration

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 =…
Guido
  • 81
  • 2
  • 9
3
votes
1 answer

Django: How to change default SignUp fields

I am struggling with changing default UserCreationForm - I was able to add one additional field by creating child class: class SignUpForm(UserCreationForm): display_name = forms.CharField(max_length=32, help_text='Your display name') class…
Ch3shire
  • 1,095
  • 2
  • 14
  • 39
3
votes
1 answer

Django - No add button for TabularInline

I'm using Django 2.0.9 and I'm creating a simple TabularInline ModelAdmin, as follows: class AnswerInline(admin.TabularInline): model = Answer This is then used in a ModelAdmin object, like so: inlines = [AnswerInline]. The ModelAdmin is…
John
  • 143
  • 1
  • 11
3
votes
2 answers

Django -- new field: How to set default callable for existing objects

I have a model: class Model(models.Model): price = models.DecimalField(...) There are already Model objects in production database. Now I add price_total field to this model which can't be null. class Model(models.Model): price =…
Milano
  • 18,048
  • 37
  • 153
  • 353
3
votes
1 answer

Make a model field as required on the base of a condition in Django Models

I'm working on a project with Python(3.6) and Django(2.0) in which I need to make a field in child model required on the base of a condition for a field in parent model class. If the service is multiple then the routing and configuration fields will…
Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150
3
votes
0 answers

Django somehow tries to render the wrong template

I am working on a project using Python 3.6 and Django 2.0.5. And I have a template named register_client.html that I would like to use to render a simple page that will register new clients to the Client model. The following is my complete…
Emre Akı
  • 135
  • 11
3
votes
1 answer

Changing a old Django URL to the new paths

So I am making a new site in Django 2.0 and was following this tutorial on making a user registration form with an activation email and my understanding of the new Django 2 is not good enough so was asking what would be the Django 2 equivalent of…
Kareem
  • 569
  • 2
  • 18