caffeinehit / django-follow Goto Github PK
View Code? Open in Web Editor NEWDjango application to follow anything.
Home Page: https://github.com/caffeinehit/django-follow
License: MIT License
Django application to follow anything.
Home Page: https://github.com/caffeinehit/django-follow
License: MIT License
Hi caffeinehit,
After setting up the package, I tried to visit the user profile, and I’m getting this error:
TemplateSyntaxError at /profiles/picomon/
Invalid block tag: 'request.user|is_following:UserProfile', expected 'endblock' or 'endblock content'
Request Method: GET
Request URL: http://127.0.0.1:8000/profiles/picomon/
Django Version: 1.3.1
Exception Type: TemplateSyntaxError
Exception Value: Invalid block tag: 'request.user|is_following:UserProfile', expected 'endblock' or 'endblock content'
Exception Location: C:\Python27\lib\site-packages\django\template\base.py in invalid_block_tag, line 290
Python Executable: C:\Python27\python.exe
Python Version: 2.7.2
In “follow/form.html”
{% load follow_tags %}
<form action="{% follow_url object %}" method="POST">
{% csrf_token %}
{% if request.user|is_following:UserProfile %}
<input type="submit" value="Unfollow" />
{% else %}
<input type="submit" value="Follow" />
{% endif %}
</form>
In User’s profile template:
{% load follow_tags %}
{% follow_url object %}
{% request.user|is_following:UserProfile %}
{% follow_form object %}
{% follow_form object "follow/form.html" %}
I registered this model:
utils.register(UserProfile)
Please help me out!
Hello, I’m not getting the usage of the package in template, because I keep getting error. What I did is this; I want to use it for following of users. Just like how friends add each other up or follow each other on sites like twitter.
So I registered it with UserProfile in models,py.
utils.register(UserProfile)
And UserProfile consists of fields like names, state, country, etc.
After registering it in models, I went on to profiles template and ‘include /follow/form.html’ so that if a user finds another users profile, and both are not following each other, it will be easy for one of them to make the request by following. But I keep getting error.
My question now is this: How will I make use of it in the template? What is the best way of doing this? Hope to hear from you soon. Thanks!
File "/Users/chirdeeptomar/envs/fashio/lib/python3.4/site-packages/follow/utils.py", line 20, in register
field_name = 'target_%s' % model._meta.module_name
AttributeError: 'Options' object has no attribute 'module_name'
Update utils.py register function to model_name instead of module_name
Hello there!
After installing django-follow and syncdb'ing I'm getting the following error:
After a few minutes of debugging I'm not sure what's going on.
It seems that follow.utils.register() correctly adds the foreignkey to the model, but the new field is not created inside the DB.
In the python shell a new instance of models.Follow has a property called "post_id". However, the db table is not created (I verified this inside the db).
My env:
Thanks for the help!
(1054, "Unknown column 'follow_follow.target_user_id' in 'where clause'")
I have checked the latest code from the repo, has anything changed lately?
Should it be in utils.py:
import Follow instead import Follower?
in
def get_followers_for_user
FollowManager.get_follows(model_or_object)
:
Returns all the Follow objects associated with a certain model or object.
FollowManager does not have get_follows as a class method. It would be `FollowManager().get_follows(model_or_object) or even Follow.objects.get_follows(model_or_object).
Its not only this, but quite a lot of the README is incorrect. I think it should also be noted that "follow_url" must be used via POST and not GET.
PS C:\Users\tbroder\workspace\django-follow> python .\setup.py install
running install
running bdist_egg
running egg_info
creating django_follow.egg-info
writing django_follow.egg-info\PKG-INFO
writing top-level names to django_follow.egg-info\top_level.txt
writing dependency_links to django_follow.egg-info\dependency_links.txt
writing django_follow.egg-info\PKG-INFO
writing top-level names to django_follow.egg-info\top_level.txt
writing dependency_links to django_follow.egg-info\dependency_links.txt
writing manifest file 'django_follow.egg-info\SOURCES.txt'
reading manifest file 'django_follow.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
Traceback (most recent call last):
File ".\setup.py", line 17, in
version=follow.version,
File "C:\Python26\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
self.run_command(cmd)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\lib\site-packages\distribute-0.6.10-py2.6.egg\setuptools\command\install.py", line 73, in run
self.do_egg_install()
File "C:\Python26\lib\site-packages\distribute-0.6.10-py2.6.egg\setuptools\command\install.py", line 93, in do_egg_install
self.run_command('bdist_egg')
File "C:\Python26\lib\distutils\cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\lib\site-packages\distribute-0.6.10-py2.6.egg\setuptools\command\bdist_egg.py", line 167, in run
self.run_command("egg_info")
File "C:\Python26\lib\distutils\cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\lib\site-packages\distribute-0.6.10-py2.6.egg\setuptools\command\egg_info.py", line 179, in run
self.find_sources()
File "C:\Python26\lib\site-packages\distribute-0.6.10-py2.6.egg\setuptools\command\egg_info.py", line 254, in find_sources
mm.run()
File "C:\Python26\lib\site-packages\distribute-0.6.10-py2.6.egg\setuptools\command\egg_info.py", line 310, in run
self.read_template()
File "C:\Python26\lib\site-packages\distribute-0.6.10-py2.6.egg\setuptools\command\sdist.py", line 204, in read_template
_sdist.read_template(self)
File "C:\Python26\lib\distutils\command\sdist.py", line 336, in read_template
self.filelist.process_template_line(line)
File "C:\Python26\lib\distutils\filelist.py", line 129, in process_template_line
(action, patterns, dir, dir_pattern) = self._parse_template_line(line)
File "C:\Python26\lib\distutils\filelist.py", line 104, in _parse_template_line
dir = convert_path(words[1])
File "C:\Python26\lib\distutils\util.py", line 201, in convert_path
raise ValueError, "path '%s' cannot end with '/'" % pathname
ValueError: path 'follow/templates/' cannot end with '/'
PS C:\Users\tbroder\workspace\django-follow>
The docs is pretty clear on how to get followers of an object (eg followers of a user), but I am struggling with how to get a list of users (eg) that a user is following.
I'd assume is comes down to using Follow.objects.is_following(user, obj)
But not sure - any chance you could provide an example?
Further, here is my issue that I've put on stackoverflow: http://stackoverflow.com/questions/26599231/using-django-follow-to-set-up-following-via-queryset
When register follow with an model in which object fields may contain non-assic strings, system would complain assic decode error.
Change the unicode method in Follow with the following solves the problem.
def unicode(self):
return self.get_object().unicode()
For some reason, foreign key constraints seem to not be created. I'm guessing this is because contribute_to_class()
doesn't create a constraint? Not sure what's going on, as indexes and other stuff is created correctly. This is on Django 1.5.
I haven't had much time to investigate this further, but the following got me up and running with working constraints:
Using south, add follow
as an external migration:
SOUTH_MIGRATION_MODULES = {
'follow': 'utils.external_migrations.follow', # My local migrations for external apps
}
Then create an initial migration and migrate:
manage.py schemamigration --initial follow manage.py migrate follow
and rinse & repeat for new fields.
I would like to know if this package works with Django 2.2 and python 3.X.
thank you
Hi Bro,
I’m not getting this. User with id 1 is following user with id 2. But when I check it out in my database, it happens to be that User 1 is following target_userprofile 1. Instead of 2. Why is it like that?
id user_id datetime target_userprofile_id
10 1 2012-03-13 19:16:33 1
Attribute Error: 'Options' object has no attribute 'module_name' on runserver migrate.py
This is happening because According to https://docs.djangoproject.com/en/1.8/internals/deprecation/ its been renamed to model_name.
If I have 100 models to follow, current follow table will create 100 columns, and 99 of them are useless.
Should change the current model. Just add a model_name column.
Hi caffeinehit,
After setting up the package, I tried to visit the user profile, and I’m getting this error:
TemplateSyntaxError at /profiles/picomon/
Invalid block tag: 'request.user|is_following:UserProfile', expected 'endblock' or 'endblock content'
Request Method: GET
Request URL: http://127.0.0.1:8000/profiles/picomon/
Django Version: 1.3.1
Exception Type: TemplateSyntaxError
Exception Value: Invalid block tag: 'request.user|is_following:UserProfile', expected 'endblock' or 'endblock content'
Exception Location: C:\Python27\lib\site-packages\django\template\base.py in invalid_block_tag, line 290
Python Executable: C:\Python27\python.exe
Python Version: 2.7.2
In “follow/form.html”
{% load follow_tags %}
<form action="{% follow_url object %}" method="POST">
{% csrf_token %}
{% if request.user|is_following:UserProfile %}
<input type="submit" value="Unfollow" />
{% else %}
<input type="submit" value="Follow" />
{% endif %}
</form>
In User’s profile template:
{% load follow_tags %}
{% follow_url object %}
{% request.user|is_following:UserProfile %}
{% follow_form object %}
{% follow_form object "follow/form.html" %}
I registered this model:
utils.register(UserProfile)
Please help me out!
In Django 1.5, you can create a custom user model (https://docs.djangoproject.com/en/1.5//topics/auth/customizing/#substituting-a-custom-user-model) for the Auth contrib application. To reference this user in other apps, there is a new setting AUTH_USER_MODEL that should be used on any relationship fields. django-follow does not currently use this setting in the local follow.Follow model, you actually reference the django.contrib.auth.models.User object directly. This raises an error "...'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL." when running syncdb.
Hi caffeinehit,
After setting up the package, I tried to visit the user profile, and I’m getting this error:
TemplateSyntaxError at /profiles/picomon/
Invalid block tag: 'request.user|is_following:UserProfile', expected 'endblock' or 'endblock content'
Request Method: GET
Request URL: http://127.0.0.1:8000/profiles/picomon/
Django Version: 1.3.1
Exception Type: TemplateSyntaxError
Exception Value: Invalid block tag: 'request.user|is_following:UserProfile', expected 'endblock' or 'endblock content'
Exception Location: C:\Python27\lib\site-packages\django\template\base.py in invalid_block_tag, line 290
Python Executable: C:\Python27\python.exe
Python Version: 2.7.2
In “follow/form.html”
{% load follow_tags %}
<form action="{% follow_url object %}" method="POST">
{% csrf_token %}
{% if request.user|is_following:UserProfile %}
<input type="submit" value="Unfollow" />
{% else %}
<input type="submit" value="Follow" />
{% endif %}
</form>
In User’s profile template:
{% load follow_tags %}
{% follow_url object %}
{% request.user|is_following:UserProfile %}
{% follow_form object %}
{% follow_form object "follow/form.html" %}
I registered this model:
utils.register(UserProfile)
Please help me out!
Seems the default views don't handle this, and there is no js included.
I believe there is a bug in the Follow.unicode method:
return '%s' % self.target
should really be:
return u'%s' % self.target
Otherwise you've got <Follow: [Bad Unicode data]> if a representation of target has non-ascii characters.
For instance in my project this even leads to a 500 page with exception thrown by the logger function,
the code is:
label = unicode(follow_inst)
Note, I tried str(...) and repr(...) with the same result (because Model.str still uses force_unicode)
When I applied the fix mentioned above, the error gone.
In 'templates/follow/form.html' it seems to me that the input value got reversed:
I'd submit a pull request if you want, but it seemed such a minor issue...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.