Django ユーザー登録について

187 views
Skip to first unread message

hito koto

unread,
Apr 22, 2014, 4:15:42 AM4/22/14
to django...@googlegroups.com
初めまして、
Django でスタッフの管理ツールを開発しょうと始めたのですが、まったくできないです、誰かが教えてくださいませ!

1,管理人は管理ログインのID/PWで入ってすべてのスタッフの情報を閲覧し管理できる
2,スタッフは管理者が発行してくれたID/PWでログインで入ってスタッフ個人個人のサイトでスタッフ個人個人の情報しか閲覧、管理できないこと

今はスタッフのID/PWで入ってもすべての情報を見てしまう!
なんかわからないです。教えてくださいませ!

上記を作りとしたコード以下です。

こちらはstartprojectのUrls.py:

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns(''
    url(r'^admin/', include(admin.site.urls)),
    url(r'articles/', include("article.urls")),

    url(r'accounts/login/$', "kojin.views.login"),
    url(r'accounts/auth/$', "kojin.views.auth_view"),
    url(r'accounts/logout/$', "kojin.views.logout"),
    url(r'accounts/invalid/$', "kojin.views.invalid_login"),
    url(r'accounts/register/$', "kojin.views.register"),
)

こちらはstartprojectのViews.py:

from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.contrib import auth
from django.core.context_processors import csrf
from django.contrib.auth.forms import UserCreationForm 
from django.shortcuts import render

def login(request):
    c = {}
    c.update(csrf(request))
    return render_to_response("login.html", c)

def auth_view(request):
    username = request.POST.get("username", "")
    password = request.POST.get("password", "")
    user = auth.authenticate(username=username, password=password)

    if user is not None:
        auth.login(request, user)
        return HttpResponseRedirect("/articles/all/")
    else:
        return HttpResponseRedirect("/accounts/invalid")

def loggedin(request):
    return render_to_response("loggedin.html", {'full_name': request.user.username})

def invalid_login(request):
    return render_to_response("invalid_login.html")

def logout(request):
    auth.logout(request)
    return render_to_response("logout.html")


def register(request):
   if request.method == 'GET':
       return render(request, 'register.html', {'form':UserCreationForm()})
   elif request.method == 'POST':
       form = UserCreationForm(request.POST)
       if form.is_valid():
           form.save()
           return render_to_response('register_done.html', {'username':form['username'].value()})
       else:
           return render(request, 'register.html', {'form':form})
   else:
       return HttpResponseForbidden


こちらはstartappのModels.py:

from django.db import models

class Staffr(models.Model):
    user_name = models.CharField(max_length=55, help_text="氏名(名)")
    first_kana = models.CharField(max_length=55, help_text="ふりがな(性)")
    last_kana  = models.CharField(max_length=55, help_text="ふりがな(名)")
    employee_number = models.CharField(blank=True, max_length=22, help_text="社員番号")
    gender = models.CharField(max_length=6, choices=(('male', '男性'),('female', '女性')), help_text="性別" )
    created_at = models.DateTimeField(auto_now_add=True, help_text="登録日")
    updated_at = models.DateTimeField(auto_now=True, help_text="更新日")
    birthday = models.DateField(null=True, blank=True, help_text="生年月日")
    attendance = models.CharField( help_text="出勤" )
    daikin = models.CharField( help_text="退勤" )

    def __unicode__(self):
        return self.user_name

class Address(models.Model):
    user = models.ForeignKey(User)
    postalcode = models.CharField(max_length=8, help_text="郵便番号")
    address = models.CharField(max_length=255, help_text="住所")
    residence = models.CharField(max_length=255, help_text="居住開始日")
    number = models.CharField(max_length=255, help_text="電話番号")
    station = models.CharField(max_length=255, help_text="通勤(最寄駅)")
    nearest_route = models.CharField(max_length=255, help_text="通勤(最寄駅路線)")
    route = models.CharField(max_length=255, help_text="経路")

こちらはstartappのViews.py:
from django.shortcuts import render_to_response
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from tcsarticle.models import Staff
from tcsarticle.models import Employment, Bank, Management
from tcsarticle.models import Address, Contact, Support
from django.core.context_processors import csrf
from forms import ArticleForm
from django.http import HttpResponseRedirect
from django.contrib.auth import authenticate

def staff_datas(request):
    args = {}
    args.update(csrf(request))
    args['staff_datas'] = User.objects.all()
    return render_to_response("staff_datas.html", args)


def staff_data(request, user_id=1):
    user = get_object_or_404(User, pk=user_id)
    return render_to_response("staff_data.html",
                             {"user": User.objects.get(id=user_id) })
def address_datas(request):
    address_list = Address.objects.all()
    return render_to_response("staff_datas.html")

def address_data(request, user_id=1):
    address = Address.object_or_404(Address, pk=user_id)
    return render_to_response("staff_data.html")


def create(request):
    if request.POST:
        form = ArticleForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/ihttest/ihttcs_test/tcsarticles/all')
    else:
        form = ArticleForm()
    args = {}
    args.update(csrf(request))
    args['form'] = form
    return render_to_response('create.html', args)

こちらはstartappのUrls.py:

from django.conf.urls import patterns, include, url

urlpatterns = patterns('',
    url(r'^all/$', "tcsarticle.views.staff_datas"),
    url(r'^get/(?P<user_id>\d+)/$', "article.views.staff_data"),

    url(r'^create/$', "tcsarticle.views.create"),

Lachlan Musicman

unread,
Apr 22, 2014, 8:01:34 AM4/22/14
to django...@googlegroups.com
Hi!

I don't know how many people on this list speak Japanese
unfortunately. I'm not sure if you will get many responses.

I read and speak a little Japanese, but had to use Google translate.

I think you are asking:

I have made a staff database.
Each Staff can login.
Each staff should only see their own page or dataset.

But that isn't what's happened - all staff can see all staff data.

Is that correct?

If so, then you want to restrict access to the view - probably a class
based view?


This is an example that you might be able to use:
http://stackoverflow.com/questions/15181622/django-authenticate-based-on-an-objects-properties-using-class-based-views

Cheers and good luck - let us know if that helps.

L.
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/71db60ba-2372-4a36-8420-ed8d7df66db8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
From this perspective it is natural that anarchism be marked by
spontaneity, differentiation, and experimentation that it be marked by
an expressed affinity with chaos, if chaos is understood to be what
lies outside or beyond the dominant game or system. Because of the
resistance to definition and categorisation, the anarchist principle
has been variously interpreted as, rather than an articulated
position, “a moral attitude, an emotional climate, or even a mood”.
This mood hangs in dramatic tension between utopian hope or dystopian
nihilism...
-----
http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos
Message has been deleted

hito koto

unread,
Apr 22, 2014, 11:52:54 AM4/22/14
to django...@googlegroups.com
thank you very much
>>>Each Staff can login. 
>>>Each staff should only see their own page or dataset. 
This is correct

I want to create administrator page and each staff ,
1, i want , Staff can see the staff page with ID and PW that an administrator has issued
2, administrator can see all the staff page and all staff's information
3, each staff should only see their own page or dataset. 
So, i don't know how to create staff page,only see their own page,

please help me




2014年4月22日火曜日 21時01分34秒 UTC+9 Lachlan Musicman:

Lachlan Musicman

unread,
Apr 22, 2014, 6:03:10 PM4/22/14
to django...@googlegroups.com
On 23 April 2014 01:52, hito koto <hitoko...@gmail.com> wrote:
> thank you very much
>>>>Each Staff can login.
>>>>Each staff should only see their own page or dataset.
> This is correct
>
> I want to create administrator page and each staff ,
> 1, i want , Staff can see the staff page with ID and PW that an
> administrator has issued
> 2, administrator can see all the staff page and all staff's information
> 3, each staff should only see their own page or dataset.
> So, i don't know how to create staff page,only see their own page,
>
> please help me
>


Ok, well first things first. You can do this through the django admin,
but it would be easier if you didn't.

Create a class based DetailView like such:

https://docs.djangoproject.com/en/1.7/topics/class-based-views/

using your Staff model as the base, set up a url schema to deal with
it and then add a mixin as explained in the Stack Overflow post I
linked to.

The administrator/Manager can always see all data through their admin
view, the staff need to login, and they get the restricted view of
their own page.

cheers
L.

hito koto

unread,
Apr 23, 2014, 12:11:15 AM4/23/14
to django...@googlegroups.com
Thank you very much good idea!
i'm was try but i'm have error when create new staff !

>>Request Method: POST
>>Request URL: http://articles/create/
>>Django Version: 1.6.2
>>Exception Type: IntegrityError
>>Exception Value:
(1048, "Column 'user_id' cannot be null")
>>Exception Location: /usr/lib64/python2.6/site-packages/MySQLdb/connections.py in defaulterrorhandler, line 36
>>Python Executable: /usr/bin/python

 >>/var/www/html/article/views.py in create
 >>           form.save()

this is my views.py:

def create(request):
    if request.POST:
        form = ArticleForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/articles/all')
    else:
        form = ArticleForm()
    args = {}
    args.update(csrf(request))
    args['form'] = form
    return render_to_response('create.html', args)



this is my forms.py:
from django import forms
from models import User,Staff, Address
from django.contrib.auth.models import User

class ArticleForm(forms.ModelForm):

    class Meta:
        model = User
        fields = ('user_name','first_kana', 'last_kana', 'employee_number','birthday')
    user_id = forms.CharField(label="id", error_messages={'required': ''}, help_text='必須')
    user_name = forms.CharField(label="氏名", error_messages={'required': ''}, help_text='必須')
    first_kana = forms.CharField(label="ふりがな(性)",error_messages={'required': ''}, help_text='必須')
    last_kana = forms.CharField(label="ふりがな(名)",error_messages={'required': ''}, help_text='必須')
    employee_number = forms.CharField(label="社員番号", required=False)
    birthday = forms.CharField(label="生年月日", required=False)

    class Meta:
        model = Address
        fields = ('user_name','postalcode', 'address', 'residence','number')
    user_name = forms.CharField(label="氏名", error_messages={'required': ''}, help_text='必須')
    postalcode = forms.CharField(label="郵便番号", required=False)
    address = forms.CharField(label="住所", required=False)
    residence = forms.CharField(label="住所開始日", required=False)
    number = forms.CharField(label="電話番号", required=False)

  











2014年4月23日水曜日 7時03分10秒 UTC+9 Lachlan Musicman:

Lachlan Musicman

unread,
Apr 23, 2014, 3:18:44 AM4/23/14
to django...@googlegroups.com
I'm actually racing out the door, but quickly: the id field is automatic. Your form refers to a user_id field that doesn't exist on your model except as implied. In that case, you don't need to ask for user_id in the form. If you want staff to have an ID_number, you should separate it from the id (also known as the pk or primary key) field in the model class, then query it in the form. 

But as it stands, you can remove it from your form, and that should work.

cheers
L.



 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.

hito koto

unread,
Apr 23, 2014, 3:59:13 AM4/23/14
to django...@googlegroups.com
Thank you!
i can do create!

Sorry! i'm don't understand create staff site,
i want to create  staff site , staff site should have when rogin using ID/PW and have staff profile
i'm realy don't know!

pleae help me



2014年4月23日水曜日 16時18分44秒 UTC+9 Lachlan Musicman:

Lachlan Musicman

unread,
Apr 23, 2014, 6:08:05 PM4/23/14
to django...@googlegroups.com
On 23 April 2014 17:59, hito koto <hitoko...@gmail.com> wrote:
Thank you!
i can do create!

Sorry! i'm don't understand create staff site,
i want to create  staff site , staff site should have when rogin using ID/PW and have staff profile
i'm realy don't know!

pleae help me



So you need to create an URL that looks something like:

And you want to redirect to that after login. This question has one example of how to solve that problem:

http://stackoverflow.com/questions/4870619/django-after-login-redirect-user-to-his-custom-page-mysite-com-username

cheers
L.


 

For more options, visit https://groups.google.com/d/optout.

hito koto

unread,
Apr 23, 2014, 9:18:31 PM4/23/14
to django...@googlegroups.com
Ok, Thank you very much!



曜日 7時08分05秒 UTC+9 Lachlan Musicman:

hito koto

unread,
Apr 27, 2014, 10:41:44 PM4/27/14
to django...@googlegroups.com
Hi,
I have this error , why?

Request Method: POST
Request URL: http://articles/attendance/11/
Django Version: 1.6.2
Exception Type: AttributeError
Exception Value:
'function' object has no attribute '_meta'
Exception Location: /usr/lib/python2.6/site-packages/django/forms/models.py in model_to_dict, line 124
Python Executable: /usr/bin/python
Python Version: 2.6.6
Python Path:
['/usr/lib/python2.6/site-packages/pip-1.5.2-py2.6.egg',
 '/usr/lib64/python26.zip',
 '/usr/lib64/python2.6',
 '/usr/lib64/python2.6/plat-linux2',
 '/usr/lib64/python2.6/lib-tk',
 '/usr/lib64/python2.6/lib-old',
 '/usr/lib64/python2.6/lib-dynload',
 '/usr/lib64/python2.6/site-packages',
 '/usr/lib/python2.6/site-packages',
 '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info',
 '/var/www/html/ihttest/ihttcs_test/kojin',
 '/var/www/html/ihttest/ihttcs_test/kojin/static/']
Server time: Mon, 28 Apr 2014 11:19:29 +0900

Traceback Switch to copy-and-paste view

  • /usr/lib/python2.6/site-packages/django/core/handlers/base.py in get_response
    1.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
      ...
  • /var/www/html/article/views.py in attendance
    1.         form = Attendance_dataForm(request.POST, instance = attendance)

this is my Views.py:

def attendance(request, user_id):
    if request.method == "POST":

        form = Attendance_dataForm(request.POST, instance = attendance)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/articles/get/%s' % user.id)
    else:
        form = Attendance_dataForm()

    args = {}
    args.update(csrf(request))
    args['form'] = form
    return render_to_response('staff_data.html', args,  context_instance = RequestContext(request, {'form': form}))
def leave_work(request, user_id):
    if request.method == "POST":
 #       leave_work = Leave_work(user = request.user_id)

        form = Leave_workForm(request.POST, instance = leave_work)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/articles/get/%s' % user.id)
    else:
        form = Leave_workForm()
    c = {}
    c.update(csrf(request))
    c['form'] = form
    return render_to_response('staff_data.html', c,  context_instance = RequestContext(request, { 'form': form}))












2014年4月24日木曜日 7時08分05秒 UTC+9 Lachlan Musicman:

Lachlan Musicman

unread,
Apr 27, 2014, 11:23:49 PM4/27/14
to django...@googlegroups.com
You need to provide more information: like the models, and the copy of the "copy and paste view" output.


cheers
L.



For more options, visit https://groups.google.com/d/optout.



--
The idea of anathematising all of a person’s good works because of something else they said or did is just as alien and repellent to us as our reaction is to someone who wishes Hacker News would die because Paul Graham is kind of a dick sometimes. ... Sergey Bratus points out that keeping works by “ideologically impure” persons out of public view was instrumental to Soviet systems of social control. And as @puellavulnerata acutely observes, a culture that encourages judging people unilaterally, rather than judging their actions in context, is one that allows socially-adept hierarchy climbers to decontextualise their own self-serving cruelties as “necessary for the cause” and stage witchcraft trials against the weirdoes on the margin.
-----------------------------------------------------------------------------------------------------------
https://medium.com/p/31895b01e68c

hito koto

unread,
Apr 28, 2014, 12:43:39 AM4/28/14
to django...@googlegroups.com
Ok, Thank you!

this is my models.py:


from django.db import models
from django.contrib.auth.models import User
#from owner.models import GroupSchedule



class GroupRestrictionMixin(object):
    group_field = 'group'

    def dispatch(request, *args, **kwargs):
        self.request = request
        self.args = args
        self.kwargs = kwargs

        obj_group = getattr(self.get_object(), self.group_field)
        user_groups = request.user.groups

        if obj_group not in user_groups:
            raise PermissionDenied

        return super(GroupRestrictionMixin, self).dispatch(request, *args, **kwargs)


class User(models.Model):
    user_name = models.CharField(max_length=255, help_text="氏名(名)")
    first_kana = models.CharField(max_length=255, help_text="ふりがな(性)")
    last_kana  = models.CharField(max_length=255, help_text="ふりがな(名)")

    employee_number = models.CharField(blank=True, max_length=22, help_text="社員番号")
    gender = models.CharField(max_length=6, choices=(('male', '男性'),('female', '女性')), help_text="性別" )
    created_at = models.DateTimeField(auto_now_add=True, help_text="登録日")
 

class Attendance_data(models.Model):
    user = models.ForeignKey(User)
    user_name = models.CharField(max_length=255, help_text="氏名(名)")

    employee_number = models.CharField(blank=True, max_length=22, help_text="社員番号")

    def __unicode__(self):
        return self.user_name, employee_number

class Leave_work(models.Model):
    user = models.ForeignKey(User)
    user_name = models.CharField(max_length=255, help_text="氏名(名)")

    employee_number = models.CharField(blank=True, max_length=22, help_text="社員番号")

    def __unicode__(self):
        return self.user_name, employee_unmber

this is my Views.py:

def staff_data(request, user_id=1):
    user = get_object_or_404(User, pk=user_id)
    return render_to_response("staff_data.html",
                             {"user": User.objects.get(id=user_id) })

def attendance(request, user_id):
    if request.method == "POST":

        form = Attendance_dataForm(request.POST, instance = attendance)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/articles/get/%s' % user.id)
    else:
        form = Attendance_dataForm()
    args = {}
    args.update(csrf(request))
    args['form'] = form
    return render_to_response('staff_data.html', args,  context_instance = RequestContext(request, {'form': form}))

def leave_work(request, user_id):
    if request.method == "POST":
        form = Leave_workForm(request.POST, instance = leave_work)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/articles/get/%s' % user.id)
    else:
        form = Leave_workForm()
    c = {}
    c.update(csrf(request))
    c['form'] = form
    return render_to_response('staff_data.html', c,  context_instance = RequestContext(request, { 'form': form}))

this is my forms.py:


class ArticleForm(forms.ModelForm):

    class Meta:
        model = User
        fields = ('user_name','first_kana', 'last_kana', 'employee_number','birthday')
    user_name = forms.CharField(label="氏名", error_messages={'required': ''}, help_text='必須')
    first_kana = forms.CharField(label="ふりがな(性)",error_messages={'required': ''}, help_text='必須')
    last_kana = forms.CharField(label="ふりがな(名)",error_messages={'required': ''}, help_text='必須')
    employee_number = forms.CharField(label="社員番号", required=False)
    birthday = forms.CharField(label="生年月日", required=False)

class Attendance_dataForm(forms.ModelForm):

    class Meta:
        model = Attendance_data
        fields = ('user_name','employee_number')


    user_name = forms.CharField(label="氏名", error_messages={'required': ''}, help_text='必須')
    employee_number = forms.CharField(label="社員番号",error_messages={'required': ''}, help_text='必須')

class Leave_workForm(forms.ModelForm):

    class Meta:
        model = Leave_work
        fields = ('user_name', 'employee_number')

    user_name = forms.CharField(label="氏名", error_messages={'required': ''}, help_text='必須')
    employee_number = forms.CharField(label="社員番号", error_messages={'required': ''}, help_text='必須')

and this is my staff_data.html:

<form method="post" action="/articles/attendance/{{ user.id }}/" class=""> {% csrf_token %}
<table>
    <tbody>
        <tr>
        <td style="text-align:center; background-color: transparent; "><button type="submit" name="submit" >ttendance</button> </td>
        </tr>
  </tbody>
</table>
</form>

<form method="POST" action="/articles/leave_work/{{ user.id }}/" class=""> {% csrf_token %}
<table><tr>
<td style="text-align:center; background-color: transparent; "><button type="submit" name="submit" >Leave_work</button></td>
</tr>
</table>
</form>







2014年4月28日月曜日 12時23分49秒 UTC+9 Lachlan Musicman:

Joseph Mutumi

unread,
Apr 28, 2014, 1:41:39 AM4/28/14
to django...@googlegroups.com
Hi there, I think your problem is you have not initialized attendance
that you use at `instance = attendance`. So it is just using the name
of your view function which also happens to be 'attendance' and
showing you that error.

Initialize to model object with the usual:
Attendence_data.objects.get(pk=user_id) or if you are using
djago.shortcuts: get_object_or_404(Attendence_data, pk=user_id)
>> <javascript:>>wrote:
>>
>>> Hi,
>>> I have this error , why?
>>>
>>> Request Method: POST Request URL: http://articles/attendance/11/
>>> Django
>>> Version: 1.6.2 Exception Type: AttributeError Exception Value:
>>>
>>> 'function' object has no attribute '_meta'
>>>
>>> Exception Location:
>>> /usr/lib/python2.6/site-packages/django/forms/models.py
>>> in model_to_dict, line 124 Python Executable: /usr/bin/python Python
>>> Version: 2.6.6 Python Path:
>>>
>>> ['/usr/lib/python2.6/site-packages/pip-1.5.2-py2.6.egg',
>>> '/usr/lib64/python26.zip',
>>> '/usr/lib64/python2.6',
>>> '/usr/lib64/python2.6/plat-linux2',
>>> '/usr/lib64/python2.6/lib-tk',
>>> '/usr/lib64/python2.6/lib-old',
>>> '/usr/lib64/python2.6/lib-dynload',
>>> '/usr/lib64/python2.6/site-packages',
>>> '/usr/lib/python2.6/site-packages',
>>> '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info',
>>> '/var/www/html/ihttest/ihttcs_test/kojin',
>>> '/var/www/html/ihttest/ihttcs_test/kojin/static/']
>>>
>>> Server time: Mon, 28 Apr 2014 11:19:29 +0900 Traceback Switch to
>>> copy-and-paste
>>> view<http://dev1.so2.co.jp/ihttest/ihttcs_test/tcsarticles/attendance/11/#>
>>>
>>>
>>> - /usr/lib/python2.6/site-packages/django/core/handlers/base.py in
>>> get_response
>>> 1.
>>>
>>> response = wrapped_callback(request,
>>> *callback_args, **callback_kwargs)
>>>
>>> ...
>>> ▶ Local
>>> vars<http://dev1.so2.co.jp/ihttest/ihttcs_test/tcsarticles/attendance/11/#>
>>>
>>> - /var/www/html/article/views.py in attendance
>>> 1.
>>>>>>> legroups.com<https://groups.google.com/d/msgid/django-users/a8c07540-4a96-4fb3-b429-19b9feaa5b4b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> From this perspective it is natural that anarchism be marked by
>>>>>> spontaneity, differentiation, and experimentation that it be marked by
>>>>>> an
>>>>>> expressed affinity with chaos, if chaos is understood to be what lies
>>>>>>
>>>>>> outside or beyond the dominant game or system. Because of the
>>>>>> resistance to
>>>>>> definition and categorisation, the anarchist principle has been
>>>>>> variously
>>>>>> interpreted as, rather than an articulated position, “a moral
>>>>>> attitude, an
>>>>>> emotional climate, or even a mood”. This mood hangs in dramatic
>>>>>> tension
>>>>>> between utopian hope or dystopian nihilism...
>>>>>> -----
>>>>>> http://zuihitsu.org/godspeed-you-black-emperor-and-the-polit
>>>>>> ics-of-chaos
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>>
>>>>> an email to django-users...@googlegroups.com.
>>>>> To post to this group, send email to django...@googlegroups.com.
>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>> msgid/django-users/ad53110c-50e3-4010-9861-7909167cb4ab%
>>>>> 40googlegroups.com<https://groups.google.com/d/msgid/django-users/ad53110c-50e3-4010-9861-7909167cb4ab%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> From this perspective it is natural that anarchism be marked by
>>>> spontaneity, differentiation, and experimentation that it be marked by
>>>> an
>>>> expressed affinity with chaos, if chaos is understood to be what lies
>>>> outside or beyond the dominant game or system. Because of the resistance
>>>> to
>>>> definition and categorisation, the anarchist principle has been
>>>> variously
>>>> interpreted as, rather than an articulated position, “a moral attitude,
>>>> an
>>>> emotional climate, or even a mood”. This mood hangs in dramatic tension
>>>>
>>>> between utopian hope or dystopian nihilism...
>>>> -----
>>>> http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos
>>>>
>>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>>
>>> "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>>
>>> email to django-users...@googlegroups.com <javascript:>.
>>> To post to this group, send email to
>>> django...@googlegroups.com<javascript:>
>>> .
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/47eba7b2-fa2c-42c5-bd18-1a55d3f0ad90%40googlegroups.com<https://groups.google.com/d/msgid/django-users/47eba7b2-fa2c-42c5-bd18-1a55d3f0ad90%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> The idea of anathematising all of a person’s good works because of
>> something else they said or did is just as alien and repellent to us as
>> our
>> reaction is to someone who wishes Hacker News would die because Paul
>> Graham
>> is kind of a dick sometimes. ... Sergey Bratus points out that keeping
>> works by “ideologically impure” persons out of public view was
>> instrumental
>> to Soviet systems of social control. And as @puellavulnerata acutely
>> observes, a culture that encourages judging people unilaterally, rather
>> than judging their actions in context, is one that allows socially-adept
>> hierarchy climbers to decontextualise their own self-serving cruelties as
>>
>> “necessary for the cause” and stage witchcraft trials against the weirdoes
>>
>> on the margin.
>>
>> -----------------------------------------------------------------------------------------------------------
>> https://medium.com/p/31895b01e68c
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0e47566a-3e87-46f8-baf8-53db8e1b2b55%40googlegroups.com.

hito koto

unread,
Apr 28, 2014, 2:09:49 AM4/28/14
to django...@googlegroups.com
Hi, Thank you!

I write to Views.py :
def attendance(request, user_id):
    Attendence_data.objects.get(pk=user_id)

    if request.method == "POST":
        form = Attendance_dataForm(request.POST, instance = attendance)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/ihttest/ihttcs_test/tcsarticles/get/%s' % user.id)

    else:
        form = Attendance_dataForm()
    args = {}
    args.update(csrf(request))
    args['form'] = form
    return render_to_response('staff_data.html', args,  context_instance = RequestContext(request, {'form': form}))

But i also have error:

Forbidden (403)

CSRF verification failed. Request aborted.

Help

Reason given for failure:

    CSRF token missing or incorrect.
    

In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django's CSRF mechanism has not been used correctly. For POST forms, you need to ensure:

  • Your browser is accepting cookies.
  • The view function uses RequestContext for the template, instead of Context.
  • In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL.
  • If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data.

You're seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed.

You can customize this page using the CSRF_FAILURE_VIEW setting.





2014年4月28日月曜日 14時41分39秒 UTC+9 jjmutumi:

Lachlan Musicman

unread,
Apr 28, 2014, 9:40:17 AM4/28/14
to django...@googlegroups.com

Lachlan Musicman

unread,
Apr 29, 2014, 3:00:29 AM4/29/14
to django...@googlegroups.com
Hito,

I was a little rough last night. Of course this list is here for
support and help within the Django community. Having said that,
getting a feel for how to ask for support, and to show a little bit of
self help effort goes a long way.

I hope you are now having success?

cheers
L.

hito koto

unread,
Apr 29, 2014, 12:59:32 PM4/29/14
to django...@googlegroups.com
Hi,

I have not been able to yet. so my skill is not enough I still,
I want to be able to going to attendance with the push a button, but I can not,



2014年4月29日火曜日 16時00分29秒 UTC+9 Lachlan Musicman:

hito koto

unread,
May 1, 2014, 12:02:20 AM5/1/14
to django...@googlegroups.com
Hello,

I have this error:  What's happening,
Exception Type: DoesNotExist
Exception Value:
Leavework matching query does not exist.


This is my Models.py

class Leavework(models.Model):
    user = models.ForeignKey(User)
    get_off_work_date = models.DateTimeField(default=datetime.now()+timedelta(days=30))

    def __unicode__(self):
          return unicode(self.id)


This is my Views.py:

def leavework(request):
    if request.POST:
        leavework = Leavework.objects.get(pk = request.user.id )
        form = LeaveworkForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponse('Got off work')
    else:
        form = LeaveworkForm()

    args = {}
    args.update(csrf(request))
    args['form'] = form
    return render_to_response('leave.html', args)







2014年4月29日火曜日 16時00分29秒 UTC+9 Lachlan Musicman:
Hito,

hito koto

unread,
May 1, 2014, 5:33:47 AM5/1/14
to django...@googlegroups.com
Hi,

L was able to solve the problem!



2014年5月1日木曜日 13時02分20秒 UTC+9 hito koto:
...

Lachlan Musicman

unread,
May 1, 2014, 6:22:25 AM5/1/14
to django...@googlegroups.com
Great News! I think you actually solved the problem, I just showed the right documentation :)

L.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages