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
248
votes
12 answers

ImportError: No module named 'django.core.urlresolvers'

I am working on Django project where I need to create a form for inputs. I tried to import reverse from django.core.urlresolvers. I got an error: line 2, in from django.core.urlresolvers import reverse ImportError: No module named…
viratayya salimath
  • 2,695
  • 2
  • 10
  • 11
132
votes
12 answers

Getting TypeError: __init__() missing 1 required positional argument: 'on_delete' when trying to add parent table after child table with entries

I have two classes in my sqlite database, a parent table named Categorie and the child table called Article. I created first the child table class and addes entries. So first I had this: class Article(models.Model): …
Christian LSANGOLA
  • 2,947
  • 4
  • 22
  • 36
62
votes
2 answers

How to fix " AttributeError at /api/doc 'AutoSchema' object has no attribute 'get_link' " error in Django

We are practicing an example of REST API on the Internet. However, the following error occurred. I tried a way in this link, but the situation hasn't changed. why swagger raises unclear error - Django from django.contrib import admin from…
Tim
  • 637
  • 1
  • 5
  • 9
57
votes
19 answers

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. (django 2.0.1)(Python 3.6)

It's my first time trying to deploy a Django app(django 2.0.1)(Python 3.6) to pythonanywhere, it is a simple portfolio app with no models, no bootstrap. Just Django, HTML, CSS & Javascript. After pulling it from the Github repo onto pythnanywhere…
lime_ajinomoto
  • 910
  • 1
  • 9
  • 9
30
votes
5 answers

How to filter choices in Django2's autocomplete_fields?

In Django 2.0, autocomplete_fields was added, which is great. Without autocomplete_fields, I can change the queryset of a ForeignKeyField using formfield_for_foreignkey. But combining the two together doesn't work - it looks like the list of options…
Oren Shpigel
  • 463
  • 1
  • 4
  • 6
25
votes
3 answers

IntegrityError: null value in column "id" for all models/fields with ForeignKey after postgres restore from dump

I'm running into issues trying to use a heroku postgres datastore from a restore of a local postgres database I have. Using the restored postgres database Django runs as normal. It retrieves all objects and uses their fields, primay key's etc…
taylor
  • 509
  • 1
  • 9
  • 22
23
votes
4 answers

NoReverseMatch with keyword argument uidb64 with Django 2.0

I can't understand why my code doesn't work. Before it worked, but now, when I run the server and test, the code does not work. When the user is registering, I send him activation email, like this: def send_activation_email(serializer, request,…
r2546971
  • 343
  • 1
  • 2
  • 5
20
votes
1 answer

Django 2, python 3.4 cannot decode urlsafe_base64_decode(uidb64)

i am trying to activate a user by email, email works, encoding works, i used an approach from django1.11 which was working successfully. In Django 1.11 the following decodes successfully to 28, where uidb64 =…
Vipin Mohan
  • 1,631
  • 1
  • 12
  • 22
19
votes
11 answers

Django 2.0: sqlite IntegrityError: FOREIGN KEY constraint failed

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",…
nnyby
  • 4,748
  • 10
  • 49
  • 105
15
votes
1 answer

Django - 'WhereNode' object has no attribute 'output_field' error

I am trying to query and annotate some data from my models: class Feed(models.Model): # Feed of content user = models.ForeignKey(User, on_delete=models.CASCADE) class Piece(models.Model): # Piece of content (video or playlist) …
14
votes
2 answers

Dynamically excluding field from Django ModelForm

I want to exclude, programatically, a field in my form. Currently I have this: class RandomForm(BaseForm): def __init__(self, *args, **kwargs): # This doesn't work if kwargs["instance"] is None: self._meta.exclude =…
alexandernst
  • 14,352
  • 22
  • 97
  • 197
13
votes
1 answer

How to pass arguments with slash in Django2 urls

I would like to call a Django URL with an argument containing a forward slash. For example, I would like to call mysite.com/test/ with 'test1/test2'. (e.g. naively, the url would be mysite.com/test/test1/test2) urls.py: urlpatterns = [ …
Henry Henrinson
  • 5,203
  • 7
  • 44
  • 76
12
votes
4 answers

Django 2.0 Populating Database with a Script

I'm trying to populate my Django database with a script so I don't have to enter in the data manually. So far I have the following: from my_app.models import ModelInApp import django django.setup() def add_data(data1, data2): d, created =…
Evan Bloemer
  • 1,051
  • 2
  • 11
  • 31
11
votes
2 answers

"upstream prematurely closed connection while reading response header from upstream" Django, Ubuntu, Nginx, Gunicorn

I deployed a Django website using this tutorial https://jee-appy.blogspot.com/2017/01/deply-django-with-nginx.html The website can be accessed from the internet, www.simplesol.com When I try to make a POST request, it fails and I get a 502 error. …
John Bobst
  • 147
  • 1
  • 1
  • 8
10
votes
4 answers

multiple parameters url pattern django 2.0

I want to pass two parameters in my url pattern but i am getting error no-reverse match i.e 'projects'.While it works fine with only one parameter. here is main urls file- urlpatterns = [ path('admin/', admin.site.urls), …
user9723456
1
2 3
28 29