Tag Archives: xadmin

How to Solve Django xadmin installation Error [7 Types of Errors]

Error 1: ModuleNotFoundError: No module named ‘django.core.urlresolvers’

1 ModuleNotFoundError: No module named 'django.core.urlresolvers'

Solution: find the wrong file according to the prompt, and change all import django.core.urlresolvers to   import django.urls

import django.core.urlresolvers 

#change to
import django.urls

Error 2: TypeError: __init__() missing 1 required positional argument: ‘on_delete’

TypeError: __init__() missing 1 required positional argument: 'on_delete'

Solution: This is basically an error in models. Foreignkey() in the models file. Add on in parentheses according to the Django document_delete=models.CASCADE

Error 3: typeerror:__init__() takes 1 positional argument but 6 were given

TypeError: __init__() takes 1 positional argument but 6 were given

Solution: hint that the file xadmin\views\dashboard.py, find

 

forms.Field.__init__(self, required, widget, label, initial, help_text,  *args, **kwargs)

change to

forms.Field.__init__(self)

 forms.Field.__init__(self, required, widget, label, initial, help_text,  *args, **kwargs)

#change to
forms.Field.__init__(self)

Error 4: ImportError: cannot import name ‘login’ from ‘django.contrib.auth.views’

ImportError: cannot import name 'login' from 'django.contrib.auth.views'

Solution: The hint is in xadmin\views\website.py”, line 5, in <module>
from django.contrib.auth.views import login

find the location, and then change

from django.contrib.auth.views import login
from django.contrib.auth.views import logout

to

from django.contrib.auth import authenticate, login, logout

from django.contrib.auth.views import login
from django.contrib.auth.views import logout

#change to
from django.contrib.auth import authenticate, login, logout

 

Error 5: ImportError: cannot import name ‘QUERY_TERMS’ from ‘django.db.models.sql.query’

 ImportError: cannot import name 'QUERY_TERMS' from 'django.db.models.sql.query'

Solution: find the location in xadmin\plugins\filters.py”, line 10, in <module>

then change

from django.db.models.sql.query import LOOKUP_SEP, QUERY_TERMS

to

from django.db.models.sql.query import LOOKUP_SEP, Query

from django.db.models.sql.query import LOOKUP_SEP, QUERY_TERMS

#change to
from django.db.models.sql.query import LOOKUP_SEP, Query

Error 6: ImportError: cannot import name ‘password_reset_confirm’ from ‘django.contrib.auth.views’

ImportError: cannot import name 'password_reset_confirm' from 'django.contrib.auth.views'

Solution: in\xadmin\plugins\passwords.py”, line 4, in <module>
Find    from django.contrib.auth.views import password_reset_confirm

 

change to   from django.contrib.auth.views import PasswordResetConfirmView

in line 77, change   return password_reset_confirm

to   return PasswordResetConfirmView

from django.contrib.auth.views import password_reset_confirm
#change to  
from django.contrib.auth.views import PasswordResetConfirmView

#line 77 
return password_reset_confirm
#to  
return PasswordResetConfirmView

Error 7: AttributeError: ‘Settings’ object has no attribute ‘MIDDLEWARE_CLASSES’

AttributeError: 'Settings' object has no attribute 'MIDDLEWARE_CLASSES'

Solution:   in xadmin\plugins\language.py”, line 24, in <module>
if settings.LANGUAGES and ‘django.middleware.locale.LocaleMiddleware’ in settings.MIDDLEWARE_CLASSES:

change to if settings.LANGUAGES and ‘django.middleware.locale.LocaleMiddleware’ in settings.MIDDLEWARE:

 

if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE_CLASSES:
#change to
if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE:

Other errors are modulenotfounderror: no module named, just install the corresponding module according to the prompt. If it is not installed, it may be that the module name is written incorrectly

Solutions to xadmin’s “apps are’t loaded yet” error

Explain the function of static keyword and final keyword in Java in detail>>>

Project environment:
Django 1.9
Python 2.7

Django project introduces xadmin as the background, but configures verb in apps.py under app_ Name, in__ init__. Default is configured in py_ app_ After configuring, the system reported the following error:
django.core.exceptions.appregistrynotready: apps are’t loaded yet.

after a long time of experiment, I found that I was in the verb of apps.py_ Name = u “course” in which the use of Chinese, not added

# -*- coding:utf-8 -*-

Just add this sentence to the beginning of the apps. Py code

[Solved] Search with xadmin_ Related field got invalid lookup: icontains

Add these three fields to the class defined in the adminx.py file
list_display = ['code','email','send_type','send_time'] # the type of fields to display
search_fields = ['code','email','send_type'] # fields to search (all fields together) No fields with foreign keys here
list_filter = ['code','email','send_type','send_time'] # fields searched (single field search) and time

1.Problem description

When using xadmin to realize Django background function, use search_ Fields = [field name, field name], related field got invalid lookup: icons

2.Problem analysis

search_ Fields controls the name of the field that can be searched through the search box_ Fields = () or search_ Fields = [], xadmin uses fuzzy query

The search of related fields is invalid because search_ For example, if the field type is ForeignKey, an error will be reported

3.Solutions

Delete search_ Fields, for example, delete the field type ForeignKey