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:
>
>
> On 23 April 2014 14:11, hito koto <[email protected] <javascript:>>wrote:
>
>> 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)
>>
>>
>>
>>
>
> 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.
>
>
>
>  
>
>> 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:
>>
>>> On 23 April 2014 01:52, hito koto <[email protected]> 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. 
>>>
>>>
>>>
>>>
>>>
>>> -- 
>>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<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/a8c07540-4a96-4fb3-b429-19b9feaa5b4b%40googlegroups.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-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 [email protected].
To post to this group, send email to [email protected].
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to