I'm beginner in django, what i'm trying to do is:
I want to build a view for a Staff_User. Inside this view the staff member can select a user (from a list of users) and by clic that lets him get some informations(Specifically check some files uploaded by the selected user)
some of my code :
models.py
from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) birth_date = models.DateField(('Date de Naissance'), null=True, blank=True) phone_number = models.IntegerField(('N° de Téléphone'), null=True, blank=True) profile_completed = models.BooleanField(('Profile completé'), default=False) #DOCUMENTS TO UPLOAD id_card = models.FileField(('Carte Nationale d\'Identité'), upload_to='documents/CNI') drive_licence = models.FileField(('Permis de conduire'), upload_to='documents/PERMIS_CONDUIRE') police_record = models.FileField(('Casier judiciaire'), upload_to='documents/CASIER_JUDICIAIRE') carte_vitale = models.FileField(('Carte vitale'), upload_to='documents/CARTE_VITALE') medical_visit = models.FileField(('Visite médicale'), upload_to='documents/MEDICAL_VISIT') rib = models.FileField(('Relevé d\'Identité Bancaire (RIB)'), upload_to='documents/RIB') uploaded_at = models.DateTimeField(('Ajouté le'), auto_now_add=True) docs_are_checked = models.BooleanField(('documents verifés'), default=False) def __str__(self): return self.user.username @receiver(post_save, sender=User) def update_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) instance.profile.save()
App/urls.py
from django.conf.urls import url, include from django.contrib.auth import views as auth_views from . import views as core_views urlpatterns = [ url(r'^accounts/login/$', auth_views.login, {'template_name': 'login.html'}, name='login'), url(r'^accounts/logout/$', auth_views.logout, {'next_page': 'login'}, name='logout'), url(r'^accounts/signup/$', core_views.signup, name='signup'), url(r'^account_activation_sent/$', core_views.account_activation_sent, name='account_activation_sent'), url(r'^accounts/activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za- z]{1,13}-[0-9A-Za-z]{1,20})/$', core_views.activate, name='activate'), url(r'^accounts/email_confirmation_done/$', core_views.email_confirmation_done, name='email_confirmation_done'), url(r'^accounts/complete_profile/$', core_views.complete_profile, name='complete_profile'), url(r'^accounts/upload_files/$', core_views.upload_files, name='upload_files'), url(r'^profile/$', core_views.view_profile, name='view_profile'),
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/05ebb2be-3868-43d4-9320-5f7aa1e08075%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment