Sphene Community Tools

Community

Copyright © 2007 by Herbert Poul
You are not logged in.
Login
Register

Change Language:



AddThis Social Bookmark Button

A Django site.
Profile for TimVerhoeven

Name TimVerhoeven
Email Address Reveal this emailaddress
Posts8
  • Re: board category extensions - part 2
    Board >> General >> Feature Discussions
    ...snip...

    or even better.. try it with the interactive shell ... something like..


    ./manage.py shell
    from sphene.sphboard.models import Post
    p = Post.objects.get( pk = 123 )
    p.masterpost.get()


    (replace 123 with the id of a post)

    I need to remember this one, very handy :-)

    Anyway, I've got it working. I've made 2 mistakes. The first one is that you need to do the {{ with ... }} statement after you have defined the variable you use inside the with statement (it is inside a for loop in my case).
    Second is that I need to use this syntax {{ with thread.root_post.masterpost.get as faq }} because my models has a reference to a post object, not to a thread object.

    Thanks for the help !
    Tim
  • Re: board category extensions - part 2
    Board >> General >> Feature Discussions
    but.. my guess about your problem would be that you have defined a related name.. so .. you have to use it :)
    try: {% with thread.masterpost.get as faq %} ... but.. i would definitively choose another related_name ;) (related name is the name of the reference in the target model pointing back to the model with the ForeignKey...)
    Herbert Poul at 2008-03-19 13:07:34 ---
    Yeah, I'll change the related_name later one. First get int working ;-).

    I've been reading the django models docs and also found what you suggest. But no go. I still can't get output. To continue testing I'll delete the database and start again to make sure the database is in order.
  • Re: board category extensions - part 2
    Board >> General >> Feature Discussions
    Something I forgot. I can see in the database dump that my extension table contains data. So it is there.

    Thanks again,
    Tim
  • board category extensions - part 2
    Board >> General >> Feature Discussions
    Hi,

    I'm almost getting there with custom category extension but I've hit a problem. I can't seem to access the content of my custom category model inside my template (and probably also in my normal code).

    This is my model :
    class FaqPostExtension(models.Model):
    post = models.ForeignKey( Post, unique = True, related_name = 'masterpost' )
    status = models.IntegerField( choices = FAQ_STATUS_CHOICES, default = 1 )
    summarypost = models.ForeignKey( Post, unique = True, null = True, related_name = 'summarypost' )

    I then do this in my template : {% with thread.faqpostextension_set.get as faq %} but {{ faq.status }} does not return anything.

    Is there way to get python/django to output the content of a model object (like thread in this example) to see what is inside ? That would make debugging this a bit easier :-)

    Thanks,
    Tim
  • Re: Summary feature for board
    Board >> General >> Feature Discussions
    well .. i have moved the doinit from the __init__.py file out into the views.py .. because it caused errors with the last i18n changes.. (recursive imports) .. you could try adding it to the models.py though

    (i actually thought views.py is always loaded.. no matter if it is part of any url pattern)
    That worked :-) I could tell that the views.py is not loaded because there appeared no views.pyc.

    Anyway. I'll try using this Category framework to see if I can add my FAQ/summary this way.

    Thanks for the support !
    Tim
  • Re: Summary feature for board
    Board >> General >> Feature Discussions
    This is the traceback for the blog. I get this when click on the "Submit new Post" button :

    AttributeError at /blog/postthread/
    'NoneType' object has no attribute 'name'
    Request Method: POST
    Request URL: http://localhost:8080/blog/postthread/
    Exception Type: AttributeError
    Exception Value: 'NoneType' object has no attribute 'name'
    Exception Location: /home/tim/communitytools/sphenecoll/sphene/sphboard/models.py in get_absolute_post_thread_url, line 373

    I've also tried to get the linklist to work. But it I can't get it to appear as a Catergory Type in the admin interface. After looking at the code a bit I think I'm missing a url pattern for it, that causes views.py to not get called which contains the doinit() function to register the caterogy. (That is how I see it). But since the views.py file for sphlinklist only contains the doinit() function and no real views I don't think I can make a URL pattern for it. So should I place the doinit inside a __init__.py or somewhere else in my project ?
  • Re: Summary feature for board
    Board >> General >> Feature Discussions
    Hi,

    I've look at the sphlinklist and sphblog code and that seems to be a nice way to use the features of the rest of the SCT. I've tried getting the blog to work but I'm getting tracebacks and I do not directly see what it wrong. But anyway. Some more documentation on how this works would be great. It seems the right way to do it.

    Tim
  • Summary feature for board
    Board >> General >> Feature Discussions
    Hi

    I've got another feature request. I'm looking to be able to do a annotation on a thread level. Let me explain. I'm planning to (mis)use the board for Q&A style site. People can ask questions and set of users are allowed to reply to the question (the "experts"). If the "asker" has had sufficient answers he can choose one of the users who replied to create a summary answer that replaces the thread below the question. The thread does not get deleted and is still available from the summary as a reference.

    I've been testing board and it basically has everything I need except the summary feature. I'm willing to code this part myself, but I would first like to discuss a bit what would be the best way to do this.

    Thanks for your nice work,
    Tim


Powered by Sphene Community Tools