Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,162,667 members, 7,851,273 topics. Date: Wednesday, 05 June 2024 at 04:12 PM

Python Django: How Users Can Follow Tags - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Python Django: How Users Can Follow Tags (834 Views)

Nairaland Should Switch To Python/django. Opinion / Learn How To Create Websites With Python(Django Web Framework) / Let's Build A Simple Blog With Python(django) (2) (3) (4)

(1) (Reply)

Python Django: How Users Can Follow Tags by FuckYou: 2:31pm On Jun 07, 2019
Pls.. who knows how I can create a blog where users can follow a tag and gets Topics only on those tags.
I have intermediate experience in Python Django, but I dont know how to go about creating a blog where users can follow a tag and gets Topics on those tags they are following..
Can someone walk me through
Re: Python Django: How Users Can Follow Tags by resosdigital(m): 2:45pm On Jun 07, 2019
Eont use django much but guess I will tell u how I would implement in laravel.

You need a many to many relationship between tags and users.

For this you need 3 tables: users, tags, and tag_subscriptions

Users and tags table must have a primary id to identify each record.

The scheme for the tag_subscriptions table will contain just two columns
user_id and tag_id.

How it works.

Let's say when user with id 3 wants to subscribe to tag with id 5, you insert a new record into tag_subscriptions with the appropriate ids for user and tag.

When you need to retrieve all the subscribed tags for say user with id 4. You would query the tag_subscriptions table for all records with user_id 4, then you can get the tag_ids and the tags.

I am sure you should be able to figure out how to implement in django

1 Like

Re: Python Django: How Users Can Follow Tags by Badilstical(m): 3:07pm On Jun 07, 2019
resosdigital:
Eont use django much but guess I will tell u how I would implement in laravel.

You need a many to many relationship between tags and users.

For this you need 3 tables: users, tags, and tag_subscriptions

Users and tags table must have a primary id to identify each record.

The scheme for the tag_subscriptions table will contain just two columns
user_id and tag_id.

How it works.

Let's say when user with id 3 wants to subscribe to tag with id 5, you insert a new record into tag_subscriptions with the appropriate ids for user and tag.

When you need to retrieve all the subscribed tags for say user with id 4. You would query the tag_subscriptions table for all records with user_id 4, then you can get the tag_ids and the tags.

I am sure you should be able to figure out how to implement in django
He should rather use ORM, read more on django docs

1 Like

(1) (Reply)

Magento 2 Custom Cart & Checkout Messages Extension By Fmeextensions / how can I make money with my laptop / An App Developer Interested In Co-founding A Startup

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.