सबसे पहले, आपको समझना चाहिए कि store additional information about users कैसे करें। इसके लिए एक और मॉडल की आवश्यकता है जिसका एक उपयोगकर्ता, "प्रोफाइल" मॉडल से संबंध हो।
उसके बाद, आप एक M2M क्षेत्र इस्तेमाल कर सकते हैं, यह मानते हुए आप django-annoying का उपयोग करेंगे, आप इस तरह के रूप में अपने उपयोगकर्ता प्रोफ़ाइल मॉडल निर्धारित कर सकते हैं:
from django.db import models
from annoying.fields import AutoOneToOneField
class UserProfile(models.Model):
user = AutoOneToOneField('auth.user')
follows = models.ManyToManyField('UserProfile', related_name='followed_by')
def __unicode__(self):
return self.user.username
और इस तरह के रूप में इसका इस्तेमाल:
In [1]: tim, c = User.objects.get_or_create(username='tim')
In [2]: chris, c = User.objects.get_or_create(username='chris')
In [3]: tim.userprofile.follows.add(chris.userprofile) # chris follows tim
In [4]: tim.userprofile.follows.all() # list of userprofiles of users that tim follows
Out[4]: [<UserProfile: chris>]
In [5]: chris.userprofile.followed_by.all() # list of userprofiles of users that follow chris
Out[5]: [<UserProfile: tim>]
साथ ही, ध्यान दें कि आप django-subscription, django-actstream, django-social (संभवतः उपयोग करने में कठोर) जैसे ऐप्स की जांच/पुन: उपयोग कर सकते हैं ...
वाई हो सकता है कि notifications और activities के लिए django संकुल को देखना चाहें क्योंकि उन्हें सभी को कुछ अनुवर्ती/सदस्यता डेटाबेस डिज़ाइन की आवश्यकता है।
जब तक आप एक विशिष्ट प्रोग्रामिंग से संबंधित प्रश्न मिल गया है, इस बेहतर एक मंच में एक पोस्ट के रूप से अनुकूल है। – patrickn
@patrickn शायद सबसे अधिक हां लेकिन इसे एक प्रश्न के रूप में भी देखा जा सकता है। चूंकि मेरे पास कोई सुराग नहीं है, इसलिए मैं इसके बारे में पूछता हूं। –