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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:57:45+00:00 2026-05-17T20:57:45+00:00

I have a portfolio application that lists projects and their detail pages. Every project

  • 0

I have a portfolio application that lists projects and their detail pages. Every project generally has the same information (gallery, about etc. ), but sometimes the user might want to add extra information for a particularly large project, maybe an extra page about the funding of that page for example.

Would it be possible to create an overwritten flatpages model within my portfolio app that forces any flatpages created within that application to always begin with /portfolio/project-name/flat-page. I could then simply pass the links to those flatpages associated with the project to the template so any flatpage the user generates will automatically be linked to from the project page.

EDIT

I have it somewhat working now

So I overwrite the FlatPage model in my portfolio app as described:

from django.contrib.flatpages.models import FlatPage
from project import Project
from django.db import models
from django.contrib.sites.models import Site

class ProjectFlatPage(FlatPage):
    prefix = models.CharField(max_length=100)
    project = models.ForeignKey(Project)

which allows me to associate this flatpage with a particular project,

Then I overwrite the save method to write all the extra information when a user saves (needs to be tidied up):

def save(self, force_insert=False, force_update=False):
    self.url = u"%s%s/" % (self.project.get_absolute_url(),self.prefix)
    self.enable_comments = False
    self.registration_required = False
    self.template_name = 'project/project_flatpage.html'
super(FlatPage, self).save(force_insert, force_update)

and I scaleback the admin to just allow the important stuff:

class ProjectFlatPageForm(forms.ModelForm):
    prefix = forms.RegexField(label=_("Prefix"), max_length=100, regex=r'^[a-z0-9-]+$'),

    class Meta:
        model = ProjectFlatPage

class ProjectnFlatPageAdmin(admin.ModelAdmin):
    form = ProjectFlatPageForm

so now the user can add a flat page inside my app and associate it with a particular project.

In the admin, they just enter a slug for the page and it automatically gets appended through the save() method like: /projects/project-name/flat-page-name/

The remaining problem is on the template end. I can access the normal flatpage information through the given template tags {{ flatpage.title }} and {{ flatpage.content }} put I have no access to the extra fields of the inherited model (i.e. the project field)

Is there anyway around this?

EDIT2

Having thought about it, the easiest way is to write a template tag to find the projectFlatPage associated with the flatpage and get access to it from there. A bit like overwritting the default flatpages template tags

  • 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-17T20:57:46+00:00Added an answer on May 17, 2026 at 8:57 pm

    Of course. Just write your own flatpage-model, for example:

    from django.contrib.flatpages.models import FlatPage
    
    class MyFlatPage(FlatPage):
        prefix = models.CharField(max_length=100, editable=False)
        url = models.CharField(_('URL'), max_length=100, db_index=True, editable=False)
    

    Then add a proper MyFlatPageAdmin to your admin.py file (if you want to, you can import the flatpageadmin from django.contrib.flatpages.admin and inherit from it). After all, you’re using the flatpage-model, but overwrite the urls-field. Now add a signal, which concats the prefix and a automatically generated url suffix to the url (like the object id). You can now add the custom flatpage like:

    flatpage = MyFlatPage(prefix='/portfolio/my-super-project/')
    

    Everything clear now?

    edit 1

    As you can read in the documentation, every flatpage should be a projectflatpage and vice versa.

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

Sidebar

Related Questions

I have a friend that is making a portfolio site. He has some high
I have a rewirte rule that rewrites my portfolio urls from portfolio.php?cat=cat-name&project=project-slug to /portfolio/cat/slug/
In my portfolio site I have listed my projects under separate tabs (tab menu).
Have a matrix report now that has Position, Hours and Wages for a location
I'm creating simple application, some kind of portfolio. I've heard that it's better to
I have an online portfolio created in Rails featuring different projects. I want to
I currently have hostingrails.com. But following their tutorial on deploying rails application with FASTCGI
I'm creating a Django powered website that will have numerous applications (Blog, Shop, Portfolio,
I have started currently an portfolio application for HoneyComb tablet. I have used ActionBar.Tab
I have inherited a broad, ill-designed web portfolio at my job. Most pages are

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.