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
3
votes
1 answer

Decode url(r'^(?P[-\w]+)/$') to path() in Django

I need to convert the following regular expression using url() method to path() method. url(r'^(?P[-\w]+)/$') Thanks and regards.
Saloni Kalra
  • 65
  • 1
  • 7
3
votes
1 answer

New Django app initial DB migrations of an existing database

I have an existing database filled with a bunch of data. I want to migrate to Django so I went ahead and created the necessary models with python manage.py inspectdb. I haven't changed anything besides removed the managed = False since I want Django…
mart1n
  • 5,969
  • 5
  • 46
  • 83
3
votes
1 answer

TypeError: metaclass conflict python 3; django 2

I'm learning django 2 and have a problem. I try to inherite some class and have this error: "TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases" This is my code of…
Alexey K
  • 59
  • 5
3
votes
1 answer

Django 2.0: combine path and re_path got NoReverseMatch error

Using path in project's urls.py, and using re_path in app's urls.py, I got the NoReverseMatch error, my project's urls.py: from django.contrib import admin from django.urls import path, include, re_path urlpatterns = [ path('user/',…
zeleven
  • 436
  • 1
  • 6
  • 21
3
votes
1 answer

Django strange SlugField validation, error not raised before clean(), uncleaned data returned

django 2.0 I have a django model, with different slug fields: from django.core.validators import validate_slug class MyModel(models.Model): # with slug field slug_field = models.SlugField(max_length=200) # or charfield with slug…
Guillaume Lebreton
  • 2,586
  • 16
  • 25
3
votes
1 answer

Django modeltranslation - can't get and see original fields

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…
Milano
  • 18,048
  • 37
  • 153
  • 353
3
votes
1 answer

Using distinct on annotations

I am trying to get a distinct list of items. The db has a created field which is datetime and I need it as a date for my query. So I added an annotation. The problem is that distinct won't work on the annotation... distinct_failed_recharges =…
Lee
  • 8,354
  • 14
  • 55
  • 90
2
votes
2 answers

Django: AttributeError: module 'collections' has no attribute 'Iterator'

Using django-admin startproject trydjango gives error: AttributeError: module 'collections' has no attribute 'Iterator' even though I have Django installed and could see a list of commands by doing django-admin. Here is the full error: Traceback…
Honesty' Best
  • 29
  • 1
  • 2
2
votes
1 answer

Override default_manager of third party app (Django)

I am using django-address module (https://pypi.org/project/django-address/) in my project. Now I want to add get_by_natural_key method on the default manager of State model of django-address module. Before Django 1.10 I was able to do it using this…
SHIVAM JINDAL
  • 2,844
  • 1
  • 17
  • 34
2
votes
2 answers

How to edit user profile in django rest framework from two models and save the change

I am trying to create an endpoint to edit both the user model and custom profile model below. models.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) bio = models.TextField(max_length=500) …
2
votes
2 answers

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

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…
Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150
2
votes
1 answer

Django Create New entries corresponding to existing Foreign Key database entries

I have a Table Books which has 100 entries. class Books(models.Model): name = models.CharField(max_length=30) I have another Table Titles which is newly created and has a Foreign Key relation. class Titles(models.Model): book =…
The Doctor
  • 486
  • 1
  • 6
  • 16
2
votes
0 answers

How to replace LocaleRegexURLResolver from django 1.11

I am currently upgrading Django from 1.11 to 2.0 (to 2.2 in the long run). But recently I bumped into a problem which a can't solve for quiet some time. LocaleRegexURLResolver has been removed in 2.0 without any warning and the whole code has been…
Petr Kučera
  • 78
  • 11
2
votes
1 answer

FOREIGN KEY constraint failed because of models.DO_NOTHING

I have this snippet of code for models.py class Provider(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING) provider = models.CharField(max_length=100, unique=True) active =…
Mesh
  • 130
  • 2
  • 11
2
votes
0 answers

Django - how to submit a form from a ListView

I am trying to pass a form to a ListView in django to create a new object Is there any way to do that? (I know how to do that using def in stead of class) Im using django 2.0 , python 3.4 This is the ListView: class CustomerListView(ListView): …