Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8588131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:44:13+00:00 2026-06-11T22:44:13+00:00

The code: class Article(models.Model): hits = models.IntegerField(help_text = ‘Visits count’) answer_to_article = models.ForeignKey(‘self’, blank

  • 0

The code:

class Article(models.Model):
    hits              = models.IntegerField(help_text = 'Visits count')
    answer_to_article = models.ForeignKey('self', blank = True, null = True)
    slug              = models.SlugField(unique = True, help_text = 'Address')
    meta_keywords     = models.CharField(max_length = 512)
    title             = models.CharField(max_length = 256)
    content           = models.TextField(verbose_name = 'Article contents', help_text = 'Article contents')

    def get_similar_articles_from_meta_and_relation(self, phrase, offset = 0, limit = 10):
        return ArticleToArticle.objects.find(article_one)[offset:limit]

    class Meta:
        db_table = 'article'

#only a relational table - one article can have similar articles chosen by it's author
class ArticleToArticle(models.Model):
    article_one = models.ForeignKey(Article, related_name = 'article_source')
    article_two = models.ForeignKey(Article, related_name = 'article_similar')

    class Meta:
        db_table = 'article_to_article'

My question is about my get_similar_articles_from_meta_and_relation method from Article model – I’d like to:
1. find other articles connected to my instance
2. filter them according to given phrase (meta_keywords)
While I don’t have problem with the former, I do have a problem with the later.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:44:14+00:00Added an answer on June 11, 2026 at 10:44 pm

    Not sure what the relation between meta_keywords ant the phrase parameter is, but you probably want something similar to:

    class Article(models.Model):
        hits              = models.IntegerField(help_text = 'Visits count')
        answer_to_article = models.ForeignKey('self', blank = True, null = True)
        slug              = models.SlugField(unique = True, help_text = 'Address')
        meta_keywords     = models.CharField(max_length = 512)
        title             = models.CharField(max_length = 256)
        content           = models.TextField(verbose_name = 'Article contents', help_text = 'Article contents')
        similar_articles  = models.ManyToMany('self')
    
        def get_similar_articles_from_meta_and_relation(self, phrase, offset = 0, limit = 10):
            return self.similar_articles.filter(meta_keywords=phrase)[offset:limit]
    
        class Meta:
            db_table = 'article'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code: class JobsManager(models.Manager): def get_active_by_category(self, cat, limit): import datetime from django.db.models import Q return
I currently have this chunk of model code: class Book(models.Model): title = models.CharField(max_length=100) num_pages
Let's say I have a set of Django Models: class Article(models.Model): title = models.CharField(max_length=100,
I've the following models class Article(models.Model): title = models.CharField(max_length=255, db_index=True) slug = UniqueSlugField(prepopulate_from='title', unique=True)
Here's my code: Models: class Article < ActiveRecord::Base attr_accessible :title, :author, :content, :imageable_attributes has_one
code: class Node: def __init__(self, key, children=[]): self.key = key self.children = children def
Here is my code: class MyTestCase(Base): def setUp(self): #some code here def test_B(self): #some
I have two models, Article and Post that both inherit from a base model
I know the following model code is not correct: as models get loaded only
My code class Union { //Search Function static boolean search(int A[], int i) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.