Re: include template which extends something else

2015-10-28 Thread Sven Wanner
Oh man sorry, there was something wrong with finding the template but many
thanks for your advices. It helped me a lot even if the problem was
blindness. But anyway, I am happy now.

Best regards to you

2015-10-28 17:25 GMT+01:00 Sven Wanner :

> Yes, sorry I was confused... No I don't get what you mean. I think thats
> exactly what I tried to do.
>
> I have kind of a main.html doing that:
>
> {% block my-wall %}
> 
> 
> {% for obj in objects %}
> 
> {% include 'wall_item.html' with object=obj %}
> 
> {% endfor %}
> 
> 
> {% endblock %}
>
> wall_item.html looks like that:
>
> {% extends "wallitem.html" %}
>
> {% block wall_item_header %}
> something
> {% endblock %}
>
> and wallitem.html like that:
>
> 
> 
> {% block wall_item_header %}
> {% endblock %}
> 
> 
>
>
> 2015-10-28 17:13 GMT+01:00 Carl Meyer :
>
>> On 10/28/2015 10:11 AM, Sven Wanner wrote:
>> > Ok, it's a pitty, but you're totally right. Using if in my template
>> > should be also fine. Not of that elegance I planned  ;) , but will
>> > definitely work, too.
>>
>> I'm not sure what you mean. I thought I just explained how you can use
>> `extends` in an included template -- I think that should work just fine
>> for your use case (and I just tested to verify that it does work).
>>
>> Carl
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/SFh41AI0dcM/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/5630F421.2020906%40oddbird.net
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAH4Xs%2BOgYS5gpPQEc4vW8Q%2BEaFqef_DhZwPv2Xh6uoQZr5h7-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: include template which extends something else

2015-10-28 Thread Sven Wanner
Yes, sorry I was confused... No I don't get what you mean. I think thats
exactly what I tried to do.

I have kind of a main.html doing that:

{% block my-wall %}


{% for obj in objects %}

{% include 'wall_item.html' with object=obj %}

{% endfor %}


{% endblock %}

wall_item.html looks like that:

{% extends "wallitem.html" %}

{% block wall_item_header %}
something
{% endblock %}

and wallitem.html like that:



{% block wall_item_header %}
{% endblock %}




2015-10-28 17:13 GMT+01:00 Carl Meyer :

> On 10/28/2015 10:11 AM, Sven Wanner wrote:
> > Ok, it's a pitty, but you're totally right. Using if in my template
> > should be also fine. Not of that elegance I planned  ;) , but will
> > definitely work, too.
>
> I'm not sure what you mean. I thought I just explained how you can use
> `extends` in an included template -- I think that should work just fine
> for your use case (and I just tested to verify that it does work).
>
> Carl
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/SFh41AI0dcM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5630F421.2020906%40oddbird.net
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAH4Xs%2BP_C6PYeih9L7tr1GAH4%3D6QMtGOFGbfUSi9TK1O87WEXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: include template which extends something else

2015-10-28 Thread Sven Wanner
Ok, it's a pitty, but you're totally right. Using if in my template should
be also fine. Not of that elegance I planned  ;) , but will definitely
work, too.

Thank you

2015-10-28 17:04 GMT+01:00 Carl Meyer :

> Hi Sven,
>
> On 10/28/2015 09:50 AM, Sven Wanner wrote:
> > Thanks for your quick reply. Yes, this is also what I found, so I was
> > quite shure that my code will never work. What I try to do is to render
> > a list of database objects. But not only on one page but on different
> > pages and with slightly different designs in each of the lists. So my
> > plan was, to avoid writing individual templates for each list, to create
> > one base template for the general appearance of such list items and only
> > adapt blocks on each individual list.
> >
> > Explained the other way around, how would I render a template.html which
> > needs a database object  in a for loop and which extends a base_template
> > html?
> >
> > Hope I achieved to explain the problem well enough...
>
> If I'm understanding right, I think blocks do work fine for your situation.
>
> What you can't do, as Tim explained, is have blocks in an included
> template interact with blocks in the including template. They are two
> totally separate renders, with totally separate inheritance hierarchies.
> But there's no problem with included templates having their own
> independent inheritance hierarchy, with blocks.
>
> So you can have an `item_base.html` that contains `{% block someblock
> %}{% endblock %}`, and then define `item_foo.html` that `{% extends
> "item_base.html" %}` and has `{% block someblock %}foo content{%
> endblock %}`, and you can have a `main.html` that has `{% include
> "item_foo.html" %}`, and all that should work fine -- the included
> portion should display "foo content".
>
> What you can't do is expect the `{% block someblock %}` in
> `item_base.html` or `item_foo.html` to interact in any way with a `{%
> block someblock %}` in `main.html` (or its parent). The included
> template and the including template have separate and unrelated
> inheritance and blocks.
>
> Carl
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/SFh41AI0dcM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5630F1F6.5090100%40oddbird.net
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAH4Xs%2BPErnWvcOpzr1wuhGFLen9iNtw-gg9M4HOY7gMT7V3-rg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: include template which extends something else

2015-10-28 Thread Sven Wanner
Thanks for your quick reply. Yes, this is also what I found, so I was quite
shure that my code will never work. What I try to do is to render a list of
database objects. But not only on one page but on different pages and with
slightly different designs in each of the lists. So my plan was, to avoid
writing individual templates for each list, to create one base template for
the general appearance of such list items and only adapt blocks on each
individual list.

Explained the other way around, how would I render a template.html which
needs a database object  in a for loop and which extends a base_template
html?

Hope I achieved to explain the problem well enough...

2015-10-28 16:39 GMT+01:00 Tim Graham :

> I think that's a limitation described in the {% include %} docs:
> https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#include.
> See the "Note" box where it says:
>
> The include
> 
> tag should be considered as an implementation of “render this subtemplate
> and include the HTML”, not as “parse this subtemplate and include its
> contents as if it were part of the parent”. This means that there is no
> shared state between included templates – each include is a completely
> independent rendering process.
>
> Blocks are evaluated *before* they are included. This means that a
> template that includes blocks from another will contain blocks that have 
> *already
> been evaluated and rendered* - not blocks that can be overridden by, for
> example, an extending template.
> 
> It's difficult for me to make a suggestion about how to structure things
> without a more complete understanding of what you're trying to do.
>
> On Wednesday, October 28, 2015 at 11:28:07 AM UTC-4, svewa wrote:
>>
>> Hi all,
>>
>> sorry if it might be a stupid question for pro's but it seems I still
>> miss a deeper knowledge of some design aspects. What I try to do is the
>> following:
>>
>> 
>> {% for obj in objects %}
>> 
>> {% include 'item.html' with object=obj %}
>> 
>> {% endfor %}
>> 
>>
>>
>> this I need to to in three different apps with slightly varying
>> appearance of item.html.
>>
>> So my idea was to create a root_item.html in my root template folder and
>> simply do in item.html the following::
>>
>> {% extends "root_item.html" %}
>> {% block anyblock %}
>> {% endblock %}
>>
>>
>> I'am so far that I guess I know that this will not work. Could anyone
>> explain to me the prefered way to achieve this? In words, I need a base
>> template which extensions should be rendered as list items...
>>
>> Sorry I'am shure it is easy but I am stuck
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/SFh41AI0dcM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/af32f8fd-e83b-4767-8f37-eaccc1ec70b8%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAH4Xs%2BO%2Bk20ht4Lhiw9eA6jNcs-yC8qEj9MzGCUpvKbjEFFnOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to mock a model backend

2015-03-26 Thread Sven Mäurer
In my model backend I usually call an external service which returns me an 
user that is saved and returned. When I don't have credentials I want to 
mock the backend for some test cases. In the setup of each test case I am 
calling the login method where CRED contains the real credentials or mock 
credentials. This can be determined by are_credentials_given.

def are_credentials_given():
return not os.path.isfile(os.path.join(BASE_DIR, 'settings/credentials'))


def login(self):
u = User.objects.create(id=CRED['ID'], is_staff=True)
u.save()
token, c = Token.objects.get_or_create(user=u)
if c:
token.save()
self.client = APIClient()
self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key)
self.client.login(username=CRED['USERNAME'], password=CRED['PASSWORD'])

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/894d8e22-b448-41fc-bd1b-a82a2a35db8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django accepting other applications ports

2015-03-25 Thread Sven Mäurer
Ohh thanks. You have saved at least 4 hours of my sleep, 10 coffees and a 
very bad mood!

Am Mittwoch, 25. März 2015 21:57:19 UTC+1 schrieb Stephen Butler:
>
> On Wed, Mar 25, 2015 at 2:27 PM, Sven Mäurer  > wrote: 
> > backend.conf 
> > 
> > Listen 8787 
> > 
> > WSGIScriptAlias / /var/www/html/backend/API/wsgi.py 
> > WSGIPythonPath 
> > 
> /var/www/html/backend:/var/www/html/backend/venv/lib/python2.7/site-packages 
>
> > WSGIPassAuthorization On 
>
> WSGIScriptAlias belongs in your VirtualHost, not at the server config 
> level. Also... 
>
> >  
> > DocumentRoot /var/www/html/backend 
> >  
> >  
> > Require all granted 
> >  
> >  
> > 
> > ErrorLog ${APACHE_LOG_DIR}/error.log 
> > CustomLog ${APACHE_LOG_DIR}/access.log combined 
> > 
> >  
>
> This is dangerous. You should never set your DocumentRoot to be where 
> your code is. A minor misconfiguration in your apache setup could 
> expose all your source code! Instead set your document root to 
> something empty (or maybe containing your static files directory) and 
> do this: 
>
> WSGIPythonPath 
> /var/www/python/backend:/var/www/python/venv/lib/python2.7/site-packages 
>
>  
> DocumentRoot /var/www/html 
> WSGIScriptAlias / /var/www/python/API/wsgi.py 
>  
>  
> Order deny,allow 
> Allow from all 
> 
>  
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4909fb3a-123e-440b-bf19-787b96a0618c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django accepting other applications ports

2015-03-25 Thread Sven Mäurer
 

*backend.conf*

Listen 8787

WSGIScriptAlias / /var/www/html/backend/API/wsgi.py
WSGIPythonPath 
/var/www/html/backend:/var/www/html/backend/venv/lib/python2.7/site-packages
WSGIPassAuthorization On


DocumentRoot /var/www/html/backend


Require all granted



ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined




*website.conf*

Listen 



DocumentRoot /var/www/html/website

Options FollowSymLinks
AllowOverride All


Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all


ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined



Am Mittwoch, 25. März 2015 20:22:05 UTC+1 schrieb Gergely Polonkai:
>
> Hello,
>
> Please share the rest of this Apache config; from what you copied, it's 
> impossible to tell.
>
> Best,
> Gergely
> On 25 Mar 2015 17:12, "Sven Mäurer" > 
> wrote:
>
>> I have two applications on my apache. Why is my Django application 
>> running accepting the connection also of port ?
>>
>> Listen 8787
>> 
>>
>>
>> The other application:
>>
>> Listen 
>> 
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f512ca44-b7fc-4e26-8c56-7cb325e1f6dd%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/f512ca44-b7fc-4e26-8c56-7cb325e1f6dd%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fdad8670-4d98-474e-ae33-6c719fcd4b75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django accepting other applications ports

2015-03-25 Thread Sven Mäurer


I have two applications on my apache. Why is my Django application running 
accepting the connection also of port ?

Listen 8787



The other application:

Listen 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f512ca44-b7fc-4e26-8c56-7cb325e1f6dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Dictionary in admin interface

2015-01-23 Thread Sven Mäurer


I want to manage a dictionary inline over the admin interface. These are my 
models. What I got working is of course a separated management of request 
and dictionary. But I want to add key value pairs in the request admin 
interface with a TabularInline. Do I have to skip the dictionary in some 
way or what do I have to do?

class Dictionary(models.Model):
name = models.CharField(max_length=255)
class KeyValuePair(models.Model):
container = models.ForeignKey(Dictionary, db_index=True)
key = models.CharField(max_length=240, db_index=True)
value = models.CharField(max_length=240, db_index=True)
class Request(models.Model):
params = models.ForeignKey(Dictionary, related_name="params_map", 
blank=True, null=True)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f57a2c01-95c1-4fdc-9a9c-3ed4000c0453%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to re-sync with Heroku?

2014-01-16 Thread Sven Aßmann
Hi Scott,

it looks more like a cygwin - heroku issue.
If you search for the heroku command, where do you find it, if even?

Try to extend your PATH variable to the path whereever the tool belt was 
installed and try it again.

Cheers,
Sven

On Thursday 09 January 2014 22:39:59 Scott Meyers wrote:
> Newbie here (obviously!).
> 
> I'm starting a Django project in Cygwin.  I push to Heroku.  I'm playing
> around, checking heroku logs, and my power goes out.  So I boot my
> computer, get back into Cygwin, go back into my project's root.  How do I
> sync it with Heroku again?  If I type heroku ps or heroku login or
> anything, I get "heroku: command not found".  How do I link it back up so
> my cygwin and heroku start talking to each other again?  Thanks!
-- 


Best Regards, 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2786360.KUsKBlklUr%40gilgamesch.
For more options, visit https://groups.google.com/groups/opt_out.


open data protocol and django

2014-01-16 Thread Sven Aßmann
Hi Folks,

again i wanna ask you if someone of you already had the chance to play around 
with the open data protocol and a django integration?

Currently it looks like that there is no real stable client implementation for 
python. Only found that https://code.google.com/p/odata-py/ and it is still 
not production ready.

After thinking about it i came to the idea that the djnago-rest-framework 
would be maybe the best starting point. The protocol is a REST based one and 
therefore only some serializers and glue code for data types and REST methods 
would be needed. An extension to rest-framework would be an possible option, 
maybe.

Therefore the question if someone maybe did already a small playaround basing 
on django-rest-framework or a small selfmade implementation?

Thanks for your feedback.


-- 


Best Regards, 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1553947.x5EqRhUUPE%40gilgamesch.
For more options, visit https://groups.google.com/groups/opt_out.


Re: mass email app for django

2014-01-16 Thread Sven Aßmann
Hi Dedrerik,

maybe your are right and just using a service like Mailchimp (which seems to 
be pretty userfriendly) would be the best way to go. I will defenetly have a 
look on it and try to find out if the users needs can be satisfied by that.

Thanks a lot.

Cheers,
Sven

On Thursday 16 January 2014 12:14:20 Diederik van der Boor wrote:
> Hi Sven,
> 
> What you describe sounds like a Mailinglist..
> Wouldn't it be possible to use Mailchimp or Aweber for this kind of service?
> From Django you can use their API's.
> 
> Mass-mailing has a risk of being blacklisted as server,
> at least make sure you send email via a whitelisted SMPT server (and not
> directly to everyone at the web). For mass-mailing I always recommend using
> specialized mailinglist software.
> 
> Greetings,
> Diederik
> 
> Op 15 jan. 2014, om 01:42 heeft Sven Aßmann  het volgende 
geschreven:
> > Hi Group,
> > 
> > currently i evaluating / research for a django app that supports mailing
> > specific texts to a receipient list (like mass emailing). the corner
> > features are:
> > 
> > - email text should be editable (text or html nothing special) thru the
> > admin app
> > - the receipient list should be maintainable independently from users and
> > texts (like a addressbook that is maintanale thru admin app)
> > - ideally supports several mail backends like smtp, aws sms, postmark
> > etc..
> > - processing of the sending can be done async via django cli / message
> > queue services
> > 
> > The closest use case app would be something like a newsletter app, where
> > the subscibers can be maintainted apart from django.auth.users
> > I am aware of www.djangopackages.com and found already a couple of
> > applications that could make the job.
> > 
> > I ask you folks if someone has good experience with a specific one and or
> > what features are included and helpfull and what are not that helpfull.
> > 
> > I really appreciate your contributions.
-- 


Best Regards, 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3294591.EeCsXCzNCc%40gilgamesch.
For more options, visit https://groups.google.com/groups/opt_out.


Re: mass email app for django

2014-01-16 Thread Sven Aßmann
Hi Serge,

unfortunately the smtp server is a managed server therefore no configuration to 
use a db as virtual mail backend can be performed.

But thanks for your notes, especially i wasn't aware that djnago can use the 
postmark / rest api for mails out of the box. I need to investigate on that - 
exiting.

Cheers,
Sven

On Wednesday 15 January 2014 13:34:11 Sergiy Khohlov wrote:
> Hello Sven,
> 
> Look like it is not task for django. This is task  for SMTP server. Of
> course you can create a task  for SMTP server using django but  main
> force of the your application is based on mail server.
>  I'm proposing  next solution:
> 1) Store usermail in  database
> 2) configure smtp server for using database as virtual  emails
> database (it is not hard)
> 3) Use django as web interface
> 4) Send letter to SMTP using standart protocol
> 
>  P.S. Postmark has API and it  is possible to use it directly from django.
> If you  have any questions let me know. I've supported SMTP servers
> for 15 years and 've worked  for spamfight service.
> Many thanks,
> 
> Serge
> 
> 
> +380 636150445
> skype: skhohlov
> 
> On Wed, Jan 15, 2014 at 2:42 AM, Sven Aßmann  wrote:
> > Hi Group,
> > 
> > currently i evaluating / research for a django app that supports mailing
> > specific texts to a receipient list (like mass emailing). the corner
> > features are:
> > 
> > - email text should be editable (text or html nothing special) thru the
> > admin app
> > - the receipient list should be maintainable independently from users and
> > texts (like a addressbook that is maintanale thru admin app)
> > - ideally supports several mail backends like smtp, aws sms, postmark
> > etc..
> > - processing of the sending can be done async via django cli / message
> > queue services
> > 
> > The closest use case app would be something like a newsletter app, where
> > the subscibers can be maintainted apart from django.auth.users
> > I am aware of www.djangopackages.com and found already a couple of
> > applications that could make the job.
> > 
> > I ask you folks if someone has good experience with a specific one and or
> > what features are included and helpfull and what are not that helpfull.
> > 
> > I really appreciate your contributions.
> > 
> > --
> > 
> > 
> > Best Regards,
> > Sven
> > 
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group. To unsubscribe from this group and stop receiving
> > emails from it, send an email to
> > django-users+unsubscr...@googlegroups.com. To post to this group, send
> > email to django-users@googlegroups.com. Visit this group at
> > http://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/django-users/3688706.24zruyElKd%40gilga
> > mesch. For more options, visit https://groups.google.com/groups/opt_out.
-- 


Best Regards, 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1397870.1xd54BY6e8%40gilgamesch.
For more options, visit https://groups.google.com/groups/opt_out.


Re: text media files for comments

2014-01-14 Thread Sven Aßmann
Hi Fatih,

i would ask myself the question is this static data that not changes 
frequently or is it editable content that should be:

a) maintainable from users (without code updates of course)
b) is maintained independently form software releaes

if one of thoses questions can be answered with yes then i would go for a 
model that stores that texts. So that in fact you only render that stuff within 
a normal view (like blog posts but much more simpler)

if the answer is no: then just include it like css of js files and deliver the 
files with a custom ResponseView that reads the file content and puts it out, 
or 
a specialized template view that skips the parse and processing aspect of 
processing templates.

On Monday 13 January 2014 13:11:55 Fatih Tiryakioglu wrote:
> Hi all,
> 
> I want to render a static media .txt file from django template, but I can't
> load it. Should I use database for text comments, or is it better statatic
> text files like image files in media folder.
> 
> Any help is appreciated.
-- 


Best Regards, 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1711781.vXMkOL7t90%40gilgamesch.
For more options, visit https://groups.google.com/groups/opt_out.


mass email app for django

2014-01-14 Thread Sven Aßmann
Hi Group,

currently i evaluating / research for a django app that supports mailing 
specific texts to a receipient list (like mass emailing). the corner features 
are:

- email text should be editable (text or html nothing special) thru the admin 
app
- the receipient list should be maintainable independently from users and 
texts (like a addressbook that is maintanale thru admin app)
- ideally supports several mail backends like smtp, aws sms, postmark etc..
- processing of the sending can be done async via django cli / message queue 
services 

The closest use case app would be something like a newsletter app, where the 
subscibers can be maintainted apart from django.auth.users
I am aware of www.djangopackages.com and found already a couple of 
applications that could make the job.

I ask you folks if someone has good experience with a specific one and or what 
features are included and helpfull and what are not that helpfull. 

I really appreciate your contributions.

-- 


Best Regards, 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3688706.24zruyElKd%40gilgamesch.
For more options, visit https://groups.google.com/groups/opt_out.


Re: test driven development and mixin for views

2014-01-06 Thread Sven
Hi Arun,

thanks for this advice. I finally came also to the conclusion that the best 
test would be to create (as part of each test case) all possible use case 
szenarios for this mixin class. For instance if it should be utilizable for 
ListView and CreateView then i would create unit tests against those 2 classes 
with an inheritance of that mixin. This should be the only way to quarantee 
the correct behavior of the mixin within a given use case. 

If someone would use the mixin outside of this, let's say for DetailView and 
this was not explicit tested then there is no gurantee that it will still 
behave as expected. That should be fair enought.

Thanks,
Sven

On Monday 06 January 2014 02:08:29 trojactory wrote:
> Hi sassman,
> 
> Since you mentioned TDD, I assume you are talking about unit tests. As with
> any matter in quality control, the more you can test, the better!
> 
> In my opinion, you would need to provide atleast one testcase for each of
> the four CBV views. It is better to create a derived class in each case
> rather than mocking it.
> 
> Regards,
> Arun
> 
> On Monday, January 6, 2014 12:01:30 AM UTC+5:30, sassman wrote:
> > Hi Folks,
> > 
> > i recently wrote some small mixins that are intented to be attached to CBV
> > like ListView, UpdateView, DetailView or even CreateView. The aim is to
> > give
> > users only access to their data. Their in terms of ownership. As an
> > Example
> > you have a Post model were a field called owner is a ForeignKey to
> > 'auth.User'
> > as a basic example.
> > 
> > So the mixin does filtering the queryset and passes an additional
> > parameter to
> > form classes where as an additional form Mixin then passes this down to
> > the
> > model. So far so good. (see http://pastebin.kde.org/pyzrouxfw)
> > 
> > Now my Question:
> > 
> > what would be the best solution to write a dedicated test against this
> > mixin?
> > Would it be good or worth to create some Views loke the 4 above that
> > inherits
> > also the Mixin and then test against this as a complete behaviour? Or
> > better
> > mock it somehow differently?
> > 
> > I really appreaciate your suggestions!!
> > 
> > 
> > 
> > 
> > Best Regards
> > 
> > Sven
-- 


Best Regards, 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2035044.O70feLxhn5%40gilgamesch.
For more options, visit https://groups.google.com/groups/opt_out.


test driven development and mixin for views

2014-01-05 Thread Sven
Hi Folks,

i recently wrote some small mixins that are intented to be attached to CBV 
like ListView, UpdateView, DetailView or even CreateView. The aim is to give 
users only access to their data. Their in terms of ownership. As an Example 
you have a Post model were a field called owner is a ForeignKey to 'auth.User' 
as a basic example.

So the mixin does filtering the queryset and passes an additional parameter to 
form classes where as an additional form Mixin then passes this down to the 
model. So far so good. (see http://pastebin.kde.org/pyzrouxfw)

Now my Question:

what would be the best solution to write a dedicated test against this mixin?
Would it be good or worth to create some Views loke the 4 above that inherits 
also the Mixin and then test against this as a complete behaviour? Or better 
mock it somehow differently? 

I really appreaciate your suggestions!!


-- 


Best Regards
 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6286078.9jIiIkrESd%40gilgamesch.
For more options, visit https://groups.google.com/groups/opt_out.


couchbase as db backend

2013-08-15 Thread Sven
Hi Guys,

has someone of you any experience with the NoSQL db couchbase together with 
django? I mean real practically experience..

Or any good experience with the other famos NoSQL databases and django?

If so, what piece of code will be good to use as Manager for be able to use 
still the django model layer?

-- 


Best Regards
 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django 1.5 runserver hangs in Chrome

2013-07-08 Thread Sven Bröckling

Hi,

Chrome sometimes does really strange things. I use chrome with a 
disabled cache for development (Open Developer Tools, click on the 
settings menu, first option) which resolves this kind of problems for me.


Regards
  Sven


I can confirm this issue. Exactly the same problem here.
Also, while Chrome is spinning, I can open Firefox and load pages
(including the problem page) just fine. So it's not that the server
is overloaded or anything like that...


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




django vagrant template and project start

2013-06-15 Thread Sven
Hi List,

i only want to share with you some boilerplate stuff. Currently developing 
inside of virtualbox is very common, automatically build from vagrant and 
configured by puppet. 
Therefore i created a django project layout that creates all this from 
scratch. very handy.

Check it out and i really appreachiate your feedback!!

https://github.com/sassman/django-vagrant-template

A how to start read me is allready there. If you have question please contact 
me.

-- 


Best Regards
 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Ordering a QuerySet based on a latest child models field

2013-03-01 Thread Sven Grunewaldt


Lets assume I want to show a list of runners ordered by their latest sprint 
time.

class Runner(models.Model):
name = models.CharField(max_length=255)

class Sprint(models.Model):
runner = models.ForeignKey(Runner)
time = models.PositiveIntegerField()
created = models.DateTimeField(auto_now_add=True)


This is a quick sketch of what I would do in SQL:

SELECT runner.id, runner.name, sprint.time
FROM runner
LEFT JOIN sprint ON (sprint.runner_id = runner.id)
WHERE 
  sprint.id = (
SELECT sprint_inner.id
FROM sprint as sprint_inner
WHERE sprint_inner.runner_id = runner.id
ORDER BY sprint_inner.created DESC
LIMIT 1
  )
  OR sprint.id = NULL
ORDER BY sprint.time ASC


The Django QuerySet documentation states:

> It is permissible to specify a multi-valued field to order the results by 
> (for example, a ManyToManyField field). Normally this won’t be a sensible 
> thing to do and it’s really an advanced usage feature. However, if you know 
> that your queryset’s filtering or available data implies that there will 
> only be one ordering piece of data for each of the main items you are 
> selecting, the ordering may well be exactly what you want to do. Use 
> ordering on multi-valued fields with care and make sure the results are 
> what you expect.

 

I guess I need to apply some filter here, but I'm not sure what exactly 
Django expects...

One note because it is not obvious in this example: the Runner table will 
have several hundred entries, the sprints will also have several hundreds 
and in some later days probably several thousand entries. The data will be 
displayed in a paginated view, so sorting in Python is not an option.

The only other possibility I see is writing the SQL myself, but I'd like to 
avoid this at all cost.

PS: This is a copy of my StackOverflow 
question: http://stackoverflow.com/q/15154863/360593

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




django git repository management app

2012-12-31 Thread Sven
Hi Guys,

a while ago i was looking for a django app that allows me to manage git 
repositories like gitosis, gitweb or at least github. But simple and well 
integrated with django. Finally i found nothing. 

Then the idea for gitana was born. A git repository management applicaiton for 
django integrated with admin app. 

Now i'm happy to announce version 1.0.0  it is opensource and you can find it 
on github  https://github.com/lubico-business/django-gitana

I very appreciate all comments, suggestions and all kind of feedback.

happy new year!

BR Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to run a django app in a subdirectory alias

2012-06-29 Thread Sven Grunewaldt
Hi,

I want to run a simple test project in a subdirectory alias on our 
development server. The basic setup is an nginx with a location that passes 
everything in a subdirectory to the wsgi application.

Django obviously does not understand that it runs in an subdirectory alias, 
which completely destroys URL generation and parsing.
I could not find any prefix-like setting in the docs and my google fu also 
did not help that much... so I'm asking here instead.

The only thing I *did* find was the setting FORCE_SCRIPT_NAME which at 
least fixes the URL generation. (see: 
http://docs.webfaction.com/software/django/config.html#mounting-a-django-application-on-a-subpath
)
Sadly this does not fix the urlconf parsing, even though the mentioned site 
suggests that.

Is it possible to run a django application in a subdirectory alias and if 
so, how?

Thanks,
Sven

PS:
nginx config:
server {
location /fancyprojectname/static {
alias /srv/fancyprojectname/static;
}

location /fancyprojectname/ {
uwsgi_pass unix://var/run/uwsgi/app/fancyprojectname/socket;
include uwsgi_params;
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/DiyOjDLvUroJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



modelForm validation -> model validation -> trigger field validation?

2012-01-25 Thread Sven
hi there,

has anyone of you an idea in which cycle the field method of 
ForeignKey.validate is triggered?

I have a custom ForeignKey Field where i override the validate method.
So i expect that 

ModelForm validation triggers 
-> Model validation (clean methods) and this triggers
-> Field validation of all contained fields

But this seems not be the case. Has anyone of you an idea?


-- 


Best Regards
 
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Form Field: BoundField question

2012-01-05 Thread Sven
Hi Tom, 

thanks for the link, in case of 'datetime.date.today' the callable makes a lot 
of sense. 

I changed my class field so that the value is not more a class definition, now 
it is wrapped by some kind of a proxy instance to avoid the callable effect.


-- 


Best Regards
 
Sven

On Thursday 05 January 2012 10:20:37 Tom Evans wrote:
> On Wed, Jan 4, 2012 at 5:25 PM, sassman  wrote:
> > Hi,
> > 
> > i'm using Django Version 1.3.1, can anyone say me why is the value
> > function in BoundField (FormField) makes a check if the value is
> > callable?
> > 
> >def value(self):
> >"""
> >Returns the value for this BoundField, using the initial value
> > if
> >the form is not bound or the data otherwise.
> >"""
> >if not self.form.is_bound:
> >data = self.form.initial.get(self.name,
> > self.field.initial)
> >if callable(data):
> >data = data()
> > 
> > 
> > I have a Field that encapsulates a Python Class, and this leads into a
> > problem because the value (a class definition) will be instatiated at
> > this time. But for a Dropdown field (wrapped by the TypedChoiceField
> > Field) this is not a neccessary action.
> > 
> > Can anyone say me what is the reason for having a datavalue callable
> > and call it on a field?
> > 
> > BR Sven
> 
> It is documented here:
> 
> https://docs.djangoproject.com/en/1.3/ref/forms/fields/#django.forms.Field.i
> nitial
> 
> Cheers
> 
> Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is there a tool to check which views are used?

2011-01-27 Thread Sven Broeckling
Hi,

> I have inherited an old project which I believe has unused views
> (useless code), does anyone know of a tool to check which views are
> being used? I think it shouldn't be too hard to make one using resolve
> but maybe there is one already or maybe I'm talking nonsense.
> It doesn't have tests, so I can't check the coverage or find data
> from there.
The django-extensions
(https://github.com/django-extensions/django-extensions) app provide a
command to get all urls from a project, maybe that is a good starting
point : 

./manage.py show_urls

hth
  Sven

-- 
http://djangopeople.net/thejester/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to turn off CSRF in django 1.2?

2010-08-26 Thread Sven Bröckling
Hi Alan,

> I developed in a system that uses django 1.2, but the server is still
> django 1.0.2.
> Upgrading for a moment is not possible. Unless someone knows a nice
> simple alternative, in order to keep my web portal compatible between
> 1.0.2 and 1.2, I would like to switch off CSRF on my developing
> computer.
> How can I do this simply and easily?
I have one project which has several issues with django 1.2, and so i
use 1.1 for that, 1.2 for other projects.

I have two versions of Django in my home dir, both svn checkouts. I need
only one version at a time, so i wrote two quick and dirty shell aliases
to switch the django version.

[s...@troy sven] which django1.1
django1.1: aliased to sudo rm -f
/usr/lib/python2.6/dist-packages/django; sudo ln -s
/home/sven/projects/programming/python/django/django-1.1/django
/usr/lib/python2.6/dist-packages/

[s...@troy sven] which django1.2
django1.2: aliased to sudo rm -f
/usr/lib/python2.6/dist-packages/django; sudo ln -s
/home/sven/projects/programming/python/django/django-trunk/django
/usr/lib/python2.6/dist-packages/

Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Python Segfaults with Django 1.1

2010-08-05 Thread Sven Broeckling
> > I got another clue, it seems that the python process runs out of
> > file handles. After 10k requests (via ab -c 1 -n 1) i got
> > several "not found" io exceptions like "/dev/urandom not found",
> > TemplateError: Template xy not found and this one : Error Opening
> > file /path/to/geoip/GeoIP.dat
> > Maybe that is why the mod_python setup runs fine, due to the restart
> > for each request.
> Also make sure you aren't still loading mod_python into Apache if
> using mod_wsgi as the presence of mod_python can in some cases cause
> mod_wsgi to misbehave.
No, mod_python is deactivated, but the file descriptor leak was imho
the problem.. 

The Fix, for the record :)

--- a/apps/catalog/templatetags/composedimage.py
+++ b/apps/catalog/templatetags/composedimage.py
@@ -105,7 +105,7 @@ class ComposedImage(object):
 def _open_svg_as_image(self, fn, width, height, position, factor,
offset): import cairo
 import rsvg
-file = tempfile.mkstemp(suffix='.png', prefix='tmc_svg_')[1]
+fd,file = tempfile.mkstemp(suffix='.png', prefix='tmc_svg_')
 fn = smart_str(fn)
 svg = rsvg.Handle(file=fn)
 
@@ -123,7 +123,10 @@ class ComposedImage(object):
 surface.write_to_png(file)
 image = Image.open(file, "r")
 image.convert("RGBA")
+
+os.close(fd)
 os.unlink(file)

Thanks,
  Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



[solved] Re: Python Segfaults with Django 1.1

2010-08-05 Thread Sven Broeckling
> > I got another clue, it seems that the python process runs out of
> > file handles. After 10k requests (via ab -c 1 -n 1) i got
> > several "not found" io exceptions like "/dev/urandom not found",
> Some tempfile that isn't getting closed? Watch your /tmp size, for 
> instance. Normally if you do it from views or so, the tempfile object 
> gets garbage collected and closed.
> Anyway, you probably already know where to look :-)
That was exactly the right point i guess. I was caught by this one :
http://bugs.python.org/issue6875
After adding os.close(fd) to an svg -> png Function the App doesn't
leak file descriptors any more. 

In about 30k Requests i know if it was the cause for the segfaults :)

Thanks Reinout :)
  Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Python Segfaults with Django 1.1

2010-08-05 Thread Sven Broeckling
> > i have a problem on a debian lenny machine which is not easy to
> > track down. It started with Apache2 mod_wsgi crashes (segfault in
> > libapr) after the migration from mod_python. The server crashes
> > sporadic and everytime with another view called, but everytime
> > after a while (2-7 Days, depending on traffic).
> Probably not related, but you never know... I've seen this happen in
> ye olde days with a zope server that you'd start in daemon mode from
> the terminal.  After 2-4 days the terminal would die and suddenly the 
> perfectly-running zope server would have nowhere to print its console 
> output once an infrequent error occured. And it would die.
> The wsgi stuff works differently, so this shouldn't be the problem. 
> Mentioning it anyway, perhaps it rings some distant bell :-)

I got another clue, it seems that the python process runs out of file
handles. After 10k requests (via ab -c 1 -n 1) i got several "not
found" io exceptions like "/dev/urandom not found", TemplateError:
Template xy not found and this one : Error Opening
file /path/to/geoip/GeoIP.dat

Maybe that is why the mod_python setup runs fine, due to the restart
for each request. 

Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Python Segfaults with Django 1.1

2010-08-05 Thread Sven Broeckling
Hi,

i have a problem on a debian lenny machine which is not easy to track
down. It started with Apache2 mod_wsgi crashes (segfault in libapr)
after the migration from mod_python. The server crashes sporadic and
everytime with another view called, but everytime after a while (2-7
Days, depending on traffic). 

I set up a lighttpd/fastcgi/runfcgi Setup to avoid this, but now
segfaults python, imho for the same reason.

Is there any "right" way to find the reason for the segfaults beyond
letting strace dump 100s of megs of Log for a Week? We habe
dependencies to libcairo (python-cairo), librsvg, geoip and memcache,
so maybe the segfault happens in there. 

This is the Kernel log for the apache crashes : 

messages.2.gz:Jul 24 22:10:58 vshop kernel: [7816643.903087]
apache2[4686]: segfault at 28 ip 7f6f8f4c2f04 sp 7f6f84043d40 error 4
in libapr-1.so.0.2.12[7f6f8f49f000+32000] messages.2.gz:Jul 24 22:13:50
vshop kernel: [7816817.795137] apache2[4700]: segfault at 28 ip
7f6f8f4c2f04 sp 7f6f7f83ad40 error 4 in
libapr-1.so.0.2.12[7f6f8f49f000+32000] messages.4.gz:Jul  4 21:49:00
vshop kernel: [6079995.222199] apache2[7564]: segfault at 28 ip
7f98f256e655 sp 7f98e310bd40 error 4 in
libapr-1.so.0.2.12[7f98f254b000+32000] messages.4.gz:Jul  6 04:58:35
vshop kernel: [6192612.659789] apache2[10605]: segfault at 28 ip
7fae92380655 sp 7fae85f23d40 error 4 in
libapr-1.so.0.2.12[7fae9235d000+32000] messages.4.gz:Jul  6 04:58:35
vshop kernel: [6192612.701478] apache2[10565]: segfault at 28 ip
7fae92380655 sp 7fae86724d40 error 4 in
libapr-1.so.0.2.12[7fae9235d000+32000] messages.4.gz:Jul  7 04:31:08
vshop kernel: [6277733.106236] apache2[4798]: segfault at 28 ip
7f2c8d6dff04 sp 7f2c84a89d40 error 4 in
libapr-1.so.0.2.12[7f2c8d6bc000+32000] messages.4.gz:Jul  7 04:32:41
vshop kernel: [6277825.802407] apache2[4855]: segfault at 28 ip
7f2c8d6dff04 sp 7f2c84288d40 error 4 in
libapr-1.so.0.2.12[7f2c8d6bc000+32000]

Thanks in advance for any hint :) 
  Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Why not Django with FastCGI?

2010-04-20 Thread Sven Svenson
I'm new to the Django world but it seems that FastCGI is not the
preferred way to deploy a Django application. Why is that? I've had
good success using FastCGI with Perl/Catalyst-based applications.

Thanks.

/sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Different model behaviour in template tag and python shell?

2010-04-13 Thread Sven Richter
Haha, just like always, short after mailing it flashed to my mind.
I named the class Business the same like the model Business, which of
course, clashes with each other.

Greetings
Sven

On Tue, Apr 13, 2010 at 11:09 PM, Sven Richter  wrote:
> Hi everybody,
>
> i have some problem i just dont understand. I have a business model
> (derived from django namespace):
> class Business(models.Model):
>    business = models.ForeignKey("self", related_name="other_business")
>    name = models.CharField(max_length=50, unique=True)
> ...
>    objects = BusinessModelManager()
>
> and:
>
> class BusinessModelManager(models.Manager):
>    def user_can_access(self, user):
>        if user.is_superuser:
>            return super(BusinessModelManager, self).get_query_set()
>        else:
>            return super(BusinessModelManager,
> self).get_query_set().filter( Q(business__groups=user.groups.all()) |
> Q(business__users=user) )
>
> Now when i go ahead into django shell and do:
> from eiwomisa.business.models import Business
> Business.objects.all()
>
> it returns the expected output, the Business objects.
>
> But, i have a templatetag:
>
> class Business(Node):
>    def __init__(self, context, user):
>        self.context = context
>        self.user = template.Variable(user)
>
>    def render(self, context):
>        user = self.user.resolve(context)
>        business = Business.objects.all()
>        #context[self.context] = business
>        #context[self.context] = 'nd'
>        return ''
>
> def get_business(parser, token):
>    bits = token.contents.split()
>
>    return Business(bits[2], bits[3])
> register.tag('get_business', get_business)
>
> Which should do the same, but it throws the following error:
> -
> TemplateSyntaxError at /admin/time_tracking/timetracking/
>
> Caught an exception while rendering: type object 'Business' has no
> attribute 'objects'
>
> Original Traceback (most recent call last):
>  File "/usr/lib/python2.6/site-packages/django/template/debug.py",
> line 71, in render_node
>    result = node.render(context)
>  File "/usr/lib/python2.6/site-packages/django/template/defaulttags.py",
> line 155, in render
>    nodelist.append(node.render(context))
>  File 
> "/home/sveri/programmierprojekte/eiwomisa/eiwomisa/../eiwomisa/project/time_tracking/templatetags/tags.py",
> line 49, in render
>    business = Business.objects.all()
> AttributeError: type object 'Business' has no attribute 'objects'
>
> Request Method:         GET
> Request URL:    http://localhost:8000/admin/time_tracking/timetracking/?e=1
> Exception Type:         TemplateSyntaxError
> Exception Value:
>
> Caught an exception while rendering: type object 'Business' has no
> attribute 'objects'
>
> Original Traceback (most recent call last):
>  File "/usr/lib/python2.6/site-packages/django/template/debug.py",
> line 71, in render_node
>    result = node.render(context)
>  File "/usr/lib/python2.6/site-packages/django/template/defaulttags.py",
> line 155, in render
>    nodelist.append(node.render(context))
>  File 
> "/home/sveri/programmierprojekte/eiwomisa/eiwomisa/../eiwomisa/project/time_tracking/templatetags/tags.py",
> line 49, in render
>    business = Business.objects.all()
> AttributeError: type object 'Business' has no attribute 'objects'
> -
>
> Hm, thats something thats completely out of my mind, i mean, its the
> same call, but it cannot get executed? Why is that?
>
>
> Greetings and thanks in Advance
> Sven
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Different model behaviour in template tag and python shell?

2010-04-13 Thread Sven Richter
Hi everybody,

i have some problem i just dont understand. I have a business model
(derived from django namespace):
class Business(models.Model):
business = models.ForeignKey("self", related_name="other_business")
name = models.CharField(max_length=50, unique=True)
...
objects = BusinessModelManager()

and:

class BusinessModelManager(models.Manager):
def user_can_access(self, user):
if user.is_superuser:
return super(BusinessModelManager, self).get_query_set()
else:
return super(BusinessModelManager,
self).get_query_set().filter( Q(business__groups=user.groups.all()) |
Q(business__users=user) )

Now when i go ahead into django shell and do:
from eiwomisa.business.models import Business
Business.objects.all()

it returns the expected output, the Business objects.

But, i have a templatetag:

class Business(Node):
def __init__(self, context, user):
self.context = context
self.user = template.Variable(user)

def render(self, context):
user = self.user.resolve(context)
business = Business.objects.all()
#context[self.context] = business
#context[self.context] = 'nd'
return ''

def get_business(parser, token):
bits = token.contents.split()

return Business(bits[2], bits[3])
register.tag('get_business', get_business)

Which should do the same, but it throws the following error:
-
TemplateSyntaxError at /admin/time_tracking/timetracking/

Caught an exception while rendering: type object 'Business' has no
attribute 'objects'

Original Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/django/template/debug.py",
line 71, in render_node
result = node.render(context)
  File "/usr/lib/python2.6/site-packages/django/template/defaulttags.py",
line 155, in render
nodelist.append(node.render(context))
  File 
"/home/sveri/programmierprojekte/eiwomisa/eiwomisa/../eiwomisa/project/time_tracking/templatetags/tags.py",
line 49, in render
business = Business.objects.all()
AttributeError: type object 'Business' has no attribute 'objects'

Request Method: GET
Request URL:http://localhost:8000/admin/time_tracking/timetracking/?e=1
Exception Type: TemplateSyntaxError
Exception Value:

Caught an exception while rendering: type object 'Business' has no
attribute 'objects'

Original Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/django/template/debug.py",
line 71, in render_node
result = node.render(context)
  File "/usr/lib/python2.6/site-packages/django/template/defaulttags.py",
line 155, in render
nodelist.append(node.render(context))
  File 
"/home/sveri/programmierprojekte/eiwomisa/eiwomisa/../eiwomisa/project/time_tracking/templatetags/tags.py",
line 49, in render
business = Business.objects.all()
AttributeError: type object 'Business' has no attribute 'objects'
-

Hm, thats something thats completely out of my mind, i mean, its the
same call, but it cannot get executed? Why is that?


Greetings and thanks in Advance
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
Shame on me. The problem was that i mixed SimpleDocTemplate (which the
examples were based on), with BaseDocTemplate, which i used. And
BaseDocTemplate needs an extra PageTemplate defined. So this code
basically works:

def generate_pdf(request):
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'
template = PageTemplate('normal',  [Frame(2.5*cm, 2.5*cm, 15*cm,
25*cm, id='F1')])
doc = BaseDocTemplate(filename=response,pagesize=A4,pageTemplates=template)

styles = getSampleStyleSheet()

Document = [Paragraph('rd', styles["Title"])]
Document.append(Spacer(1,50))

    doc.build(Document)

return response

Thanks all for the help!
Sven

On Wed, Mar 31, 2010 at 12:23 AM, Sven Richter  wrote:
> Hm, what makes me wonder is this one:
> IndexError at /office/job//admin/job/offer/generate/pdf/
> This is a url that is not accessible, cause it does not exist, at
> least i never defined it in any urls.py.
> Maybe thats the problem? Django tries to access a url which doesnt exist?
>
>
> Greetings
> Sven
>
> On Tue, Mar 30, 2010 at 10:55 PM, Sven Richter  wrote:
>> On Tue, Mar 30, 2010 at 9:08 PM, Paulo Almeida
>>  wrote:
>>> Ok, that is not easy to debug with so little information. Is the IndexError
>>> in views.py? Maybe there is a mistake in urls.py, caused by adding the url
>>> for the generate_pdf view?
>>
>> Hm, its indeed hard. I really dont know what that Error will tell me.
>> My Application is a very basic one. Up to now i do everything in the
>> admin interface. The only url defined is the one to view the pdf file:
>>
>> urls.py:
>> urlpatterns = patterns('',
>>    # Example:
>>    # (r'^eiwomisa/', include('eiwomisa.foo.urls')),
>>
>>    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
>>    # to INSTALLED_APPS to enable admin documentation:
>>    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>
>>    # Uncomment the next line to enable the admin:
>>    (r'^admin/', include(admin.site.urls)),
>>    (r'^project/task/', include('project.task.urls')),
>>    (r'^office/job/', include('office.job.urls')),
>> )
>>
>> offic/job/urls.py:
>>
>> from django.conf.urls.defaults import *
>>
>> urlpatterns = patterns('office.job.views',
>>    (r'/offer/generate/pdf/$', 'generate_pdf', '',
>> 'office_job_generate_offer_pdf'),
>> )
>>
>> and here is my views.py:
>>
>> def generate_pdf(request):
>>    response = HttpResponse(mimetype='application/pdf')
>>    response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'
>>
>>    doc = BaseDocTemplate(filename=response,pagesize=A4)
>>    styles = getSampleStyleSheet()
>>    Document = [Paragraph('rd', styles["Title"])]
>>    Document.append(Spacer(1,50))
>>    date_now = unicode(datetime.now().strftime("%B %d, %Y"))
>>    Document.append(Paragraph("PDF created on " + date_now, styles["Normal"]))
>>    Document.append(Spacer(1,10))
>>    doc.build(Document)
>>
>> I have tried the same "setup" with the canvas.Canvas example from the
>> django documentation, and it worked. All i changed here is from canvas
>> to document.
>>
>> Greetings
>> Sven
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
Hm, what makes me wonder is this one:
IndexError at /office/job//admin/job/offer/generate/pdf/
This is a url that is not accessible, cause it does not exist, at
least i never defined it in any urls.py.
Maybe thats the problem? Django tries to access a url which doesnt exist?


Greetings
Sven

On Tue, Mar 30, 2010 at 10:55 PM, Sven Richter  wrote:
> On Tue, Mar 30, 2010 at 9:08 PM, Paulo Almeida
>  wrote:
>> Ok, that is not easy to debug with so little information. Is the IndexError
>> in views.py? Maybe there is a mistake in urls.py, caused by adding the url
>> for the generate_pdf view?
>
> Hm, its indeed hard. I really dont know what that Error will tell me.
> My Application is a very basic one. Up to now i do everything in the
> admin interface. The only url defined is the one to view the pdf file:
>
> urls.py:
> urlpatterns = patterns('',
>    # Example:
>    # (r'^eiwomisa/', include('eiwomisa.foo.urls')),
>
>    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
>    # to INSTALLED_APPS to enable admin documentation:
>    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
>    # Uncomment the next line to enable the admin:
>    (r'^admin/', include(admin.site.urls)),
>    (r'^project/task/', include('project.task.urls')),
>    (r'^office/job/', include('office.job.urls')),
> )
>
> offic/job/urls.py:
>
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('office.job.views',
>    (r'/offer/generate/pdf/$', 'generate_pdf', '',
> 'office_job_generate_offer_pdf'),
> )
>
> and here is my views.py:
>
> def generate_pdf(request):
>    response = HttpResponse(mimetype='application/pdf')
>    response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'
>
>    doc = BaseDocTemplate(filename=response,pagesize=A4)
>    styles = getSampleStyleSheet()
>    Document = [Paragraph('rd', styles["Title"])]
>    Document.append(Spacer(1,50))
>    date_now = unicode(datetime.now().strftime("%B %d, %Y"))
>    Document.append(Paragraph("PDF created on " + date_now, styles["Normal"]))
>    Document.append(Spacer(1,10))
>    doc.build(Document)
>
> I have tried the same "setup" with the canvas.Canvas example from the
> django documentation, and it worked. All i changed here is from canvas
> to document.
>
> Greetings
> Sven
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
On Tue, Mar 30, 2010 at 9:08 PM, Paulo Almeida
 wrote:
> Ok, that is not easy to debug with so little information. Is the IndexError
> in views.py? Maybe there is a mistake in urls.py, caused by adding the url
> for the generate_pdf view?

Hm, its indeed hard. I really dont know what that Error will tell me.
My Application is a very basic one. Up to now i do everything in the
admin interface. The only url defined is the one to view the pdf file:

urls.py:
urlpatterns = patterns('',
# Example:
# (r'^eiwomisa/', include('eiwomisa.foo.urls')),

# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
(r'^project/task/', include('project.task.urls')),
(r'^office/job/', include('office.job.urls')),
)

offic/job/urls.py:

from django.conf.urls.defaults import *

urlpatterns = patterns('office.job.views',
(r'/offer/generate/pdf/$', 'generate_pdf', '',
'office_job_generate_offer_pdf'),
)

and here is my views.py:

def generate_pdf(request):
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'

doc = BaseDocTemplate(filename=response,pagesize=A4)
styles = getSampleStyleSheet()
Document = [Paragraph('rd', styles["Title"])]
Document.append(Spacer(1,50))
date_now = unicode(datetime.now().strftime("%B %d, %Y"))
Document.append(Paragraph("PDF created on " + date_now, styles["Normal"]))
Document.append(Spacer(1,10))
doc.build(Document)

I have tried the same "setup" with the canvas.Canvas example from the
django documentation, and it worked. All i changed here is from canvas
to document.

Greetings
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
On Tue, Mar 30, 2010 at 8:21 PM, palmeida  wrote:
> Is that all your code? I don't see a line like this (from my
> generate_pdf function):
>
> doc = SimpleDocTemplate(response, pagesize=A4)
I missed that one out of my example. You're right.

But it doesnt generate a pdf like that, it just complains about that IndexError.


Greetings
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
Great, thank you very much, this got me started. However, its not
working yet. This is the code i have right now:

def generate_pdf(request):
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'
styles = getSampleStyleSheet()
Document = [Paragraph('rd', styles["Title"])]
Document.append(Spacer(1,50))
date_now = unicode(datetime.now().strftime("%B %d, %Y"))
Document.append(Paragraph("PDF created on " + date_now, styles["Normal"]))
Document.append(Spacer(1,10))
doc.build(Document)
return response

But instead of showing the pdf i get the error:

Exception Type: IndexError
Exception Value:list index out of range

I cannot imagine what may be wrong there? From my point of view it
should work like that?


Greetings
Sven


On Tue, Mar 30, 2010 at 6:56 PM, Paulo Almeida
 wrote:
> I'm using Platypus (part of reportlab) to generate pdfs without
> micromanagement of Canvas elements. reportlab's documentation was very
> helpful to learn how to work with Paragraph, Table, Image, etc. Some code:
> # views.py
> @login_required
> def view_pdf(request, experiment_id):
>     experiment =
> get_object_or_404(Experiment.objects.filter(pk=experiment_id))
>     response = HttpResponse(mimetype='application/pdf')
>     filename = slugify(experiment.title) + '.pdf'
>     response['Content-Disposition'] = 'filename=' + filename
>     generate_pdf([experiment], response)
>     return response
> # functions.py
> def generate_pdf(experiments, output):
>     doc = SimpleDocTemplate(output, pagesize=A4)
>     Document = []
>     for experiment in experiments:
>         Document.extend(pdf_elements(experiment))
>     doc.build(Document)
> pdf_elements is a function that adds bits and pieces... This is just an
> excerpt:
> def pdf_elements(experiment):
>     styles = getSampleStyleSheet()
>     Document = [Paragraph(escape(experiment.title), styles["Title"])]
>     Document.append(Spacer(1,50))
>     date = unicode(experiment.date.strftime("%B %d, %Y"))
>     Document.append(Paragraph("Acquired on " + date, styles["Normal"]))
>     date_now = unicode(datetime.now().strftime("%B %d, %Y"))
>     Document.append(Paragraph("PDF created on " + date_now,
> styles["Normal"]))
>     Document.append(Spacer(1,10))
>     return Document
> Read the Platypus documentation for many more elements and options.
> These are my reportlab imports:
> from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer,
> TableStyle
> from reportlab.platypus import KeepTogether
> from reportlab.platypus import Table as Platypus_Table
> from reportlab.platypus import Image as Platypus_Image
> from reportlab.lib import colors
> from reportlab.lib.pagesizes import A4
> from reportlab.lib.styles import getSampleStyleSheet
> - Paulo
>
> On Tue, Mar 30, 2010 at 5:08 PM, Sven Richter 
> wrote:
>>
>> Hi everybody,
>>
>> i am looking for a way to get BaseDocTemplate from the reportlab
>> library working, connected with a httpresponse.
>> I found the documentation for a simple reportlab page, using canvas.
>> But to me it seems, that i need more options than basic Canvas offers.
>> Like a page header or footer, tables continuing over pages etc.
>> I have not found a working example to use httpresponse:
>>
>> response = HttpResponse(mimetype='application/pdf')
>> response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'
>>
>> in conjunction with:
>>
>> BaseDocTemplate('basedoc.pdf',showBoundary=1)
>>
>> So if somebody could provide some working code, or a hint to
>> repository or an application with some working code, i'd really
>> appreciate that.
>>
>>
>> Greetings
>> Sven
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django, reportlab and basedoctemplate | simpledoctemplate

2010-03-30 Thread Sven Richter
Hi everybody,

i am looking for a way to get BaseDocTemplate from the reportlab
library working, connected with a httpresponse.
I found the documentation for a simple reportlab page, using canvas.
But to me it seems, that i need more options than basic Canvas offers.
Like a page header or footer, tables continuing over pages etc.
I have not found a working example to use httpresponse:

response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'

in conjunction with:

BaseDocTemplate('basedoc.pdf',showBoundary=1)

So if somebody could provide some working code, or a hint to
repository or an application with some working code, i'd really
appreciate that.


Greetings
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: extend admin interface - chang_list_results.html

2010-03-27 Thread Sven Richter
Thank you very much. Do you know if there is something planned for
future releases?


Greetings
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: extend admin interface - chang_list_results.html

2010-03-26 Thread Sven Richter
Ok, just for Information, i found the answer myself. In the django
docs it is said:
"Some of the admin templates, such as change_list_request.html are
used to render custom inclusion tags. These may be overridden, but in
such cases you are probably better off creating your own version of
the tag in question and giving it a different name. That way you can
use it selectively."

So, i'm gonna do it myself.

Greetings
Sven

On Fri, Mar 26, 2010 at 7:24 PM, Sven Richter  wrote:
> Hi,
>
> i am about to extend the admin interface and came to the following problem.
> I want to add some information to the overview of an application
> model. Now, i look in the change_list.html and see that the {%
> result_list cl %}   template tag is the one i need to adapt.
> Now, when i look in the templatetags.py i see the link to
> register.inclusion_tag("admin/change_list_results.html") and finally
> found the template i need to adapt.
>
> But the problem is, the path is hardcoded. So i have to put
> change_list_results.html in "templates/admin" path to get it used
> instead of "templates/app/model/" path.
>
> That of course is not very useful, cause the template will be used for
> every app instead for the one i want to adapt.
>
> How do i get around that? Is there a standard way for doing these things?
>
>
> Greetings
> Sven
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



extend admin interface - chang_list_results.html

2010-03-26 Thread Sven Richter
Hi,

i am about to extend the admin interface and came to the following problem.
I want to add some information to the overview of an application
model. Now, i look in the change_list.html and see that the {%
result_list cl %}   template tag is the one i need to adapt.
Now, when i look in the templatetags.py i see the link to
register.inclusion_tag("admin/change_list_results.html") and finally
found the template i need to adapt.

But the problem is, the path is hardcoded. So i have to put
change_list_results.html in "templates/admin" path to get it used
instead of "templates/app/model/" path.

That of course is not very useful, cause the template will be used for
every app instead for the one i want to adapt.

How do i get around that? Is there a standard way for doing these things?


Greetings
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: admin user, groups unregister deleted applications?

2010-03-23 Thread Sven Richter
On Tue, Mar 23, 2010 at 10:10 AM, Grigory Javadyan  wrote:
> On 03/23/2010 12:53 PM, Sven Richter wrote:
>>
>> Hi,
>>
>> i just mentioned that in the admin interface, in the user and groups
>> section i still can see all the applications i once installed, but
>> that are deleted now from my project. How can i get rid of them?
>>
>
> Are you sure you removed them from the INSTALLED_APPS setting in your
> project's config file?

Yes, i am sure and i just checked it once more. They are removed from
the INSTALLED_APPS setting, and one doesnt even exist anymore on my
harddrive.


Greetings
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



admin user, groups unregister deleted applications?

2010-03-23 Thread Sven Richter
Hi,

i just mentioned that in the admin interface, in the user and groups
section i still can see all the applications i once installed, but
that are deleted now from my project. How can i get rid of them?


Greetings
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Permissions for groups and users

2010-03-23 Thread Sven Richter
Hi Tim,

On Tue, Mar 23, 2010 at 1:03 AM, Tim Shaffer  wrote:
> Ah, yes I see the problem. Good catch. I hadn't tested that
> functionality. Luckily it is a simple change to admin.py. It's a
> matter of removing line 25:
>
once again, thanks for the good work. Now it works perfectly. You did
a great job with that small app :-)

Have a nice day
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Permissions for groups and users

2010-03-22 Thread Sven Richter
Hi Tim,

I just tried your app and, wow, this is exactly what i was looking
for. It works instantly, but, as always, there must be a but.
One thing doesnt work. I did all as you said, and, like i wrote, it
worked out of the box, except my ForeignKeys.

In my example i have:
class Task(NamespacedModel):
   name = models.CharField(max_length = 250)
   parent_task = models.ForeignKey('self',  related_name='Parent
Task',  blank=True,  null=True)

Now, when a user from GroupA with Namespace A accesses the tasks it
only sees the tasks from namespace a. But, if he wants to add a new
task, he can choose tasks from other namespaces as parent tasks.

I tried that with a different model combination, with the same result.
As soon as a model refers to a foreignkey the user is able to choose
from ever other namespace.
Can that be resolved somehow?


Greetings and thanks
Sven

On Mon, Mar 22, 2010 at 10:31 PM, Tim Shaffer  wrote:
> Django doesn't support that out of the box. I searched and couldn't
> find anything. Self plug: I created an app that does exactly this.
>
> http://code.google.com/p/django-namespace/
>
> Only difference is I called the model Namespace instead of Domain.
> Just download it, then add it to your INSTALLED_APPS.
>
> You can then create different Namespaces in the admin, and give either
> users or groups access to them. Then their builtin django privileges
> apply only to those namespaces.
>
> Then for any model that needs to be in a domain/namespace, subclass
> the NamespacedModel like so. Basically this just adds a foreign key to
> the Namespace model.
>
> from django_namespace.namespace.models import NamespacedModel
>
> class Task(NamespacedModel):
>    name = models.CharField(max_length = 250)
>    parent_task = models.ForeignKey('self',  related_name='Parent
> Task',  blank=True,  null=True)
>
> Then when you register the model for the admin, use the
> NamespacedAdmin class (or you can subclass it). This takes care of
> making sure users in DomainA can only see/edit/delete tasks in that
> domain.
>
> from django_namespace.namespace.admin import NamespacedAdmin
>
> admin.site.register(Task, NamespacedAdmin)
>
> See the usage for some examples. I think it's pretty straight forward
> if you're familiar with Django. I've been using it in an internal
> project with great success.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Permissions for groups and users

2010-03-22 Thread Sven Richter
Hi,

this might be offtopic, so i excuse for that in advance, but i dont
know a better place to ask for it, cause its not completely offtopic
at all.

Let's start with what i want to achieve. I am building some sort of a
groupware, and i want it to fully support different domains, and with
it different users.
So lets say i have a simple model Domain, and a model Tasks:
class Domain(models.Model):
domain = models.CharField(max_length=250)

class Task(models.Model):
name = models.CharField(max_length = 250)
parent_task = models.ForeignKey('self',  related_name='Parent
Task',  blank=True,  null=True)
domain = models.ForeignKey(Domain)

Now i create two domains DomainA and DomainB and with it two groups
GroupA and GroupB with some users for each. GroupA shall be allowed to
add new tasks to DomainA and the same goes for GroupA (add tasks only
in DomainA).

Can i achieve that with the given permission (users and groups) system
of django or do i have to extent the user and groups models from
django?


Greetings
Sven

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: convert mysql database to django model

2010-02-27 Thread Sven Richter
Wow, this is cool. Django is so cool! I love it more and more every day!


Greetings and thanks
Sven

On Sat, Feb 27, 2010 at 11:49 AM, rebus_  wrote:
> On 27 February 2010 11:46, Sven Richter  wrote:
>> Hi everybody,
>>
>> i am wondering if there is a tool which converts existing mysql
>> databases with table structure into a django model?
>>
>>
>> Greetings
>> Sven Richter
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
> http://docs.djangoproject.com/en/dev/ref/django-admin/#inspectdb
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Sven Richter
Dipl.-Inf. (FH)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



convert mysql database to django model

2010-02-27 Thread Sven Richter
Hi everybody,

i am wondering if there is a tool which converts existing mysql
databases with table structure into a django model?


Greetings
Sven Richter

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [solved] admin interface, nginx and fawps

2009-09-15 Thread Sven Richter
I solved the problem myself.
I had to set the SESSION_COOKIE_DOMAIN = '.domain.de' and delete the old
cookie then everything worked as it should.


Greetings
Sven

On Mon, Sep 14, 2009 at 3:33 PM, Sven Richter wrote:

> Hi all,
> i am running a django project with fapws (
> http://github.com/william-os4y/fapws3) as server managed through nginx as
> webserver (nginx just forwards to the running fapws instance).
> Fapws deploys the django project as wsgi app.
>
> Now i have a weird problem, i am using the admin interface very often and
> everytime i logout and try to relog into the interface i have to restart the
> fapws instance.
> If i dont restart it i get the following error:
> 1. 502 Bad Gateway message from nginx and
> 2. if i return to the login screen it shows me that my browser wont accept
> cookies and that i should enable them.
>
> Before i ran the project as scgi application managed by cherokee (another
> small webserver) and everything worked without problems.
>
> Any ideas?
>
>
> Greetings and thanks in advance
> Sven
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



admin interface, nginx and fawps

2009-09-14 Thread Sven Richter
Hi all,
i am running a django project with fapws (
http://github.com/william-os4y/fapws3) as server managed through nginx as
webserver (nginx just forwards to the running fapws instance).
Fapws deploys the django project as wsgi app.

Now i have a weird problem, i am using the admin interface very often and
everytime i logout and try to relog into the interface i have to restart the
fapws instance.
If i dont restart it i get the following error:
1. 502 Bad Gateway message from nginx and
2. if i return to the login screen it shows me that my browser wont accept
cookies and that i should enable them.

Before i ran the project as scgi application managed by cherokee (another
small webserver) and everything worked without problems.

Any ideas?


Greetings and thanks in advance
Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: method import error

2009-09-07 Thread Sven Richter
Indeed, that was the problem. Thank you very much.

Greetings
Sven

On Mon, Sep 7, 2009 at 1:53 PM, Karen Tracey  wrote:

> On Mon, Sep 7, 2009 at 6:21 AM, Sven Richter wrote:
>
>> Hi all,
>>
>> i must have a simple error somewhere in my code, everytime i try to import
>> a certain method i get the following error:
>> cannot import name send_entry_created
>>
>> This is my code:
>> entry.models:
>> from entry.signals import send_entry_created
>> ...
>>
>> dispatcher.connect(send_entry_created, signal=signals.post_save,
>> sender=Entries)
>>
>> entry.signals:
>> from entry.models import Entries
>>
>> def send_entry_created(sender, instance, signal, *args, **kwargs):
>> if 'created' in kwargs:
>> if kwargs['created']:
>> print 'new'
>> try:
>> Entries.objects.get(id=instance._get_pk_val())
>> except (Entries.DoesNotExist, AssertionError):
>> print 'nsrd'
>>
>> Where signals is a file living in the entry app.
>>
>> Can someone point me to the error please?
>>
>>
> Looks like you may have a circular dependency.  Your entry.models file is
> trying to import send_entry_created from entry.signals but entry.signals
> then attempts to import Entries from entry.models, which leads to trying to
> import send_entry_created from entry.signals again and instead of entering
> an infinite loop Python reports the error.  You need to structure your
> code/imports so that there are no circular imports.
>
> Karen
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



method import error

2009-09-07 Thread Sven Richter
Hi all,

i must have a simple error somewhere in my code, everytime i try to import a
certain method i get the following error:
cannot import name send_entry_created

This is my code:
entry.models:
from entry.signals import send_entry_created
...

dispatcher.connect(send_entry_created, signal=signals.post_save,
sender=Entries)

entry.signals:
from entry.models import Entries

def send_entry_created(sender, instance, signal, *args, **kwargs):
if 'created' in kwargs:
if kwargs['created']:
print 'new'
try:
Entries.objects.get(id=instance._get_pk_val())
except (Entries.DoesNotExist, AssertionError):
print 'nsrd'

Where signals is a file living in the entry app.

Can someone point me to the error please?


Greetings
Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



cookie handling session management

2009-09-02 Thread Sven Richter
Hi everybody,

i've been tinkering around with cookies scinc some days. They work so far
for me, but i fear the way that i use them right now is not the django way
and it isn't a DRY way.
This is how i do it right now, i have some views and everytime the view is
called it checks if there is a certain cookie set or not and if it isnt set
then the view sets it:
 try: request_rated = request.session['rated']
except:
request.session['rated'] = ""
request_rated = request.session['rated']

Is there a more "django" way to use them?

The cookies problem is keeping me right now from using generic views and
this bugs me a bit.


Greetings
Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
Yea, i thought about that, but for me this seems like an ugly workaround.
Dont misunderstand me, i dont know enough about django and its database
internals, but why should i use a third model for something i can access
directly?

The solution i posted above was exactly what i was looking for and what
seems logic to me, but i could of course be wrong too.


Greetings
Sven

On Fri, Aug 28, 2009 at 6:19 PM, patrickk  wrote:

>
> I could be mistaken ... but why not using a third model.
>
> C(models.model):
>   a = models.ForeignKey('A')
>   b = models.ForeignKey('B')
>
> when editing either A or B, you could use C as inlines.
>
> regards,
> patrick
>
>
> On 28 Aug., 17:18, Sven Richter  wrote:
> > But i wonder how this would help me further.
> > In the End it doesnt matter for me on which model i define the M2M
> relation.
> > But i need to access the M2M Table from both models, at least in the view
> or
> > in the template if not in the admin interface.
> >
> > I am having a hard time finding out how to achieve that.
> >
> > Any Ideas?
> >
> > Greetings
> > Sven
> >
> > On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter  >wrote:
> >
> > > I've opened a bug/feature request at:
> > >http://code.djangoproject.com/ticket/11795#comment:2
> > > if someone is interested.
> >
> > > Greetings
> > > Sven
> >
> > > On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan  >wrote:
> >
> > >> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter >
> > >> wrote:
> > >> > I found this thread:
> >
> > >>http://stackoverflow.com/questions/660260/django-admin-form-for-many-.
> ..
> > >> > on Stackoverflow, but when i try the suggested TabularInline thing i
> get
> > >> the
> > >> > error:
> >
> > >> >  has no ForeignKey to
> > >>  > >> > 'politlog.entry.models.Entries'>
> >
> > >> At least with Django 1.0.x, the admin interface does not support
> > >> many-to-many relationships on inlines -- it will always return an
> > >> error like the one you got above.  Indeed, the message is technically
> > >> accurate, because m2m relationships get implemented as a separate
> > >> table, so there is no direct relationship between the two.
> > >> InlineModelAdmin works great for one-to-many but not for many-to-many.
> >
> > >> I'd also be interested in solutions to this, not having found anything
> > >> in a bunch of Google searches.  The alternative I'm planning on is
> > >> having to hand-code some views, forms, and templates that let me do
> > >> the right thing -- not a huge amount of work, but having admin do it
> > >> for us would be way cool.
> >
> > >> Craig
> >
> > >> > Greetings
> > >> > Sven
> >
> >
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
But i wonder how this would help me further.
In the End it doesnt matter for me on which model i define the M2M relation.
But i need to access the M2M Table from both models, at least in the view or
in the template if not in the admin interface.

I am having a hard time finding out how to achieve that.

Any Ideas?


Greetings
Sven

On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter wrote:

> I've opened a bug/feature request at:
> http://code.djangoproject.com/ticket/11795#comment:2
> if someone is interested.
>
>
> Greetings
> Sven
>
>
> On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:
>
>>
>> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
>> wrote:
>> > I found this thread:
>> >
>> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
>> > on Stackoverflow, but when i try the suggested TabularInline thing i get
>> the
>> > error:
>> >
>> >  has no ForeignKey to
>> > > 'politlog.entry.models.Entries'>
>> >
>>
>> At least with Django 1.0.x, the admin interface does not support
>> many-to-many relationships on inlines -- it will always return an
>> error like the one you got above.  Indeed, the message is technically
>> accurate, because m2m relationships get implemented as a separate
>> table, so there is no direct relationship between the two.
>> InlineModelAdmin works great for one-to-many but not for many-to-many.
>>
>> I'd also be interested in solutions to this, not having found anything
>> in a bunch of Google searches.  The alternative I'm planning on is
>> having to hand-code some views, forms, and templates that let me do
>> the right thing -- not a huge amount of work, but having admin do it
>> for us would be way cool.
>>
>> Craig
>>
>>
>> > Greetings
>> > Sven
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
Ah, and google does help or at least django_snippets.
I found the solution here:
http://www.djangosnippets.org/snippets/1295

The trick is to create a column in both models and in one with the option to
not syncdb.
Its really simple, just 6 lines at all.


Greetings and a nice Weekend
Sven

On Fri, Aug 28, 2009 at 5:18 PM, Sven Richter wrote:

> But i wonder how this would help me further.
> In the End it doesnt matter for me on which model i define the M2M
> relation.
> But i need to access the M2M Table from both models, at least in the view
> or in the template if not in the admin interface.
>
> I am having a hard time finding out how to achieve that.
>
> Any Ideas?
>
>
> Greetings
> Sven
>
>
> On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter wrote:
>
>> I've opened a bug/feature request at:
>> http://code.djangoproject.com/ticket/11795#comment:2
>> if someone is interested.
>>
>>
>> Greetings
>> Sven
>>
>>
>> On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:
>>
>>>
>>> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
>>> wrote:
>>> > I found this thread:
>>> >
>>> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
>>> > on Stackoverflow, but when i try the suggested TabularInline thing i
>>> get the
>>> > error:
>>> >
>>> >  has no ForeignKey to
>>> >> > 'politlog.entry.models.Entries'>
>>> >
>>>
>>> At least with Django 1.0.x, the admin interface does not support
>>> many-to-many relationships on inlines -- it will always return an
>>> error like the one you got above.  Indeed, the message is technically
>>> accurate, because m2m relationships get implemented as a separate
>>> table, so there is no direct relationship between the two.
>>> InlineModelAdmin works great for one-to-many but not for many-to-many.
>>>
>>> I'd also be interested in solutions to this, not having found anything
>>> in a bunch of Google searches.  The alternative I'm planning on is
>>> having to hand-code some views, forms, and templates that let me do
>>> the right thing -- not a huge amount of work, but having admin do it
>>> for us would be way cool.
>>>
>>> Craig
>>>
>>>
>>> > Greetings
>>> > Sven
>>>
>>> >>>
>>>
>>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
I've opened a bug/feature request at:
http://code.djangoproject.com/ticket/11795#comment:2
if someone is interested.


Greetings
Sven

On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:

>
> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
> wrote:
> > I found this thread:
> >
> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
> > on Stackoverflow, but when i try the suggested TabularInline thing i get
> the
> > error:
> >
> >  has no ForeignKey to
>  > 'politlog.entry.models.Entries'>
> >
>
> At least with Django 1.0.x, the admin interface does not support
> many-to-many relationships on inlines -- it will always return an
> error like the one you got above.  Indeed, the message is technically
> accurate, because m2m relationships get implemented as a separate
> table, so there is no direct relationship between the two.
> InlineModelAdmin works great for one-to-many but not for many-to-many.
>
> I'd also be interested in solutions to this, not having found anything
> in a bunch of Google searches.  The alternative I'm planning on is
> having to hand-code some views, forms, and templates that let me do
> the right thing -- not a huge amount of work, but having admin do it
> for us would be way cool.
>
> Craig
>
>
> > Greetings
> > Sven
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many-to-many column admin interface

2009-08-27 Thread Sven Richter
I found this thread:
http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
on Stackoverflow, but when i try the suggested TabularInline thing i get the
error:

 has no ForeignKey to


Greetings
Sven



On Thu, Aug 27, 2009 at 5:03 PM, Thomas Guettler  wrote:

>
> Hi,
>
> I had the same question some time ago and found no answer,
> but maybe you try harder.
>
> Sven Richter schrieb:
> > Hi,
> >
> > i have a new problem with my many-to-many field.
> >
> > I have two models A and B.
> > A(models.model):
> >   b = models.ManyToManyField('app.B')
> >
> > Now when i edit A in the admin interface everything is ok, i can select
> all
> > B instances A belongs to.
> >
> > What i need now is to be able to do the same thing from B's admin
> interface.
> > When i edit B i want to select all instances of A B belongs to.
> >
> > Is there a way to achieve that?
>
> --
> Thomas Guettler, http://www.thomas-guettler.de/
> E-Mail <http://www.thomas-guettler.de/%0AE-Mail>: guettli (*)
> thomas-guettler + de
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Many-to-many column admin interface

2009-08-27 Thread Sven Richter
Hi,

i have a new problem with my many-to-many field.

I have two models A and B.
A(models.model):
  b = models.ManyToManyField('app.B')

Now when i edit A in the admin interface everything is ok, i can select all
B instances A belongs to.

What i need now is to be able to do the same thing from B's admin interface.
When i edit B i want to select all instances of A B belongs to.

Is there a way to achieve that?


Greetings
Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many-to-many column

2009-08-26 Thread Sven Richter
Thank you very much. I think i get the idea.


Greetings
Sven

On Tue, Aug 25, 2009 at 10:51 PM, Peter Bengtsson  wrote:

>
> I fear your only option is to write a recursive function which you
> feed with what you define to be "the end of the chain".
> You can collect all the entries in a mutable list. Some example,
> untested, code:
>
> def get_all_parents(list_, current):
>for entry in current.following_to.all():
>list_.append(entry)
>list_.extend(get_all_parents(list_, entry)
>return list_
>
> current = A
> parents = []
> get_all_parents(parents, current)
> print parents
>
> Excuse me if I didn't get it right but it should get you started.
>
> On Aug 25, 10:11 am, Sven Richter  wrote:
> > Hi,
> >
> > i implemented a many-to-many field in my model like:
> > class Entries(models.Model):
> >   following_to = models.ManyToManyField('self', blank=True, null=True)
> >
> > Now i can get all related Entries in a template with
> entry.following_to.all.
> > But i want to go deeper in relationships.
> >
> > Lets say i have 4 Entries A, B, C, D.
> > A is following_to to B and
> > B is following_to to C and
> > C is following_to to D.
> > A.following_to.all gives back B.
> >
> > But what i need is to follow until the end of the chain is reached.
> > I need something like:
> > A.following_to.give_all_related_entries which then returns:
> > B, C, D
> >
> > Do i have to write my own template tag for that or is it already
> implemented
> > in Django?
> > Or maybe there is a better approach to solve my issue?
> >
> > I couldnt find a similar question or answer in the docs.
> >
> > Greetings
> > Sven
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Many-to-many column

2009-08-25 Thread Sven Richter
Hi,

i implemented a many-to-many field in my model like:
class Entries(models.Model):
  following_to = models.ManyToManyField('self', blank=True, null=True)

Now i can get all related Entries in a template with entry.following_to.all.
But i want to go deeper in relationships.

Lets say i have 4 Entries A, B, C, D.
A is following_to to B and
B is following_to to C and
C is following_to to D.
A.following_to.all gives back B.

But what i need is to follow until the end of the chain is reached.
I need something like:
A.following_to.give_all_related_entries which then returns:
B, C, D

Do i have to write my own template tag for that or is it already implemented
in Django?
Or maybe there is a better approach to solve my issue?

I couldnt find a similar question or answer in the docs.


Greetings
Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: adapt admin interface

2009-08-13 Thread Sven Richter
Uhm, yes, i already asked my first question here on that list.
I just thought that mail never got posted, thats why i asked
once more.
So the first one is answered on:
http://groups.google.com/group/django-users/browse_thread/thread/110f0d4e3c146fdc

I suspect that the answer to question two is basically the same as to
question
one?


Greetings
Sven

On Thu, Aug 13, 2009 at 10:33 AM, Sven Richter wrote:

> Hi everybody,
>
> i have two questions regarding the admin interface.
>
> 1. Is it possible to make on column be dependent of the choice of another
> one?
> For example, i have to columns in my model: Party and Politician. If i
> choose a party
> now i want only the politicians belonging to that party to be shown in the
> politician
> drop down box.
>
> 2. I am using django-tagging for some days now which is really a great
> work.
> What isnt so great is comparing text with the tags that i already have to
> make sure
> i always use the same text.
> So, when i enter my text for a model in the admin interface i need a button
> which calls
> a function "compare". "compare" now should compare the text from an input
> field with
> the tags already entered and if  there are identical tags found, insert
> them into
> the "tags" column in the admin interface.
>
> I didnt really find much about customizing the admin interface that way
> that i want it.
>
>
> Greetings
> Sven
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



adapt admin interface

2009-08-13 Thread Sven Richter
Hi everybody,

i have two questions regarding the admin interface.

1. Is it possible to make on column be dependent of the choice of another
one?
For example, i have to columns in my model: Party and Politician. If i
choose a party
now i want only the politicians belonging to that party to be shown in the
politician
drop down box.

2. I am using django-tagging for some days now which is really a great work.
What isnt so great is comparing text with the tags that i already have to
make sure
i always use the same text.
So, when i enter my text for a model in the admin interface i need a button
which calls
a function "compare". "compare" now should compare the text from an input
field with
the tags already entered and if  there are identical tags found, insert them
into
the "tags" column in the admin interface.

I didnt really find much about customizing the admin interface that way that
i want it.


Greetings
Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: javascript variable in url resolver template tag

2009-08-10 Thread Sven Richter
Ok, thank you very much, thats how i am gonna do it.
I just didnt think about the fact that django is being done on
the server side and the script on the client side.


Greetings
Sven

On Sun, Aug 9, 2009 at 8:20 PM, Daniel Roseman wrote:

>
> On Aug 9, 4:59 pm, Sven Richter  wrote:
> > I am looking for a rating function AJAX style.
> > So what i am trying to do is the following:
> >
> > Click on a link  > register a Jquery function to call on that click with:
> > $('a#vote_pos').click(rate_it);
> > and then in rate_it call the url rate with two paramaters int entry and
> > string pos_neg
> > like
> > $.ajax( {type:"POST", url:/entry/rate/pos_neg, ...
> > and i wanted to build the url with the url tag like:
> > url:{% url rate entry pos_neg %}
> >
> > Sven
> >
>
> Rather than having a dynamic URL with parameters, you'll just have to
> make the parameters part of the POST. So you can still use the url tag
> at render time to output the URL, but instead of it being /entry/5/
> rate/positive/ it should just be eg /entry/rate/, and the values for
> rate and pos_neg are keys in the POST.
> --
> DR.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: javascript variable in url resolver template tag

2009-08-09 Thread Sven Richter
Ok, i think i understand the problem now.
So i have to hardcode the url in my javascript function?
That was what i wanted to circumvent.

Sven

On Sun, Aug 9, 2009 at 5:57 PM, Daniel Roseman wrote:

>
> On Aug 9, 4:43 pm, Sven Richter  wrote:
> > Hi all,
> >
> > i wanted to know if it is possible to pass a Javascript variable to
> > the url template tag?
> >
> > Like:
> > 
> > ...
> > 

Re: javascript variable in url resolver template tag

2009-08-09 Thread Sven Richter
I am looking for a rating function AJAX style.
So what i am trying to do is the following:

Click on a link  wrote:

>
> On Sun, Aug 9, 2009 at 5:43 PM, Sven Richter
> wrote:
> > Hi all,
> >
> > i wanted to know if it is possible to pass a Javascript variable to
> > the url template tag?
> >
> > Like:
> > 
> > ...
> > 

javascript variable in url resolver template tag

2009-08-09 Thread Sven Richter
Hi all,

i wanted to know if it is possible to pass a Javascript variable to
the url template tag?

Like:

...

Re: Admin get_urls

2009-02-02 Thread Sven B

Hi,

guess you're right. It is the 1.0.x branch i'm using.
[s...@troy django-trunk] svn info
URL: http://code.djangoproject.com/svn/django/branches/releases/1.0.X

after svn switch http://code.djangoproject.com/svn/django/trunk

[s...@troy admin] grep get_urls options.py
def get_urls(self):

mystery solved, thanks :)

Sven


2009/2/2 Daniel Roseman :
> That doesn't necessarily prove you're on trunk - I checked out the 1.0
> tag, and did svn up, and still get the 'at revision 9803' message even
> though when I do svn info the last changed revision is 8961.
> Have you got the get_urls method in django.contrib.admin.options?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin get_urls

2009-02-02 Thread Sven Broeckling

Hi,

i also miss this function in trunk. I'm looking for a method to
populate the admin with own views. Is it possible that this feature
got
lost some time ago? Im at the latest trunk Version, but i can't fint
any line with get_urls in it in django.contrib.admin.
[s...@troy django-trunk] cd django/contrib/admin
[s...@troy admin] grep -r 'get_urls' *
[s...@troy admin]

Any hints?

Sven

On 2 Feb., 08:52, Dave Fowler  wrote:
> Daniel, thanks for the response
> I'm on the latest svn version
> d...@django$ svn up
> At revision 9803.
> so my version shouldn't be the issue.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: slow django builtin webserver

2008-11-16 Thread Sven Richter

Steve Holden wrote:
> Sven Richter wrote:
>   
>> Hi all,
>>
>> i recently reinstalled my workingstation. Nothing wild, just
>> changed from single hdd to a raid system. However, scince
>> that day my django server has a horrible response on
>> the new system.
>> Loading the server takes up to ca. 5 secs and requesting
>> a site from it the same amount of time.
>>
>> First i thought it was the mysql server which was running
>> on ubuntu and where i upgraded to the new version (intrepid).
>> So i installed a mysql server on my machine and adapted the
>> settings, but that didnt help.
>>
>> Same issue as before.
>>
>> Now i am wondering where i can start to debug that.
>>
>> My production machine runs on Arch linux which
>> uses python 2.6 and django 1.0.
>>
>> The same problem seems to appear when i try to
>> connect via ssh to my other server. But that seems
>> serverrelated cause it happens on other clients in my
>> LAN too. I am a bit irritated, is suspect it to be
>> some kind of dns problem.
>> But what speaks against that is that internet requests
>> are as fast as normal, and phpymadmin behaves
>> normal too.
>>
>> 
> This sounds a bit like a DNS problem to me, though that's only one of
> many possible diagnoses.
>
> Is "localhost" set in the /etc/hosts file?
>
>   
It was, but in one line with localhost.localdomain like that:
127.0.0.1 localhost.localdomain localhost
I moved it up to stay there alone in the line and scince
then it works.


Thx for the hint
Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



slow django builtin webserver

2008-11-12 Thread Sven Richter
 Hi all,

i recently reinstalled my workingstation. Nothing wild, just
changed from single hdd to a raid system. However, scince
that day my django server has a horrible response on
the new system.
Loading the server takes up to ca. 5 secs and requesting
a site from it the same amount of time.

First i thought it was the mysql server which was running
on ubuntu and where i upgraded to the new version (intrepid).
So i installed a mysql server on my machine and adapted the
settings, but that didnt help.

Same issue as before.

Now i am wondering where i can start to debug that.

My production machine runs on Arch linux which
uses python 2.6 and django 1.0.

The same problem seems to appear when i try to
connect via ssh to my other server. But that seems
serverrelated cause it happens on other clients in my
LAN too. I am a bit irritated, is suspect it to be
some kind of dns problem.
But what speaks against that is that internet requests
are as fast as normal, and phpymadmin behaves
normal too.


Thanks in Advance
Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ImageField upload Media root confusion

2008-10-22 Thread Sven Richter

Hi all,

respective to my thread from yesterday:
http://groups.google.com/group/django-users/browse_thread/thread/c5816db50ed0ef9/1455790f9220bb30?lnk=gst&q=image+upload#1455790f9220bb30
i got more irritated now and think i found
a bug or something like that.

If i try to store the uploaded picture in
'avatars/' it creates a new folder
avatars in my django project and stores
the files there.

But when try to show the picture on
the website with 'pic.url' it gives
me the path to the media root, meaning:
'media/avatars/file.jpg'.

And if i say the upload path should be
'media/avatars' it creates a folder
avatar in 'media' and stores the
pictures there.

But then, when i call the pic.url
function it gives me back the url:
'media/media/avatars/fil.jpg'.

So for me this means that it stores
the file in the specified upload path,
no matter where that is, and reads it
from the media root + the upload path,
which seems like a bug for me.

Any clarification for that behaviour?
Or is it just me experiencing this?


Greetings
Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Image upload Field

2008-10-22 Thread Sven Richter

Nevermind my Mail,
right after i sent this message it works.
I dont know what went wrong exactly
but right now i can see all of a sudden like
10 pictures i was loading up.


Greetings
Sven


Sven Richter wrote:
> Hi,
>
> i have a model which defines a ImageField with
> a path which exists in the media root.
>
> Then i created a form which is bound to the Model
> with Modelform.
>
> All the fields in the Form are working as expected
> despite the Image field.
> I mean, i can choose an image, but it wont
> upload to my path, nor would it throw
> any errors.
>
> Below is the code i use:
>
> models.py:
> class UserProfile(models.Model):
>...
>pic = models.ImageField(upload_to=upload_path_avatar, blank=True, 
> null=True,
>verbose_name=_('picture:'))
>
>
> forms.py:
> class CompleteUser(ModelForm):   class Meta:
>model = UserProfile
>exclude = ('key', 'key_expires', 'user')
>
>
> views.py:
> def edit(request, name, template): 
>if request.method == 'POST':
>userprofile_form = CompleteUser(request.POST, request.FILES, 
> instance=user_profile)
>user_form = UserForm(request.POST, instance=request.user)  
>  if userprofile_form.is_valid() and user_form.is_valid() :
>userprofile_form.save()
>user_form.save()  else: 
> userprofile_form = CompleteUser(instance=user_profile)
>user_form = UserForm(instance=request.user)
>
>return render_to_response(template, {'name':name, 
> 'form':userprofile_form, 'user_form':user_form, }, 
> RequestContext(request))
>
>
> and the html file:
> 
> {{ form.pic.label_tag }} {{ form.pic }}type="submit" value="{% trans "Save" %}">
>
>
>
> I've taken out the not so relevant parts.
> The problem is i really dont know how to debug that
> problem cause i got no error messages or something
> like that. All it does is not working.
>
>
> Greetings
> Sven


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Image upload Field

2008-10-22 Thread Sven Richter

Hi,

i have a model which defines a ImageField with
a path which exists in the media root.

Then i created a form which is bound to the Model
with Modelform.

All the fields in the Form are working as expected
despite the Image field.
I mean, i can choose an image, but it wont
upload to my path, nor would it throw
any errors.

Below is the code i use:

models.py:
class UserProfile(models.Model):
...
pic = models.ImageField(upload_to=upload_path_avatar, blank=True, 
null=True,
verbose_name=_('picture:'))


forms.py:
class CompleteUser(ModelForm):  
   
class Meta:
model = UserProfile
exclude = ('key', 'key_expires', 'user')


views.py:
def edit(request, name, template):  
 
if request.method == 'POST':
userprofile_form = CompleteUser(request.POST, request.FILES, 
instance=user_profile)
user_form = UserForm(request.POST, instance=request.user)  
   
if userprofile_form.is_valid() and user_form.is_valid() :
userprofile_form.save()
user_form.save() 
   
else:  
userprofile_form = CompleteUser(instance=user_profile)
user_form = UserForm(instance=request.user)

return render_to_response(template, {'name':name, 
'form':userprofile_form, 'user_form':user_form, }, RequestContext(request))


and the html file:

{{ form.pic.label_tag }} {{ form.pic }}   




I've taken out the not so relevant parts.
The problem is i really dont know how to debug that
problem cause i got no error messages or something
like that. All it does is not working.


Greetings
Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: resolving urls template error

2008-09-18 Thread Sven Richter

Sven Richter wrote:
> Hi, 
>
> i get the following error message:
> TemplateSyntaxError at /community/profile/sveris/
> Caught an exception while rendering: Reverse for 'youriq.profile_myiq' with 
> arguments '('',)' and keyword arguments '{}' not found.
>
> Original Traceback (most recent call last):
>   File "/usr/lib/python2.5/site-packages/django/template/debug.py", line 71, 
> in render_node
> result = node.render(context)
>   File "/usr/lib/python2.5/site-packages/django/template/defaulttags.py", 
> line 378, in render
> args=args, kwargs=kwargs)
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 
> 252, in reverse
> *args, **kwargs)))
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 
> 241, in reverse
> "arguments '%s' not found." % (lookup_view, args, kwargs))
> NoReverseMatch: Reverse for 'youriq.profile_myiq' with arguments '('',)' and 
> keyword arguments '{}' not found.
>
> when i try to call:
> {% url profile_myiq argument %}
>
> from a template.
>
>
> These are all important modules i hope:
> settings.py
> INSTALLED_APPS = (
>   'accounts'
>   'community'
>   'profile',
>   'shared',
> )
>
> urls.py
> urlpatterns = patterns('',
>   (r'^admin/(.*)', admin.site.root), 
>   (r'^community/', include('community.urls')),
> )
>
> community/urls.py
> urlpatterns = patterns('community.views',
>   (r'^$', direct_to_template, {'template':'community/community.html'},
> 'community'),
>   (r'^accounts/', include('accounts.urls')),
>   (r'^profile/', include('profile.urls')),
> )
>
> profile/urls.py
> urlpatterns = patterns('profile.views',
>   (r'^$', direct_to_template, {'template':'profile/profile_all.html'},
> 'profile_all'),
>   (r'^(?P\w+)/$', 'user', {} 'profile_myiq'),
> )
>
> profile/views.py
> def user(request, name):
>
> return render_to_response('profile/profile_user.html', {'name':name},
> RequestContext(request))
>
>
>   
Thanks to the people from the irc i could
solve the problem.
The template call has to look like that:

{% url profile_myiq "argument" %}

if argument is a string it has to be
quoted, and if it's an variable it doesn't need
quotes which is some sort of logic.

The documentation about that is a bit misleading.
It says something like:
{% url profile_myiq 1994 %}
which led me to the conclusion the argument
doesn't have to be quoted anyway.


Greetings
Sven


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



resolving urls template error

2008-09-18 Thread Sven Richter

Hi, 

i get the following error message:
TemplateSyntaxError at /community/profile/sveris/
Caught an exception while rendering: Reverse for 'youriq.profile_myiq' with 
arguments '('',)' and keyword arguments '{}' not found.

Original Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/template/debug.py", line 71, in 
render_node
result = node.render(context)
  File "/usr/lib/python2.5/site-packages/django/template/defaulttags.py", line 
378, in render
args=args, kwargs=kwargs)
  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 
252, in reverse
*args, **kwargs)))
  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 
241, in reverse
"arguments '%s' not found." % (lookup_view, args, kwargs))
NoReverseMatch: Reverse for 'youriq.profile_myiq' with arguments '('',)' and 
keyword arguments '{}' not found.

when i try to call:
{% url profile_myiq argument %}

from a template.


These are all important modules i hope:
settings.py
INSTALLED_APPS = (
  'accounts'
  'community'
  'profile',
  'shared',
)

urls.py
urlpatterns = patterns('',
  (r'^admin/(.*)', admin.site.root), 
  (r'^community/', include('community.urls')),
)

community/urls.py
urlpatterns = patterns('community.views',
  (r'^$', direct_to_template, {'template':'community/community.html'},
'community'),
  (r'^accounts/', include('accounts.urls')),
  (r'^profile/', include('profile.urls')),
)

profile/urls.py
urlpatterns = patterns('profile.views',
  (r'^$', direct_to_template, {'template':'profile/profile_all.html'},
'profile_all'),
  (r'^(?P\w+)/$', 'user', {} 'profile_myiq'),
)

profile/views.py
def user(request, name):

return render_to_response('profile/profile_user.html', {'name':name},
RequestContext(request))


I was fiddling around for some hours now and 
became totally clueless.
If anybody got some ideas i'd appreciate them.


Greetings
Sven


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: overwrite get_absolute_url /contrib/auth/User

2008-09-16 Thread Sven Richter

On Tue, 2008-09-16 at 15:11 -0300, Eduardo O. Padoan wrote:
> On Tue, Sep 16, 2008 at 2:59 PM, Sven Richter <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > i am wondering if the "users" path in get_absolute_url
> > from the User class is hardcoded?
> > I mean this line:
> > return "/users/%s/" % urllib.quote(smart_str(self.username))
> >
> > I have the problem that all my profiles want to reside
> > under /profile/username and not /users/username.
> >
> > Can i subclass this Model and overwrite the function
> > somehow?
> > Or is there another way to get my profiles path
> > without a dirty hack?
> >
> 
> Jannis Leidel have written about it:
> http://jannisleidel.com/2008/08/easy-overrides-absolute-urls-reusable-apps/

