Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 115 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Featuring" content in a Django website

#1
I'm working on a new Django project, and the client wants to "feature" content on the homepage and a few other sections of the website. Content in this case could be a blog post, an event, a news story, etc. Each item would have a "start featuring" datetime and an "stop featuring" datetime.

I've done this a few different ways in the past, but wonder if anybody has any great methods of archiving this.
Reply

#2
Have you looked at the [contenttypes framework][1]? You could set up a `FeaturedItem` model, with start and end datetimes, and a generic foreign key. This allows the relationship to be with any model.

If you heavily feature objects from particular models, look at the section on [reverse generic relations][2].


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#3
I'm trying something similar, using the contenttypes framework but the problem comes when displaying the relationship in the admin area. I've been trying to hack this together to simply show a checkbox with "Featured?" next to it.

class FeaturedContent(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')

I'm not yet clear on how to implement the checkbox.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through