how to change the data scraped by facebook like? - django

I am using facebook "like" as a iframe on my site. The data that the facebook button scraps from my sites url is not correct. How can we customize this data being sent or scraped?
i.e. I am using django, and hence have a base.html which has the meta tags of facebook. This base.html is extented throughout the site.
Now I cant understand how to customize these meta tags for each individual page that my site has.
Is there a way to give these attributes in the iframe itself ?
Is the question clear ? else please comment i will make the necessary changes.

Do you mean the open graph meta tags?
http://ogp.me/
I don't think it's valid to add meta tags anywhere in a page (i.e. outside the head tag) in order to customise their contents on each of your pages but I think it's valid in html 5 to have meta tags outside the head tag so I would suggest trying it first and then if you're able to, try and set it up so that in your base.html the meta tags are holding a variable and then on each of your pages that use the base.html you can specify the value of the variable on the individual page.

Related

Can I render an id of a tag instead of full page

Hey guys I am building a website in which the sections of that website are in same html pages and they are given an id ,Now in this special case I want to make a url in django which can go to the specific id not the whole html page
Is this possible?

wagtail pages vs using django views and urls

When and where should I use wagtail pages and when should I write my custom urls and views using django? for example should I create pages for user profiles or should I add a urlpattern for profile and write profile logic in a django view?
This question is pretty broad and it depends a lot on what you are trying to achieve, but here are some thoughts.
General Approach
Use Wagtail pages if your pages have CMS (user) editable content and need to be placed (and easily moved) within the main page tree along with other editable pages.
If a page is not editable and URL must be fixed, it might be best to approach this either with Django URLs and views. Eg. Sitemap or Search page.
The docs cover how to set up mixed URLs in Integrating into Django.
Specific Use Case - User Profiles
You could create a Wagtail page model like UserProfileIndex which could contain some CMS editable content about that page such as body text and images.
This assumes you are wanting to make a social media type index and page for each user.
Then use RoutablePageMixin to have the URLs for each individual profile page.
Sometimes this index page thinking can come in handy, it let's you change the root URL but puts the logic for sub-urls within the model.
Remember that this means CMS users could technically change the slug of this page, unless it is locked down.
If you are trying to create a user profile page that is more suited for a user to manage their profile then it would probably best to use Django view.

Drupal 8: How to alter the final html output?

I use a single drupal8 installation to serve content for multiple website's FAQ section. So I have put some custom tags like "##website_name##" in the html in article content and title. I also have blocks and custom views which display links to other articles like: related articles or popular articles etc.
I want to replace the custom tags with the respective value of the website. Is there any hook present in drupal8 which will be executed on generation of final output html but before sending it to browser so that I can place my replacement login there ?

Django website settings variables

I’m Django beginner, I would like to know some best practices for saving variables about website like: email, website title, url, meta description, google analytics id.
I want to edit those variables inside admin and also print inside templates.
Should i create special app for that?
Thanks
I place meta tags and website title etc. in the head tags of my base.html template. I'm new as well but this is how I learned to do it.

Can't get Google map to show up in Flatpage using Django Flatpages

I have a client with a "Directions" page in their website and they wanted to add a Google map to the page, so they went to maps and put in their location and then used the "embed" link to get the html for the iframe. They then opened up the Flatpage for "Directions" page in the admin and went to html mode in TinyMCE and then pasted in the code, but as soon as they save the code is gone and there is no map, just the div tags that surrounded the iframe are left.
I have tried Googling and I have repeated the process myself but no success, does anyone know if you are just not allowed to insert iframe html into the body of a Flatpage in django?
Unless you've added some kind of additional validation/cleaning, flatpages would not remove anything from the content. Have you tried without TinyMCE?
update: The point isn't that you'd leave TinyMCE disabled; the point is to narrow down where the problem is, so you can actually fix it. And I'm almost certain the problem here is TinyMCE, not Django.
I would suspect that tiny-mce is garbling something up. I'd try to disable tinymce and see if you have the same problem. Also, make sure you're using the 'safe' filter on the text in the templates. Otherwise Django will escape all the HTML.