| Name | skizzy |
|---|---|
| Email Address | n/a |
| Posts | 12 |
-
- 2012-02-19 08:24:51
- Adding Of Users
- Board » General Category » General Discussion
-
Hi guys, I'm trying to make the below script let users follow each other. Just like adding friends up.So that users will be able to follow each other. When I click the 'follow' button in a user profile, instead of it to take me to the users wall, it will only redirect me to the same page(user profile page). and it won't add up the user.
I just try this code, though. Please put me through.
Model:
class followme(models.Model):
user=models.ForeignKey(User)
userprofile=models.ForeignKey(UserProfile)
def __unicode__(self):
return u"%s" % self.user
class FollowForm(ModelForm):
class Meta:
model=followme
exclude=('user','userprofile')
View:
def followm(request):
if request.method=="POST":
form=FollowForm(request.POST)
if form.is_valid():
new_obj=form.save(commit=False)
new_obj.initiated_by=request.user
u=User.objects.get(request.POST['profile_id'])
new_obj.follow=u
new_obj.save()
return HttpResponseRedirect('/homi/')
else:
form=FollowForm()
return render_to_rensponse('follow.html',{'FollowForm':form,},context_instance=RequestContext(request))
Template:
<html>
<body>
<form action="" method="POST" >
<input type="hidden" name="profile_id" value="{{ profile.id }}" />
<input type='submit' name='follow' value='Follow' />
</form>
-
- 2012-02-18 06:14:43
- Getting Friends
- Board » General Category » General Discussion
-
Hello guys, anyone have the idea on how to get started with making users add each other in django site? I've been fighting with this for a long time, but yet no success.
I also tried django packages like, Django-Relationships, Django-follow and Django friends yet none is working! If you've used any of this packages kindly let me know by commenting below. and if you have idea on how to get started with adding users in django, please kindly help out.
Thanks.
-
- 2012-02-09 06:34:28
- Re: Want To Make This Update Work
- Board » General Category » General Discussion
-
Sent! okay no problem. Check your mail. Thanks.
-
- 2012-02-09 05:56:47
- Re: Want To Make This Update Work
- Board » General Category » General Discussion
-
I'm developing in the development area. Localhost. Send me your email address so that I can mail you. Actually, I'm not dealing with profiles, I'm dealing with update of status. You know what bro? Send me your email address, so I will explain what I actually need in MS format to illustrate so that you can grab what I mean. Thanks so much! You're a rare gem

-
- 2012-02-09 05:24:26
- Re: Want To Make This Update Work
- Board » General Category » General Discussion
-
Bro, you really tried! But I'm still getting "Mob User already exist"
What I actually want to do is to let users post status update. I guess you know how we update or status on Facebook? Do you really get my point?
-
- 2012-02-09 05:09:20
- Re: Want To Make This Update Work
- Board » General Category » General Discussion
-
Here:
if mob.objects.filter(user=request.user).count()=0:
-
- 2012-02-09 04:58:56
- Re: Want To Make This Update Work
- Board » General Category » General Discussion
-
I'm getting syntax error:
def homey(request):
#if there's nothing in the field do nothing.
if request. method=="POST":
form =mobForm(request.POST)
if form.is_valid():
data=form.cleaned_data
if mob.objects.filter(user=request.user).count()=0: #here is where the problem is. I tried changing it but still getting syntax error.
newmob=mob(
username=request.user,
state_province=state_province,
body=data['body'],
date=datetime.datetime.now())
newmob.save()
else:
mob.objects.filter(user=request.user).update{
body=data['body']}
return HttpResponseRedirect('/homi/')
else:
return render_to_response('home.html', {'mobForm': form },context_instance=RequestContext(request))
else:
form = mobForm()
return render_to_response('home.html', {'mobForm': form },context_instance=RequestContext(request))
-
- 2012-02-09 04:27:48
- Re: Want To Make This Update Work
- Board » General Category » General Discussion
-
I guess it will work bro. But I'm getting- "Mob with this User already exists" When I input my username in the user fields.
What I really want to do is this, display only the body of the mobForm on the template, so when the user inputs whatever he or she wants to write, it will now display the user's username, the body(what the user wrote) , date and province on the template. below the body mobform. I hope you get my point?
-
- 2012-02-09 04:12:30
- Re: Want To Make This Update Work
- Board » General Category » General Discussion
-
Thanks bro. So no need for me to change the template? I should leave it like this?
<div class="form">
<form action="" method="post" enctype="multipart/form-data">
<table>
{{ mobForm.as_table }}
</table>
<input type="submit" value="Update" />
</form>
-
- 2012-02-09 03:23:09
- Re: Want To Make This Update Work
- Board » General Category » General Discussion
-
Bro, I tested it but I'm getting "UnboundLocalError at /homi/ " local variable 'newmob' referenced before assignment.
Views:
def homey(request):
#if theres nothing in the field
if request.method=="POST":
form=mobForm(request.POST)
if form.is_valid():
data=form.cleaned.data
newmob=mob(
user=request.user,
state_province=None,
body=data['body'],
date=datetime.datetime.now())
newmob.save()
return HttpResponseRedirect('/homi/')
else:
return render_to_response('home.html',{'mobForm':newmob},context_instance=RequestContext(request)) #this is the line that's giving me problem.
else:
newmob=mobForm()
return render_to_response('home.html',{'mobForm':mobForm}, context_instance=RequestContext(request))
What I'm I missing?
If you have another way to solve this, kindly write it and lets try it. I hope you get the problem I want to solve?
Let me expalain again bro. I want users to be able to update their status by entering what they want in the body form only. and after they click on update button, their username, staus['body'], date and state_province should be displayed on the same template.
so that their friends will be able to see it and comment or share if they like. You know how we do update our status on FB? Hope to hear from you soon. Thanks so much!


