Comments (5)
Hey,
I think I know what's causing this - MentionableMixin has the fields:
allow_incoming_webmentions = models.BooleanField(default=True)
allow_outgoing_webmentions = models.BooleanField(default=False)
As you can see, allow_outgoing_webmentions
defaults to False
. Thank you for reminding me about this default behaviour! I definitely need to add this to the documentation because it's not at all obvious.
So for outgoing webmentions to be processed you need to set allow_outgoing_webmentions
to True
. How you do that depends on your preference and/or how you create your posts.
Change default behaviour
If you always want your model to process outgoing mentions you can override the field on your model:
class MyPostModel(MentionableMixin, models.Model):
allow_outgoing_webmentions = models.BooleanField(default=True)
...
def all_text(self):
"""This also needs to be implemented if you haven't already!
It should return whatever text you want to process for
outgoing mentions."""
return f'{self.title} {self.content}'
(You will need to run makemigrations
and migrate
after doing this.)
Outgoing mentions should then be processed every time you save your post.
Keep default behaviour
Creating/editing via Django Admin pages
If you are editing your posts via the Django Admin and you are using fieldsets
then add allow_outgoing_webmentions
:
@admin.register(MyPostModel)
class MyPostModelAdmin(admin.ModelAdmin):
fieldsets = (
...
('Mentions', {
'fields': (
'allow_incoming_webmentions',
'allow_outgoing_webmentions',
),
}),
...
)
This will provide a checkbox that you can tick when you want to process outgoing mentions.
(If you are not using fieldsets
then those fields should already appear on the admin page.)
Creating/editing manually
If you are creating the posts via MyPostModel.objects.create()
then you will need to set the field before saving:
post = MyPostModel.objects.create(title='whatever')
post.allow_outgoing_webmentions = True
post.save()
Let me know if that fixes the issue for you. I will add this to the documentation asap.
from django-wm.
I will certainly adjust my model to have allow_outgoing_webmentions = models.BooleanField(default=True)
. However I think this is not the issue.
This is how my django-admin "Add a Post" looks like:
I made sure to allow outgoing webmentions before saving the post.
I will make some adjustment to my code base as you suggested. Meanwhile, do you have a suggestion as to how to debug sending and receiving webmentions? For example, do you think it would be useful to check celery logs on the server?
Thanks a ton in advance.
from django-wm.
Hey,
Yes, your celery logs should show several messages while the task runs. Something like:
outgoing_webmentions Checking for outgoing webmention links...
outgoing_webmentions Checking url=https://django-wm.dev
outgoing_webmentions Found webmention endpoint: https://django-wm.dev:443/webmention/
outgoing_webmentions https://django-wm.dev:443/webmention/: {'target': 'https://django-wm.dev', 'source': 'https://beatonma.org/a/190406-webmention-test'}
outgoing_webmentions Sending webmention to "https://django-wm.dev:443/webmention/" successful with status_code=202
Also, I have just published an update which adds a new model to help track the status of outgoing mentions. I've also added a log message so you can see when the process_outgoing_webmentions
task is passed to Celery after saving your post.
Please update to this version, run makemigrations
and migrate
, reload your server and save a post with a mentionable link again. You should then see Outgoing webmention processing task added to queue...
in your server log, and you should see an entry at your-server-admin-url/mentions/outgoingwebmentionstatus/
like this:
Sorry for the late response - I'm off until Tuesday now so I'll be more available until then!
Michael
from django-wm.
What command do you use to check Celery logs on your server (or what file you look at)? I've googled this and read the documentation, but couldn't get it quite right. Thanks in advance.
from django-wm.
I'm not sure what the default behaviour is - you could try tail -f /var/log/syslog
. If that doesn't show anything useful I'd look in /var/log/
for something like celery.log
.
Otherwise, you can configure the log to go anywhere you like via the LOGGING
entry in your project settings file. If you already have a LOGGING
entry you can just add the following to LOGGING.loggers
:
'celery.task': {
'handlers': ['console', 'file',], # These are defined in LOGGING.handlers - see below if you need to add those entries
'propagate': True,
'level': 'DEBUG',
},
Here's an example:
# settings.py
CELERY_LOG_PATH = '/path/to/mysite-celery.log' # Make sure your `celery` user has write access to this file, wherever you put it!
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %($
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
'file': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'verbose',
'filename': CELERY_LOG_PATH,
'maxBytes': 1 * 1024 * 1024,
'backupCount': 2
},
},
'loggers': {
'celery.task': {
'handlers': ['console', 'file',],
'propagate': True,
'level': 'DEBUG',
},
# add any other app loggers you want here
},
}
from django-wm.
Related Issues (20)
- Expand the allowed versions of the required requests package? HOT 2
- Add more flexibility in URLs for MentionableMixin models HOT 3
- How to only send webmentions from "live" objects?
- Add template for successful submission of webmention
- Don't make links to same-page #anchors into targets
- HCards only being found if they're the first item in the soup
- Should HCards be found within h-entry's?
- Quote text is never set HOT 2
- Multiple outgoing mentions created when connections repeatedly fail HOT 5
- Still trying to send webmentions to #anchor links? HOT 3
- Webmentions being accepted by pages that aren't Mentionable HOT 4
- Mentions for models without a `slug` field HOT 2
- Webmention endpoint resolution failing when there are multiple `link`s in header HOT 3
- Single incoming webmention repeatedly being processed. HOT 6
- Problem integrating django-wm with Wagtail HOT 21
- `allow_outgoing_webmentions` field does not display on custom forms HOT 7
- Lots of "settings.WEBMENTIONS_URL_SCHEME should not be `http` when in production!" warnings during tests
- Small error in QuotableAdmin's search_fields HOT 1
- [Feature Request] Exclude domains and/or URLs from outgoing webmentions HOT 3
- Clean Install Breaks Incoming Webmentions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-wm.