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

  • Home
  • SEARCH
  • 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 597045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:14:15+00:00 2026-05-13T16:14:15+00:00

I am using a ForeignKey called Memberno in My Django models. After entering data

  • 0

I am using a ForeignKey called Memberno in My Django models. After entering data in the Members Class, it appears in the other classes as “member object” in the ‘memberno’ field. For ForeignKey, I am using ‘raw_id_fields’ as a workaround, but for normal fields and even ‘filter_horizontal’ , each memberno value is displayed as “member object”. I would like the values to appear as they are in the member class i.e. 1, 2, …

from django.db import models

# Create your models here.
class Members(models.Model):
    DESIGNATION_CHOICES=(
    ('ADM', 'Administrator'),
    ('OFF', 'Club Official'),
    ('MEM', 'Ordinary Member'),
    )
    memberno = models.AutoField(primary_key=True)
    fname = models.CharField(max_length=15)
    sname = models.CharField(max_length=15)
    onames = models.CharField(max_length=30, blank=True)
    email = models.EmailField()
    phoneNumber = models.CharField(max_length=15)
    regNo = models.CharField(max_length=15)
    designation = models.CharField(max_length=3,choices=DESIGNATION_CHOICES)
    image = models.ImageField(max_length=100,upload_to='photos/%Y/%m/%d', blank=True, null=True)
    course = models.CharField(max_length=30, blank=True, null=True)


def __unicode__(self):
    return  u'%s %s %s' % (self.fname, self.sname, self.memberno)


def get_absolute_url(self):
    return '%s%s/%s' % (settings.MEDIA_URL, settings.ATTACHMENT_FOLDER, self.id)

def get_download_url(self):
    return '%s%s/%s' % (settings.MEDIA_URL, settings.ATTACHMENT_FOLDER, self.name)




class Security(models.Model):
    memberno = models.ForeignKey(Members, unique=True)
    username = models.CharField(max_length=30, primary_key=True)
    password = models.CharField(max_length=70)

def __unicode__(self):
    return  u'%s %s %s' % (self.username, self.password, self.memberno)


class Subscriptions(models.Model):
    memberno = models.ForeignKey(Members)
    receiptNo = models.CharField(max_length=30, primary_key=True)
    type = models.CharField(max_length=50)
    date = models.DateField()
    amount = models.FloatField(max_length=99)

def __unicode__(self):
    return  u'%s %s %s' % (self.receiptno, self.type, self.memberno)




class events(models.Model):
    eventName  = models.CharField(max_length=25)
    eventID =  models.AutoField(primary_key=True)
    details = models.TextField()
    attendanceFee = models.FloatField(max_length=99)
    date = models.DateField()
    memberno = models.ManyToManyField(Members)



def __unicode__(self):
    return  u'%s %s %s' % (self.eventName, self.eventID, self.memberno)
  • 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-05-13T16:14:15+00:00Added an answer on May 13, 2026 at 4:14 pm

    The admin interface appears to use __str__() to determine the display of a model. I make it a habbit to always define both __unicode__() and __str__() when I create a model. For example:

    class Activity(models.Model):
        activity_code = models.ForeignKey(ActivityCode)
        note = models.TextField(blank=True)
        def __str__(self):
            return "(%s) %s" % (self.activity_code.short, self.note)
        def __unicode__(self):
            return u'(%s) %s' % (self.activity_code.short, self.note)
    

    Update:
    It looks as though your def __unicode__(self) is not indented properly in your code. As a result it is not a part of your class, and is not being used. Indenting is very important in Python.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 350k
  • Answers 350k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I believe you're missing the parentheses on It.IsAny<Delegate>(). May 14, 2026 at 7:01 am
  • Editorial Team
    Editorial Team added an answer You can subscribe to the Window's Loaded event and do… May 14, 2026 at 7:01 am
  • Editorial Team
    Editorial Team added an answer I figured it out. The issue was that the field… May 14, 2026 at 7:01 am

Related Questions

I am using the standard User model (django.contrib.auth) which comes with Django. I have
In a custom Form, how does one validate a Model's field's uniqueness (i.e., has
I am trying to write a Firefox 3 add-on which will enable me to
Ok, so let me explain a little of what I am trying to do.
My first question on here so be nice! I am a junior developer with

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.