django-2.1

Django: TypeError: '<' not supported between instances (model objects)

此生再无相见时 提交于 2019-12-01 09:42:25
问题 I'm trying to migrate my Django project from Python 2.7/Django 1.11 to Python 3.7/Django 2.1. I've found one issue and I want to understand its cause. I have 3 models in my project: class DeviceModel(models.Model): name = models.CharField(max_length=255) pirsh = models.CharField(max_length=255) def __str__(self): return self.name + " - " + self.pirsh class Device(models.Model): created_at = models.DateTimeField(auto_now_add=True) device_model = models.ForeignKey(DeviceModel, on_delete=models

Django cannot import login from django.contrib.auth.views

痴心易碎 提交于 2019-11-27 02:50:25
问题 I try to build a login function for my page. To edit the urls.py as followed, it keeps printing this: cannot import name 'login' from 'django.contrib.auth.views' How could I deal with the problem? from django.contrib.auth.views import login from django.urls import path from . import views app_name = "users" urlpatterns = [ path("login/", login, {"template_name": "users/login.html"}, name="login"), ] 回答1: Since django-1.11, the login , logout , etc. function-based views have been rewritten to