我正在使用Django(第1.3版),并忘记了行政用户名称和密码。 如何重新确定两者?
能否让普通用户进入行政管理,然后取消行政地位?
我正在使用Django(第1.3版),并忘记了行政用户名称和密码。 如何重新确定两者?
能否让普通用户进入行政管理,然后取消行政地位?
python manage.py changepassword <user_name>
,见。
python manage.py createsuperuser
will create another superuser, you will be able to log into admin and rememder your username.给予普通用户特权,可使用<代码>python管理。 py shell andtries:
from django.contrib.auth.models import User
user = User.objects.get(username= normaluser )
user.is_superuser = True
user.save()
You may try through console:
python manage.py shell
接着,在壳体中使用文字
from django.contrib.auth.models import User
User.objects.filter(is_superuser=True)
将把所有超级用户列入名单。 1. 如果您从名单上确认用户名称:
usr = User.objects.get(username= your username )
usr.set_password( raw password )
usr.save()
您提出了新的前言:
https://docs.djangoproject.com/en/dev/ref/django-admin/? from=olddocs#django-admin-createsuperuser"createsuperuser
指挥。
In addition to @JamesO answer that states using
python manage.py changepassword [username]
1- while in your project s main directory access the database (I m using sqlite3):
sqlite3 db.sqlite3
www.un.org/Depts/DGACM/index_french.htm 表格
SELECT * FROM auth_user ;
3- look for the user that has is_superuser = 1
, in my case it s admin
screenshot of the command output (I don t have enough rep points)
这是一个很好的问题。
python Manager.py changepassworduser_name
例:
python manage.py changepassword mickey
检索用户名和密码的最佳途径之一是浏览和更新。 用户模式提供了这样做的完美方式。
根基目录,即你“管理.py”档案的所在地是使用你的ole子或其他应用,如Gite。
利用“python管理.py Shell”的指挥将沙尔遣返。
Import the User Model by typing the following command "from django.contrib.auth.models import User"
Get all the users by typing the following command "users = User.objects.all()"
Print a list of the users For Python 2 users use the command "print users" For Python 3 users use the command "print(users)" The first user is usually the admin.
Select the user you wish to change their password e.g.
<代码>用户=用户[0]
密码
user.set_password (0) 姓名_of_the_new_password_for_user_s selected
删除新的密码
<代码>用户。
在使用用户名称和最新密码时开始服务器和标识。
new setup should first run python manage.py createsuperuser
to create user. It seems like there is no default username password to login into admin.
Two ways to do this:
www.un.org/Depts/DGACM/index_french.htm
(env) $ python manage.py changepassword <username>
或(在几个答复的基础上扩大,但为任何扩展用户模式开展工作)使用<<>django-admin ll:
(env) $ python manage.py shell
This should bring up the shell command prompt as follows:
Python 3.7.2 (default, Mar 27 2019, 08:44:46)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>
那么,你们会想:
>>> from django.contrib.auth import get_user_model
>>> User = get_user_model()
>>> user = User.objects.get(username= admin@hug.com )
>>> user.set_password( new password )
>>> user.save()
>>> exit()
N.B. Why have I answered this question with this answer?
Because, as mentioned, User = get_user_model()
will work for your own custom User
models. Using from django.contrib.auth.models import User
then User.objects.get(username= username )
may throw the following error:
AttributeError: Manager isn t available; auth.User has been swapped for users.User
python manage.py changepassword username
你或许也回答了一个定点问题,有零工作人员。 在这种情形下,应负责:
obvioustest=# c [yourdatabasename]
obvioustest=# x
obvioustest=# select * from auth_user;
-[ RECORD 1 ]+-------------
id | 1
is_superuser | f
is_staff | f
...
直接确定:
update auth_user set is_staff= true where id=1;
如果您愿意创建行政管理用户,首先就在<代码>createsuperuser的指挥下建立。 然后修改密码。
如果你忘记你的管理,你需要利用你来创造新的用户。
python manage.py createsuperuser <username>
为改变用户密码,CLI指令changeword
python manage.py changepassword <username>
页: 1
django-admin changepassword <username>
页: 1 Run this code in Django env
from django.contrib.auth.models import User
u = User.objects.get(username= john )
u.set_password( new password )
u.save()
(venv)your_prj $ ./manage.py shell
>>> from customusers.models import CustomUser
>>> CustomUser.objects.filter(is_superuser=True)
>>> user = CustomUser.objects.get(email="somesuper@sys.com")
>>> user.set_password( @NewPwd )
>>> user.save()
>>> exit()
如果你不知道这里产生的用户名称。 如上文所述,你可以接触用户。
python manage.py shell
from django.contrib.auth.models import User
usrs = User.objects.filter(is_superuser=True)
#identify the user
your_user = usrs.filter(username="yourusername")[0]
#youruser = usrs.get(username="yourusername")
#then set the password
However in the event that you created your independent user model. A simple case is when you want to use email as a username instead of the default user name. In which case your user model lives somewhere such as your_accounts_app.models then the above solution wont work. In this case you can instead use the get_user_model method
from django.contrib.auth import get_user_model
super_users = get_user_model().objects.filter(is_superuser=True)
#proceed to get identify your user
# and set their user password
值得注意的另一件事是将用户位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位位。 这至少使我受益。 详细情况是,我设立了另一个<代码>超级用户,如上所述。 然后,我去查阅数据库表auth_user
,并查询该用户名称以确保其is_staff
。 国旗为1
。 这最后使我得以登录在<代码>admin的网站上。
Create a new superuser with the command "python manage.py createsuperuser". Login as the new super user. Click on the users link. Then click on the user you want to delete. click on delete user at the end of the form page.
注: 上述程序将对特定用户进行的活动记录进行修改。
最好的办法只是去找您的终点站和类型。
python manage.py createsuperuser
and insert another password and user name again but u will lost some of your profile that u have created before in most cases.
在你的指挥线上,这种指挥是公正的:
python manage.py changepassword yourusername
use
python manage.py dumpdata
then look at the end you will find the user name
I think,The better way At the command line
python manage.py createsuperuser
If a reset_password
link is needed in the /admin/ website
this is the way to go:
https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#adding-a-password-reset-feature
I installed this instant messenger program called IM+ that keeps your accounts online even when you exit the application (you know... touch: only one app at a time) it accepts push deliveries to ...
I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...
Suppose I am writing a server for a particular network protocol. If I know that the client is running on a Windows machine, is it possible for my server to authenticate the Windows user that owns the ...
The infrastructure team wants to update the authentication protocol to NTLMv2 and Kerberos. Will this affect CRM 4.0 on-premise installation. What would need to be changed in order to use the ...
I m developing an ASP.NET MVC site that utilizes forms authentication for part of the application. During development, I need to be able to give external parties access to a development server hosting ...
If I have a type like: public class Context { public Context() { } public IQueryable<Record> Records { get { if (user == someone) //psuedocode ...
We recently attempted to add ip address validation to our website s login security. So in addition to having a cookie with valid credentials, we checked that your ip address on page request matched ...
While looking into forms authorizing/authentication, I found that it is possible to do role based authorizing by adding an array of roles to a FormsAuthenticationTicket. That way I can write User....