On Dec 5, 5:17 pm, "Tane Piper" <[EMAIL PROTECTED]>
wrote:
> Here is my blog application, which contains the two models:
Thanks. So, as I said in the post above, Entry.save() override won't
work with your M2M categories. That's because the M2M objects are
saved only after the Entry is saved
Hi Darryl and Tane,
>
> [untested with Many2Many, but should work, it works for ForeignKeys]
Actually, the approach below won't work for M2M even though it does
for FKs.
> In your Entry save() method call the save method of each of your related
> categories after you do your super().save()
>
>
Hi darryl,
Ok I tried as you said above, but it gives me two problems:
When I try to make my first category to use for entries I get this error:
instance needs to have a
primary key value before a many-to-many relationship can be used.
So ok, it's looking for an Entry instance to exist, but
Hi Tane,
[untested with Many2Many, but should work, it works for ForeignKeys]
In your Entry save() method call the save method of each of your related
categories after you do your super().save()
{{{
class Entry(models.Model):
...
def save(self):
if not self.slug:
Here is my blog application, which contains the two models:
from django.db import models
from django.db.models import permalink
from django.core import urlresolvers
from django.contrib.auth.models import User
from django.template.defaultfilters import slugify
import datetime
# Create your
>
> Hope that makes sense, as if I can do it this way instead of
> calculating it on the view, that would make this inclusion tag so much
> easier.
What does your Entry model look like?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to
Yes, What I wanted to do was have a field in my Category model called
num_entries, and every time an Entry model was saved, I wanted to
increment this by one - but I could not work out how to access the
Category model to update just one field per entry (for example if my
entry is in Blog and
Hi there,
At the moment, i'm building a inclusion tag for using on my blog
software to show all the categories, kind of like how Wordpress does
it. The tag works fine and displays the data, sorted in order of the
name:
@register.inclusion_tag("blog/category_list.html")
def
8 matches
Mail list logo