django-users

How To Show User Profile To Everyone By Link! in Django

怎甘沉沦 提交于 2019-12-12 06:59:38
问题 How To Show User Profile To Everyone By Link! in Django I Want To Show User Profile To Everyone for-example if someone type this in browser domain.com/profile/1 Then Our First User Profile Want To Show But it's showing blank It's showing when user login but we need to show to everyone Here is my detail.html {% extends 'base.html' %} {% block body_block %} <h1 class="posttitle">{{user.username}}</h1> {% endblock %} Here is my Views.py def profile_detail(request,pk): model = get_object_or_404

Django ) 'authenticate' with the user model retrieved by the foreign model

╄→гoц情女王★ 提交于 2019-12-12 01:47:45
问题 I'm developing 'email verification' module. First of all, I have a model named 'SNUser' having 'One To One' relationship with the default 'user' model below : class SNUser(models.Model): # Manager objects = SNUserManager() # Auth user = models.OneToOneField(User, unique=True, primary_key=True) I finished sending email containing the unique token for an user. When the link is clicked, I searched the correct SNUser object by the token.(That token is one of the field of SNUser model). So what I

How to add fields to Django User model and show it on registration form with django-registration?

会有一股神秘感。 提交于 2019-12-11 18:20:07
问题 I noticed that the User model that Django provides does not have a Date of Birth Field . I do not want to write my own custom User class just to include this attribute . I am wondering if it is possible in some way to "attach" date of birth to the User model . If not what are the other simple options to make this work. I am also ok to save the contents of User Model to a profile model with additional date of birth information. But would my form has to save both User and profile model which I

django profile creation, set User profile while using multiple profile types

一个人想着一个人 提交于 2019-12-11 06:52:26
问题 I am stuck at user registration, I actually intends to have different profile types. While registration I am unable to set UserProfile while creating a user. I am using UserCreationForm. code in my files are as following. from django.contrib.auth.forms import UserCreationForm from registration.forms import RegistrationForm from django import forms from django.contrib.auth.models import User from accounts.models import UserProfile from django.utils.translation import ugettext_lazy as _ from

Serializing a model which has a foreign key to Django Auth User

╄→尐↘猪︶ㄣ 提交于 2019-12-11 05:42:41
问题 How can one serialize a model which has a foreign key to Django auth user so that a username can be retrieved? This is what I have tried through Tastypie: def dehydrate(self, bundle): posts = Post.objects.annotate(num_poster = Count('likedby')).order_by('-num_poster') specificpost = posts.get(id__exact=bundle.data['id']) likedList = specificpost.likedby.all()[:7] liked_data = serializers.serialize('python', likedList, fields=('user__username', 'userPic'), use_natural_keys=True) liked_actual =

In Django, how do I write a url.py where users/self/ is the same as users/<pk>/, where <pk> is your logged in user pk?

老子叫甜甜 提交于 2019-12-11 05:19:43
问题 I am trying to write a url.py where I have a simple view for users urlpatterns = patterns( 'doors.view', url( r'^users/$' , 'users_list' , name = 'users_list' ), url( r'^users/(?P<pk>\d+)/$', 'users_detail', name = 'users_detail' ), url( r'^users/self/$' , # do some sort of redirect here ), ) The problem with the redirect is I don't know the pk of the logged in user in url.py . In view.py , I would obviously do a @login_required to be able to access users/self/ . Maybe I am doing this wrong

Django rest serializer Breaks when data exists

北城以北 提交于 2019-12-10 19:39:38
问题 I have this model: class MyModel(User): #others fields and this serializer: class MySerializer(serializers.ModelSerializer): class Meta: model = MyModel fields = ('username', 'password', 'some_field') I get data from ajax to make a login and I handle it like this: serializer = MySerializer(data=request.DATA) print(serializer.is_valid()) The problem: When I send any data my serializer works but when my username field , which must be unique as User model describe, matches with one at the

seperate 'admin' interfaces for different user types in django

谁都会走 提交于 2019-12-09 12:59:29
问题 I have recently being trying to create a project which has several levels of user involved. (Just an example of an abbreviated and rough schema) ME (Super User) Client (s) Customer (s) Survey Collections SurveyUser (s) Invitee (s) Surveys Invitee (s) (invitee is a child of both survey and user) Questions Etc I would ideally have: www.example.com/client/ go to a client interface which you had to be a client to access www.example.com/customer/ go to a customer interface which you had to be a

How to delete user in django?

孤者浪人 提交于 2019-12-09 04:25:27
This may sounds a stupid question but I have difficulty deleting users in django using this view: @staff_member_required def del_user(request, username): try: u = User.objects.get(username = username) u.delete() messages.sucess(request, "The user is deleted") except: messages.error(request, "The user not found") return render(request, 'front.html') in urls.py I have url(r'^del_user/(?P<username>[\w|\W.-]+)/$', 'profile.views.del_user'), Instead the user being deleted I get The user not found . What can be wrong here? doniyor You should change your code to: @staff_member_required def del_user

Django - User creation with custom user model results in internal error

南楼画角 提交于 2019-12-08 03:38:01
问题 Ok, I know this is a silly question but I am blocked and I can't figure out what to do. I have searched on google and stackoverflow but did not found any answer : I tried this : Adding custom fields to users in django Django - Create user profile on user creation https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users My model is the following : class UserProfile(models.Model): user = models.OneToOneField(User) quota = models.IntegerField(null = True) def