Monday, April 30, 2018

Facebook-Like Multiple Accounts for a Django Social Media Website

Hello Django Users Group!

As the title of the topic suggests, I am in the process of creating a Facebook-Like Multiple Account functionality for a Django Social Media Website.
With Facebook-Like, I mean that users of the Website will have the opportunity to create multiple "Page Accounts" to interact with the Website.
The idea is to fix the actual system and integrate a way to allow users to switch to one page or another that they have created from a drop down menu "Facebook style".
A bit of help in design choices would be extremely useful. I think I can take care of all the code on my own, but some help from more experienced developers in the design part would be extremely, extremely useful.


So far, the User Model is extended using a "Contributor" model, like so:
At the moment it is not possible for the same User Instance to have multiple related accounts, so far a User can create and manage either a 'normal' contributor or a 'page' contributor.

from django.contrib.auth.models import User

class Contributor(models.Model):
    """
    A Contributor Instance Model.
    Contributor is an extension of the User Model, the classical 'profile'
    """

    user = models.ForeignKey(User, related_name="contributor")
  
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES, default='F', verbose_name='sex')
    birthdate = models.DateField(null=True, blank=True, verbose_name='birthdate')
    avatar = ImageField(upload_to='avatars', blank=True, null=True, verbose_name='Profile Photo')
    cover = ImageField(upload_to='copertine', blank=True, null=True, verbose_name='Cover Photo')
    location =  models.CharField(max_length=512, null=True, blank=True, verbose_name=u"City")

    /* a bunch of other attributes */

    is_a_page = models.BooleanField(default=False)
    page_name = models.CharField(max_length=50, null=True, blank=True, unique=True, verbose_name="Page Name")
    kind_of_page = models.CharField(max_length=3, choices=PAGE_CHOICES, default='B', verbose_name='Kind Of Page')


As you can see, a User registering to the Website can now decide whether he/she wants to create a 'normal' contributor account or a contributor 'page' account.

Contrary to real Facebook style pages, there are no substantial differences between what a 'normal' vs 'page' contributor can do.
The model is actually the very same one, the difference in fact is that a bunch of db columns will stay empty depending of what the user chooses. 

Considering that there are of course two distinct registration forms and so that a part of the attributes is hidden depending on the choice, the first idea to allow multiple accounts for the same user was to just add two boolean flags to the model:
1) default_contributor    # set to true if this is the first contributor instance that has been created for a specific User Instance.
2) is_active                   # set to true only if this is the account that the user is deciding to use for that specific session.

default_contributor = models.BooleanField(default=False) # first created contributor
is_currently_active = models.BooleanField(default=False) # which contributor is beign used currently by the user





The problem is that it is now vital to allow a user to create MULTIPLE 'page' contributor accounts, and then switch from one to the other from a drop down menu.
Most importantly: We all know deep in our hearts that that specific Contributor model  is flawed by design, and should be fixed before it is too late.

So, now that the Social Media Website is still in it's very first alpha stages, I still have the opportunity to make things a better.

The idea coming to 

--
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/daaed7fd-2d99-4db0-838c-937a8d11b990%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment