精华内容
下载资源
问答
  • [10:50:57:236 DVL] Testing cache for: select * from tags where ID IN (select tag_id from global_tags where name LIKE 'boo%%' ESCAPE '^' ) LIMIT 500 [10:50:57:241 DVL] [CACHED ITEMS] ...
  • <div><p>as it is done in #...rollback HLTDQM, in order to make tier0 jobs safe while keeping the plots in the workflows run for the validation (as requested at the Join Opt Meeting 2017.10.20 [1]) [1] ...
  • [ 10%] Creating directories for 'catch' /usr/bin/cmake -E make_directory /home/matthias/dvl/cpp-appveyor/build/catch/src/catch /usr/bin/cmake -E make_directory /home/matthias/dvl/cpp-appveyor/...
  • #10 0x10d819b39 in dvl::mainmenu_init_menu(int) mainmenu.cpp:139 #11 0x10d819a2a in dvl::mainmenu_single_player() mainmenu.cpp:127 #12 0x10d81985f in dvl::mainmenu_loop() mainmenu.cpp:100 #13 0x...
  • [ 10:28:14:258 DVL ] [CACHED ITEMS] select * from tags where path ='std::tr1' LIMIT 1 [ 10:28:14:258 DBG ] Checking DoExtractTemplateInitListFromInheritance... done [ 10:28:14:258 DBG ] ...
  • #10 0x10b18783c in dvl::StartGame(int, int) diablo.cpp:113 #11 0x10b4c1ed1 in dvl::mainmenu_init_menu(int) mainmenu.cpp:145 #12 0x10b4c1dc2 in dvl::mainmenu_single_player() mainmenu.cpp:133 #13 0x...
  • django版本如下: 1 2 3 [root@dvl-stun-001testoms]#python-c"importdjango;printdjango.VERSION" ...(1,10,3,u'final',0) [root@dvl-stun-001testoms]# django默认情况下是有...

    django版本如下:

    1
    2
    3
    [root@dvl-stun-001 testoms]# python -c "import django;print django.VERSION"
    (1, 10, 3, u'final', 0)
    [root@dvl-stun-001 testoms]#

    django默认情况下是有一个登陆界面的,就是当你启动project的时候,在浏览器里输入“外网ip地址/admin“就会看到django默认的登陆界面,如图:

    wKioL1j5Z3LxJneeAABpIXtmo_A575.png


    但是我们还是希望可以做出来一个我们内部用户可以登陆平台的界面,而这篇文章就叫讲述如何达到这个目的。


    http://chenx1242.blog.51cto.com/10430133/1914949  里我已经建立了一个叫testoms的project,里面有两个app分别是app1和app2,并且已经把app1和app2添加到了testoms的settings.py里的INSTALLED_APPS节点,如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
            'app1',
            'app2',
    ]


    然后把MIDDLEWARE里的csrf注释掉:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        #'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
        'debug_toolbar.middleware.DebugToolbarMiddleware',
    ]


    此时testoms/testoms/url.py的内容是初始化的,是这样的:

    1
    2
    3
    4
    5
    from django.conf.urls import url
    from django.contrib import admin
    urlpatterns = [
        url(r'^admin/', admin.site.urls),
    ]


    现在我们在app1里建立一个小数据表,可以用来存放账号的密码,来到testoms/app1里面,#vim models.py,编辑成如下内容:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    from __future__ import unicode_literals
    from django.db import models
    from django.contrib import admin
     
    class User(models.Model):
        username = models.CharField(max_length=50)
        password = models.CharField(max_length=50)
         
    class UserAdmin(admin.ModelAdmin):
        list_display = ('username','password')
     
    admin.site.register(User,UserAdmin)


    看到我们设置了一个叫User的类,里面有两个字段分别是username和password,最大字节数是50,这里设置的比较简单,如果想做的更精密一点,可以添加邮箱或者手机号什么的。


    返回到testoms目录里,#python manage.py migrate 就会看到数据库已经被同步,然后#python manage.py createsuperuser 建立一个超级用户,这样可以登陆到django的后台里。登陆后台之后就会看到app1的菜单栏下面多了一个Users,也就是上面我们设定的那个“类”名:

    wKiom1j5bimgoni8AAAKTSoHpaA712.png


    然后点击add,随便添加一个用户,比如user叫“lidakang",密码是123123:

    wKiom1j5bveA7-l8AAAfluwMAwQ310.png


    点击save保存之后,就会看到效果:

    wKioL1j5cHzC_YiwAAAzfv0PYUE058.png


    可以看到我们已经设定lidakang可以登陆到我们的django里了,也就是说我们的小数据库里多了一条叫lidakang的数据,那么用户信息表已经生成,下面要做的就是用户登陆功能。


    在testoms/app1的views.py里,修改成这样的内容:

    #coding=utf-8
    from django.shortcuts import render,render_to_response
    from django.http import HttpResponseRedirect
    from app1.models import User       #因为在app1下的操作,所以这里要写app1
    from django import forms
    
    #定义表单模型
    class UserForm(forms.Form):
        username = forms.CharField(label='用户名:',max_length=100)
        password = forms.CharField(label='密码:',
        widget=forms.PasswordInput())
    
    #登录
    def login(request):    
          if request.method == 'POST':
            uf = UserForm(request.POST)        
            if uf.is_valid():            
            #获取表单用户密码
                username = uf.cleaned_data['username']
                password = uf.cleaned_data['password']            
                #获取的表单数据与数据库进行比较
                user = User.objects.filter(username__exact = username,password__exact = password)            
                if user:                
                    return render_to_response('success.html',{'username':username})            
                else:                
                    return render_to_response('fail.html',{'username':username})    
         else:
             uf = UserForm()    
         return render_to_response('login.html',{'uf':uf})



    这段代码的意思是,规定通过POST的当时获取到输入的“账号”和“密码”,如果输入的数据与数据库User数据表的字段一致,那么就跳转到success.html界面(同时把username这个字段设定叫‘username’),反之就跳转到fail.html这个页面。


    现在我们就要设定success.html界面以及login.html界面了,在testoms/app1/templates里面,#vim login.html,内容如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    <!DOCTYPE html>
    <html lang="en">
    <head>  
        <meta charset="UTF-8">  
        <title>Login</title>  
      <style type="text/css">
        html{
        width: 100%;
        height: 100%;
        overflow: hidden;
        font-style: sans-serif;
    }
    body{
        width: 100%;
        height: 100%;
        font-family: 'Open Sans',sans-serif;
        margin: 0;
        background-color: #4A374A;
    }
    #login{
        position: absolute;
        top: 50%;
        left:50%;
        margin: -150px 0 0 -150px;
        width: 400px;
        height: 400px;
    }
    #login h1{
        color: #fff;
        text-shadow:0 0 10px;
        letter-spacing: 1px;
        text-align: center;
        width: 430px;
        margin-left: -60px;
    }
    h1{
        font-size: 2em;
        margin: 0.67em 0;
    }
    input{
        width: 278px;
        height: 18px;
        margin-bottom: 10px;
        outline: none;
        padding: 10px;
        font-size: 13px;
        color: #fff;
        text-shadow:1px 1px 1px;
        border-top: 1px solid #312E3D;
        border-left: 1px solid #312E3D;
        border-right: 1px solid #312E3D;
        border-bottom: 1px solid #56536A;
        border-radius: 4px;
        background-color: #2D2D3F;
    }
    .but{
        width: 300px;
        min-height: 20px;
        display: block;
        background-color: #4a77d4;
        border: 1px solid #3762bc;
        color: #fff;
        padding: 9px 14px;
        font-size: 15px;
        line-height: normal;
        border-radius: 5px;
        margin: 0;
    }
     </style>
    </head>
    <body>
     <div id="login">
    <h1>欢迎登陆陈男神的运维平台!</h1>
    <form method = 'post' enctype="multipart/form-data">
        `uf`.`as_p`
        <input type="submit" value = "ok" />
    </form>
     </div>
    </body>
    </html>


    我在这里把html和css写到了一起,所以比较长。保存退出之后,再建立一个叫success.html界面:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title></title>
    </head>
    <body>
        <h1>恭喜`username`,登录成功!</h1>
    </form>
    </body>
    </html>


    一模一样的,再来一个fail.html界面: 

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title></title>
    </head>
    <body>
        <h1>遗憾`username`,登录失败...</h1>
    </form>
    </body>
    </html>


    返回到app1这一层目录,手动建立一个叫urls.py的文件,填写如下内容:

    1
    2
    3
    4
    5
    from django.conf.urls import url
    from app1 import views
    urlpatterns = [
        url(r'^$', views.login, name='login'),
    ]


    保存之后,再返回到testoms/testoms这一层目录,修改urls.py的内容: 

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    from django.conf.urls import url,include
    from django.contrib import admin
    admin.autodiscover()
    from app1 import views as app1_views
    from app2 import views as app2_views
     
    urlpatterns = [
        url(r'^admin/', admin.site.urls),
        #url(r'^$', app1_views.hello,name='hello'),
        url(r'^bye/$', app2_views.bye,name='bye'),
        url(r'^login/', include('app1.urls')),  #在这里用到了刚才在 app1下建立的urls.py文件
    ]


    重新启动django,在浏览器地址栏里输入"外网ip地址/login",就会看到我们的成果: 

    wKiom1j5p9XgfJtrAAEuYm7ze40153.png


     输入我们刚刚建立的lidakang和对应的密码123123,点击 OK之后,就会看到成功的界面: 

    wKioL1j5diHwbkusAAA-dSGu8Sw214.png


    而如果输入的账号名密码不匹配,比如这里我随便输入一个dsada的用户,那么就会出来失败的界面: 

    wKioL1j5sUCwaC2eAAAfOJmV5Vs709.png



     本文转自 苏幕遮618 51CTO博客,原文链接:http://blog.51cto.com/chenx1242/1917985


    展开全文
  • Windows Error: listen EACCES

    2020-12-27 08:13:27
    at Object.statics (C:\dvl\JS\proxy\hoxy\node_modules\hoxy\lib\cycle.js:264:10) at C:\dvl\JS\proxy\hoxy\node_modules\hoxy\node_modules\await\await.js:399:47 at Object. (C:\dvl\JS\proxy\hoxy\node_...
  • , line 10, in <module> execute_from_command_line(sys.argv) File "/home/dvl/.virtualenvs/infobusca/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_...
  • #10 0x0000555555654880 in dvl::DiabloMain (argc=2, argv=0x7fffffffdc58) at /var/tmp/portage/games-engines/devilutionx-1.0.0/work/devilutionX-1.0.0/Source/diablo.cpp:300 #11 0x0000555555629ae2 ...
  • false,,,-domaindir,,,D:\DEVELOPMENT\Software\glassfish4\glassfish\domains,,,AP10DVL -domainname AP10DVL -instancename server -type DAS -verbose false -asadmin-classpath D:/DEVELOPMENT/Software/...
  • 71,10 @@ accept: 'application/json, */*; q=0.01', provided: ['text/html', 'application/json'], selected: ['application/json', 'text/html'] + ...
  • Error at launch on Manjaro

    2021-01-07 15:14:33
    #10 0x55af94d40cd9 in dvl::init_archives() /home/hamdy/Documents/devilutionX/Source/init.cpp:77 #11 0x55af94c08d5e in dvl::diablo_init(char*) /home/hamdy/Documents/devilutionX/Source/diablo.cpp:237 ...
  • Error loading level 8 (osx)

    2021-01-07 15:13:01
    #10 0x1021e0e47 in dvl::mainmenu_loop() mainmenu.cpp:102 #11 0x101ea4f91 in dvl::WinMain(void*, void*, char*, int) diablo.cpp:300 #12 0x101d34df7 in main main.cpp:28 #13 0x7fff734672e4 in start ...
  • Crash on lvl2

    2021-01-07 15:24:46
    #10 0x55b60d375aed in dvl::mainmenu_single_player() /home/glebm/devilutionX/Source/mainmenu.cpp:133 #11 0x55b60d3759a1 in dvl::mainmenu_loop() /home/glebm/devilutionX/Source/mainmenu.cpp:102 #12 0x...
  • #10 dvl::mainmenu_single_player () at /redacted/diasurgical-devilutionX.git/Source/mainmenu.cpp:129 #11 dvl::mainmenu_loop () at /redacted/diasurgical-devilutionX.git/Source/mainmenu.cpp:101 #12 0x566...
  • The ISC DVL service was shut down (isc.org/bind-keys). BIND versions since April 2017 (i.e. 9.9.10, 9.10.5, 9.11.1 and later) include a hard-coded copy of the root KSK which gets updates automatically...
  • No compile

    2020-11-24 23:17:19
    C:\dvl\proyectos\platforms\gatsby-strapi-tutorial\blog>npm -v 6.5.0 <strong>Strapi version</strong>: 3.0.0-alpha.18 <strong>Operating system</strong>: windowa 10 <p><strong>Which example is causing...
  • SUMMARY: AddressSanitizer: FPE /data/diablo/source/devilutionX/SourceX/display.cpp:107 in dvl::SpawnWindow(char const*, int, int) ==3816==ABORTING </code></pre> <p>The error occurs ...
  • :10,"response_raw":"{\"error\":false,\"video_id\":17}","response":{"error":false,"video_id":17}} [30-May-2018 13:26:53 Canada/Central] ...
  • SOC_PART_NUMBER_MCIMX6X3EVK10AB SOC_PART_NUMBER_MCIMX6X3EVK10AC SOC_PART_NUMBER_MCIMX6X1EVO10AB SOC_PART_NUMBER_MCIMX6X1EVO10AC SOC_PART_NUMBER_MCIMX6X3EVO10AB SOC_PART_NUMBER_MCIMX6X3EVO10AC SOC_PART...
  • If I go ahead and install the DVL files on my HLK test machine, the STL test fails, mentioning the "MustFix" failures.</li><li>Storage Firmware Update: I imagine this can be made to pass. ...
  • <div><p>I've made a small sample code which shows that the proxy server (no proxy!) does not allow Selenium-wire to catch traffic when navigating to a new page. <pre><code> #!C:/Python38-32/python...
  • If I run the following code the PropSI function will fail 10 to 20 times: <pre><code> numCalls = 1e5; numCoolPropFailures = 0; for i = 1:1:numCalls %try random temperature between 278....
  • 从stdClass中提取值

    2014-12-25 07:49:54
    string(61) "http://ecx.images-amazon.com/images/I/41-H4eV8dvL._AA160_.jpg" ["price_range/_text"]=> string(15) "$13.99 - $20.99" ["price_range"]=> string(160) ...
  • appears in /data/app/com.something.mayapp-z5KWb0UKVI5dVl540C-t7A==/base.apk:classes5.dex) at epic.mychart.android.library.accountsettings.RegistrationIntentService.RegistrationIntentService....
  • sims/verilator build fails

    2020-12-25 18:41:13
    /home/theodore/dev/clones/chipyard/sims/verilator/generated-src/example.TestHarness.DefaultRocketConfig/SimDTM.cc:3:10: fatal error: fesvr/dtm.h: No such file or directory #include <fesvr> ^~~...
  • 0x30bb200] Successfully created a VDPAU device (G3DVL VDPAU Driver Shared Library version 1.0) on X11 display :0 00:00:23 - SDL Info (0): Driver: G3DVL VDPAU Driver Shared Library version 1.0 00:00:...
  • tag=phone-calls, time:729928 msec, client:172.16.10.131, stage:ExecuteRequestHandler, module:FastCgiModule) REQUEST "6900000180000d81" (url:PUT /.../.../u....php?mac=0090333000af&proc=reset&...

空空如也

空空如也

1 2 3
收藏数 41
精华内容 16
关键字:

dvl10