Thank you, this pointed me into the right direction.
Just in case somebody is interested in the solution.

In the settings file of the project you have to define the option:
ABSOLUTE_URL_OVERRIDES = {
'auth.user' : lambda o:'/profile/%s/' % o.username,
}

to overwrite the get_absolute_url function.
This works for any installed model in the project.

Docs can be found here:
http://docs.djangoproject.com/en/dev/ref/settings/#absolute-url-overrides


Greetings
Sven


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



overwrite get_absolute_url /contrib/auth/User

2008-09-16 Thread Sven Richter

Hi,

i am wondering if the "users" path in get_absolute_url
from the User class is hardcoded?
I mean this line:
return "/users/%s/" % urllib.quote(smart_str(self.username))

I have the problem that all my profiles want to reside
under /profile/username and not /users/username.

Can i subclass this Model and overwrite the function
somehow?
Or is there another way to get my profiles path
without a dirty hack?


Greetings
Sven


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Tests catch Errors

2008-09-09 Thread Sven Richter

On Tue, 2008-09-09 at 21:28 +0200, Sven Richter wrote:
> On Tue, 2008-09-09 at 20:25 +0200, Sven Richter wrote:
> 
> > i was playing around with unittests and found the
> > failUnlessRaises(excClass, callableObj) Method.
> > If i understand it right the Method catches Exceptions
> > that are thrown by django.
> > 
> > I tried to send a post to a register form with:
> > res = Client().post('/register/', {data}) which
> > works so far.
> > 
> > Now i want to catch an Error, in this special case
> > the error that is thrown if i forget a field,
> > f.e. the password field.
> > So i want to catch the "forgot-password-field-error".
> > 
> > Now my question is, where can i find the exceptions
> > i can catch? Meaning where are they described?
> 
> I was looking around the net cause i am afraid i cannot
> sleep if i dont solve it tonight :D
> 
> At least i am more confused now.
> I found an example for a unittest which uses
> failUnlessRaises():
> 
> 
> 
> def raises_error(*args, **kwds):
> print args, kwds
> raise ValueError('Invalid value: ' + str(args) + str(kwds))
> 
> class ExceptionTest(unittest.TestCase):
> def testFailUnlessRaises(self):
> self.failUnlessRaises(ValueError, raises_error, 'a', b='c')
> 
> If i understand that right i have to  submit the values
> to the method raises_error from my testmethod which i want to check.
> 
> I am more confused now. How can i submit a post request with
> given data to a method? In this case the raises_error method?
> 
> And how can i catch the error that a form field has to be
> filled with some data?
> 
> At least i am questioning myself if failUnlessRaises
> is available in django the way i want to use it.
> 
> So i am wondering how i can achieve to test
> a form to throw an error?

I found what i was looking for:
self.assertFormError(res, 'form', 'username', 'This field is requied.')

As simple as that.

Just in the case one of the website admins reads here.
An example to that Method, besides an large test example
is provided under:
http://www.djangoproject.com/documentation/models/test_client/

But then i click on documentation and then go to the
apropriate test section i come to:
http://docs.djangoproject.com/en/dev/topics/testing/#assertions
which doesn't provide a link to the large example.

Providing that link would be really cool :-)


Greetings
Sven



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Tests catch Errors

2008-09-09 Thread Sven Richter

On Tue, 2008-09-09 at 20:25 +0200, Sven Richter wrote:

> i was playing around with unittests and found the
> failUnlessRaises(excClass, callableObj) Method.
> If i understand it right the Method catches Exceptions
> that are thrown by django.
> 
> I tried to send a post to a register form with:
> res = Client().post('/register/', {data}) which
> works so far.
> 
> Now i want to catch an Error, in this special case
> the error that is thrown if i forget a field,
> f.e. the password field.
> So i want to catch the "forgot-password-field-error".
> 
> Now my question is, where can i find the exceptions
> i can catch? Meaning where are they described?

I was looking around the net cause i am afraid i cannot
sleep if i dont solve it tonight :D

At least i am more confused now.
I found an example for a unittest which uses
failUnlessRaises():



def raises_error(*args, **kwds):
print args, kwds
raise ValueError('Invalid value: ' + str(args) + str(kwds))

class ExceptionTest(unittest.TestCase):
def testFailUnlessRaises(self):
self.failUnlessRaises(ValueError, raises_error, 'a', b='c')

If i understand that right i have to  submit the values
to the method raises_error from my testmethod which i want to check.

I am more confused now. How can i submit a post request with
given data to a method? In this case the raises_error method?

And how can i catch the error that a form field has to be
filled with some data?

At least i am questioning myself if failUnlessRaises
is available in django the way i want to use it.

So i am wondering how i can achieve to test
a form to throw an error?


Greetings
Sv


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Tests catch Errors

2008-09-09 Thread Sven Richter

Hi,

i was playing around with unittests and found the
failUnlessRaises(excClass, callableObj) Method.
If i understand it right the Method catches Exceptions
that are thrown by django.

I tried to send a post to a register form with:
res = Client().post('/register/', {data}) which
works so far.

Now i want to catch an Error, in this special case
the error that is thrown if i forget a field,
f.e. the password field.
So i want to catch the "forgot-password-field-error".

Now my question is, where can i find the exceptions
i can catch? Meaning where are they described?


Greetings
Sven


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: error when using User.get_profile()

2008-09-08 Thread Sven Richter

Karen Tracey wrote:
> On Mon, Sep 8, 2008 at 6:42 AM, sveri <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>
> Hi,
>
> i am using Django 1.0 and try to extent the usermodel, which works so
> far
> for adding new users.
>
> But when i want to retrieve a user profile i get a weird error:
>
> user = get_object_or_404(User, id=9)
> user.get_profile()
>
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "/usr/lib/python2.5/site-packages/django/contrib/auth/
> models.py", line 293, in get_profile
>self._profile_cache =
> model._default_manager.get(user__id__exact=self.id <http://self.id>)
> AttributeError: 'NoneType' object has no attribute '_default_manager'
>
> This is what happens when i try that in the console.
>
> I dont know what to do with that messages.
> And googling didn't help either.
>
>
> Searching this group for the "'NoneType' object has no attribute 
> '_default_manager'" message, this thread comes up:
>
> http://groups.google.com/group/django-users/browse_thread/thread/8494cd87bf181018/e73fed4cdbd80a4e
>
> Perhaps your problem has the same solution.
>
> Karen
>
Indeed, and i thought i doublechecked everything.
It was a mistake i made.
In settings.py AUTH_PROFILE_MODULE i used: 'project.userprofile'
instead of 'model.userprofile' which works now.


Thank you
Sven


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: issue with ifequal in a base template

2007-06-05 Thread Sven Broeckling

> > {% for catetory in categorylist %}
> If this is a cut-and-paste of your template, here's your error. Learn to
> spell "category". :-)
Oh how blind was that. Of course that was the problem, thanks a lot :)
After fixing that i got an "always false" instead of "always true".
The debug line with the == shows "News == News", but the  won't
appear. I think i'm going to check for other stupid typos now.

Bye
  Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



issue with ifequal in a base template

2007-06-05 Thread Sven Broeckling

Hi everyone,

i use django for a small fun website, and it's really fun to create
applications with it. Now i'm stuck with a behaviour i can't
comprehend.

I have a category list in my base template :

--[snip]--
{% if categorylist %}
Buckets

  
{% for catetory in categorylist %}
{% ifequal
category.name active_category %}{% endifequal %}{{ catetory.name
}}{% ifequal category.name active_category %}{% endifequal
%}

{% endfor %}

  
{% endif %}
--[snip]--


categorylist and active_category are supplied by a context processor
named categorylist :

--[snip]--
def categorylist(request):
active_category = None
if hasattr (request, "session"):
if "category" in request.session:
try:
active_category = Category.objects.get
(pk=request.session['category'])
except:
active_category = None

c = Category.objects.all()

return { 'categorylist' : c, 'active_category' : active_category}
--[snip]--


Both the category list and the active category appear in the template,
and the values are right. What fails is the ifequal statement in the
base template. The  tags appear in the output if {{
active_category }} is None. If i choose a category the ifequal test
fails even if both values are the same.

Any Ideas?

TIA
 Sven

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: nested dictionaries in templates

2007-05-19 Thread Sven Herzing

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Aidas,

thx for the fast help. I hope i get better with django soon, that I can
help others too.

greets
Sven

Aidas Bendoraitis wrote:
> Hi Sven!
> 
> To get a value from a dictionary by a variable key, you either need a
> custom filter like {{ dictionary|dict_value:key }}
> 
> def dict_value(dict, key):
> """ returns the value of a dictionary key ...
> """
> try:
> return dict[key]
> except:
> return None
> 
> register.filter('dict_value', dict_value)
> 
> ... or you can go through the items like this:
> 
> {% for key_value in dictionary.items %}
> {{ key_value.0 }}{# the key #}
> {% for item in key_value.1 %}{# the value, that is the queryset #}
> {{ item }}
> {% endfor %}
> {% endfor %}
> 
> Regards,
> Aidas Bendoraitis aka Archatas
> 
> 
> 
> On 5/17/07, Sven Herzing <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I'm sorry that I have to ask again for help, but, I couldn't figure it
> out how to access nested directories in templates.
> 
> My Problem ist, that I have 3 categories (which I get from the DB), and
> for every category a queryset.
> 
> and the structure looks like this
> 
> {'rahmen':
> [, ],
>  'laufrad':
> [, ,  laufrad2, lr2>],
> 'lenker':
> [, ,  lenker2, len2>, ]
> }
> 
> I have the keywords for the dictionary in an array (mygroups) which I
> access in the template like this:
> 
> {% for entry in mygroups %}
> {{ entry }}
> 
>  and here I would like to access the dictionaries like this
> 
> {% for prod in product.entry %}
> {{ prod.name }}
> {% endfor %}
> {% endfor %}
> 
> The template manual says that if there is a point in a variable, it trys
> to treat it like a dictionary or a list, but what if the word after the
> point isn't parameter of the dictironary?
> I also tried sth like this {% for prod in product.{{ entry }} %}, but
> this didn't work either.
> 
> Is this kind of access possible?
> 
> regards
> Sven Herzing
> 
> 
>>

> 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGTsze4uR1pQ+2BeoRAtGvAKCV41i3tXin9/jb81Meirsqqpi33gCcDHWO
oIhx7sa3qdPsn8+bnPkRvn4=
=NwHW
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



nested dictionaries in templates

2007-05-17 Thread Sven Herzing

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I'm sorry that I have to ask again for help, but, I couldn't figure it
out how to access nested directories in templates.

My Problem ist, that I have 3 categories (which I get from the DB), and
for every category a queryset.

and the structure looks like this

{'rahmen':
[, ],
 'laufrad':
[, , ],
'lenker':
[, , , ]
}

I have the keywords for the dictionary in an array (mygroups) which I
access in the template like this:

{% for entry in mygroups %}
{{ entry }}

 and here I would like to access the dictionaries like this

{% for prod in product.entry %}
{{ prod.name }}
{% endfor %}
{% endfor %}

The template manual says that if there is a point in a variable, it trys
to treat it like a dictionary or a list, but what if the word after the
point isn't parameter of the dictironary?
I also tried sth like this {% for prod in product.{{ entry }} %}, but
this didn't work either.

Is this kind of access possible?

regards
Sven Herzing


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGTMDU4uR1pQ+2BeoRAo2MAJ47gSuZlZWG/T88ePMqVNXBWim6hQCeKJD2
JCDvvAFlgFT8C+lkxHu8J94=
=PP8O
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



SQL Queries over multiple Tables

2007-05-14 Thread Sven Herzing

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi All,

I'm quite new to django and try to solve a problem which I found while
I'm writing a little webshop with django. I'm sorry if I ask a too
simple question, but sadly, I can't see a solution on my own.

I have 3 Classes

class Company(models.Model):
name = models.CharField( maxlength = 64, core = True )  
address =
models.ForeignKey( Address )
def __str__( self ):
return self.name
class Admin:
pass

class ProductGroup(models.Model):
groupname = models.CharField( maxlength = 32 )
def __str__( self ):
return self.groupname
class Admin:
pass

class Product(models.Model):
companyid = models.ForeignKey( Company )
description = models.CharField( maxlength = 32 )
productno = models.CharField( maxlength = 20 )
group = models.ManyToManyField( ProductGroup )

and I like to get the Products for a specific group and for a specific
company.
My problem is that I haven't found a possibility in the db and model
documentation, to make an database query, where I have serveral tables
in the where clause, but only get the objects of one table. I tried the
objects.all.extra(...), but I didn't had success with that.


Rigth now, I think about using custom sql which this statement:

from django.db import connection
cursor = connection.cursor()
cursor.execute( "select sp.* from shop_product sp, shop_product_group
spg where sp.id = spg.product_id and productgroup_id = %s and
companyid_id = %s", [ productgroupId, companyId ] )
row = cursor.fetchone()
prod = Product( row[0], row[1], row[2], row[3] )

.. but here I need to reassign the values from the tuple to an object
again (which don't work somehow in this way :( )

Does anyone have a suggestion how I could solve this which the django
api, as I like to be flexible with the database.

Thanks a lot for any help or suggestion
Regards
Sven Herzing





-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGSLn24uR1pQ+2BeoRAn6XAJ9Tn/wibrUWzCQceFDx9asiaZcPNQCfSqdG
yeYUPzDLCdGRXxfCJoch2/Y=
=wkig
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---