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 5968751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:08:03+00:00 2026-05-22T20:08:03+00:00

I am trying to create two user types in django 1.3. I am subclassing

  • 0

I am trying to create two user types in django 1.3. I am subclassing the AUTH_PROFILE_MODULE with the following models.py:

class Member(models.Model):
    ROLE_CHOICES = (
        (0, 'Guide'),
        (1, 'Operator'),
    )
    user = models.ForeignKey(User, unique=True)
    location = models.CharField(max_length=60)
    role = models.IntegerField(choices=ROLE_CHOICES)


class Guide(Member):
    bio = models.TextField(blank=True)
    experience = models.TextField(blank=True)
    image = models.ImageField(blank=True, upload_to='images')
    fileupload = models.FileField(blank=True, upload_to='files')

    def __unicode__(self):
        return self.user.username

    def get_absolute_url(self):
        return '/profiles/guides/%s' % self.user.username


class Operator(Member):
    bio = models.TextField(blank=True)
    image = models.ImageField(blank=True, upload_to='images')

    def __unicode__(self):
        return self.user.username

    def get_absolute_url(self):
        return '/profiles/operators/%s' % self.user.username

I am using generic class based views and can get the ListView to work for the Guide and Operator models I cannot get the DetailView to work. My views.py is as follows:

class GuideDetailView(DetailView):
    model = Guide
    context_object_name = 'guide'
    template_name = 'members/guide_detail.html'


class GuideListView(ListView):
    model = Guide
    context_object_name = 'guides'
    template_name = 'members/guide_list.html'

Any idea what might be missing?

  • 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-22T20:08:04+00:00Added an answer on May 22, 2026 at 8:08 pm

    Either provide a queryset:

    class GuideDetailView(DetailView):
        queryset = Guide.objects.all()
    

    or override the get Method of DetailView:

    class GuideDetailView(DetailView):
        def get(self):
            return "Everything you want, maybe: Guide.object.get(id=1)"
    

    Given this in your urls.py:

    url(r'^(?P<my_id>\d)/$', GuideDetailView.as_view(),),
    

    You need to override get, like this:

    class GuideDetailView(DetailView):
        def get(self, request, **kwargs):
            # lookup Guide Id in your database and assign it object
            self.object = Guide.objects.get(pk=kwargs.get('my_id'))
            # add object to your context_data, so that you can access via your template
            context = self.get_context_data(object=self.object)
            return self.render_to_response(context)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a rating system, where the user can rate pictures/videos/audio etc.
I am trying to create a simplified code to insert images dynamically into a
I am trying to generate a unidirectional one-to-many mapping between two JPA entities. In
I'm trying to create an iOS application which upon loading, will initially connect via
In my rails 3 project, I'm trying to create a consistent error/success message display
I am trying to develop a database for a website. This website has registered
Hello I am a php developer, trying to get going with Oracle. So I
Please excuse my english, I'm still trying to master it. I've started to learn
I read some stuff about PropertyGrid (cause I am pretty new to that control)
I'm implementing a small voting system on my website. I came up with three

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.