Re: -bash: django-admin.py: command not found

2010-11-17 Thread ErritG
Hi Rob,

Thanks very much for your help. Installing Django properly solved all
the problems encountered!

Don't worry about being anything other then very helpful. Much
appreciated.

Errit.

On 16 nov, 12:40, Robbington  wrote:
> Thats ok, I can appriciate how frustrating it can be trying to learn
> of your own back from the beginning as a lot of the advice can seem to
> be in a foreign language. But if you dont understand you need to state
> that, as often if you double post people will just ignore you, noone
> gets paid to submit on these forums.
>
> Anyways, to your problem.
>
> Firstly, understand that python looks in the folder site-packages to
> find any additional packages like django. I'm guessing that your
> problem is that you have not installed Django properly, check to see
> if you have a folder in site-packages named Django.
>
> Secondly, Linux looks in the usr/bin folder for system commands. So
> When you type django-admin.py into the command prompt, linux looks in
> that folder and if it cant find djang-admin.py it returns that error
> you are seeing.
>
> At the command prompt: find / -name 'django' to make sure that there
> is a folder inside site-packages called django.
>
> How are you going about installing django? apt-get install,
> easy_install, pip install?
>
> As mentioned before creating a symbolic link isnt the best way to go
> about it, installing django properly is your best bet. You will save
> yourself a lot of trouble in the long run.
>
> But just getting it working is often half the learning battle, so if
> you feel you really need to, locate django-admin.py: find / -name
> 'django-admin.py'
>
> and make a symbolic link to your usr/bin folder. It should be located
> at /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
> site-packages/django/bin/django-admin.py
>
> So you would type: sudo ln -s /Library/Frameworks/Python.framework/
> Versions/2.7/lib/python2.7/site-packages/django/bin/django-admin.py /
> usr/bin.
>
> I hope I havnt been to condesending, just trying to put it in easy
> terms. I will however STRESS again, dont just create a symbolic link,
> install Django properly.
>
> Rob

-- 
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: Can I inport recaptcha?

2010-11-17 Thread Jitesh
Hi robos85,
If you really want to put recaptcha inside your project directory you
can do that also,
Simply download recaptcha-client from 
http://pypi.python.org/pypi/recaptcha-client.

Extract the package, then in the folder you'll find a recaptcha folder
> client > captcha.py file
copy this file into your project directory.

Get captcha public and private keys
and "import captcha" in your views, use it. :)
MikeKJ also said the same thing I just simplified it.

Thanks

On Nov 17, 5:24 pm, Brett Parker  wrote:
> On 17 Nov 04:14, robos85 wrote:
>
> > robo...@s27:~$ python setup.py install --home=~
> > python: can't open file 'setup.py': [Errno 2] No such file or
> > directory
>
> > That's what I get :/
>
> Now try doing it in the folder that you've unpacked recaptcha in...
> where the setup.py file is.
>
>
>
> > On 17 Lis, 12:48, Daniel Roseman  wrote:
> > > On Nov 17, 9:55 am, robos85  wrote:
>
> > > > I'm not guru in server side commands:)
> > > > I have access to command line. I'm in python console but don't know
> > > > what to do next to add this module. eazy_install requires root so I
> > > > can't just install it:/
>
> > > Sigh. For the third time: just run this command:
> > > python setup.py install --home=~
>
> > > You don't need to be root.
> > > --
> > > 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Brett Parker                    http://www.sommitrealweird.co.uk/
> PGP Fingerprint 1A9E C066 EDEE 6746 36CB  BD7F 479E C24F 95C7 1D61

-- 
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: representing a possible future object in a form?

2010-11-17 Thread Derek
It would be great if perhaps one of you could write up a more detailed
description (i.e with code) of this as a blog entry... or maybe a wiki page?


On 17 November 2010 18:10, bobhaugen  wrote:

> I've done this several times, and Toby's description is pretty much
> what I have done.
>
> Sometimes three levels of non-data-model classes to represent the
> matrix:
> a table class
> a row class
> a cell class
>
> Then formsets to populate the rows with data entry fields.
>
> Then builder methods to morph the data-model objects into the cells
> and rows, and from there to the formsets.  Usually one builder from
> data to matrix classes, and another from matrix rows to formsets.
>
> The formsets then populate the table rows.
>
> Then a template with a table to represent the table class, with
> formset form fields in the td's.
>
> Then deconstruction methods to morph the formset forms with entries
> back into the data-model objects.
>
> Might be a simpler way, but that works.
>
> --
> 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.



Re: ReportLab and Django - templates? ; FK object has no attribute split

2010-11-17 Thread natebeacham
Try using:

text = item.category.name

and

text = '%s' % item.subject.name

Rather than sending the entire FK field to ReportLab.

I don't necessarily see a problem with this logic in your view, as
you're just generating a file response. If it doesn't feel right, you
can throw this logic into a utility package (ie: something like
reports.py) and reference it from your view.

Cheers

On Nov 17, 3:55 pm, Victor Hooi  wrote:
> Hi,
>
> I'm trying to use ReportLab to produce a PDF output for one of my
> views.
>
> My first question is - at the moment, I'm building up the PDF inside
> my view. Is this really the recommended way of doing it? It's like
> I've got presentation code inside my view (controller). Isn't there a
> cleaner way of doing it, or going from a template to PDF somehow? (I
> know ReportLab offers a commercial package using RML templates,
> however I was hoping for an opensource/free method).
>
> Second question, I have a model with several FK fields. E.g.
>
>     class Article(models.Model):
>         category = models.ForeignKey(Category)
>         subject = models.ForeignKey(Subject)
>
> Both the category and subject classes have fields called "name", and
> __unicode__ methods defined which return name.
>
> I'm trying to refer to these fields in my PDF output. I have a list of
> items in article_list (i.e. queryset):
>
>     for item in article_list:
>         text = item.category
>         category = Paragraph(text, styles['Heading2'])
>         story.append(category)
>
>         text = '%s' % item.subject
>         subject = Paragraph(text, styles['Heading3'])
>         story.append(subject)
>
> When I try to run this code, I get:
>
>     'Category' object has no attribute 'split'
>
> and the same error with subject, obviously, once it gets to that bit
> of the code.
>
> Any idea why this might be, or how to fix it? Any help is much
> appreciated.
>
> Cheers,
> Victor

-- 
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.



Running Selenium unit tests -- no server running

2010-11-17 Thread Shawn Milochik
I installed the django-selenium-test-runner package and have finally
have almost everything working. Everything happens up through the
launch of the browser, but when it tries to hit the 127.0.0.1 there's
no connection. It appears that there's no test server running. I
obviously can't run it manually because the whole point is for it to
be running the test database created by the test runner.

Has anyone gotten this working?

My only alternative would be to create a script that makes an empty
test database, loads data from fixtures, run the dev server, and
manually run Selenium RC (which I can do). But I'm so close to
integrating Selenium to my unit tests and I really, really want to do
it.

Thanks,
Shawn

-- 
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: Newbie: can't login as user via standard admin login page

2010-11-17 Thread john doe
On Wed, Nov 17, 2010 at 5:48 PM, Thomas Schreiber  wrote:

> Are you sure the user has been marked as is_staff or is_superuser?
>
> http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.models.User.is_staff
>
> No the user is not marked as either because it is my goal to set up a
normal user. I did not know that only users with is_staff or superuser
status can log in via the admin console.

Is there an in-built view/page to easily let a user log in or do I have to
set up even the user login page and the associated view.

I tried going through the Django user auth docs but am not clear where
should I be putting in the python code for authenticating a user. Maybe I
need to set up a view leading to a form, accept the values and process it.

Thanks though :-)

> On Wed, Nov 17, 2010 at 18:26, bingbang 
> wrote:
> > Dear all,
> > Started learning Django 3 days ago. Great tutorials. Just
> > made a modified version of the poll app. I am now facing a small
> > problem, given my newbie-ishness with Python, its proving to be a
> > little hard to solve for me. I searched this group and did find some
> > similar issues reported, I tried out the suggestions but there is
> > probably something I am missing here. Any suggestions will be
> > great :-) .
> >
> > Problem: Can't login as a normal user via the standard
> http://127.0.0.1/admin/
> > page.
> > Can log in as admin, have created user account, have modified
> > permission, user account is active but still I get :Please enter a
> > correct username and passwd"
> >
> > I have entered user accounts via the shell and the web interface..
> > neither user accounts work. Point to note is that in my urls.py I have
> > not set up a view for users, I have also not written any login() code
> > for users, I assumed that a user can login via the admin interface. Is
> > this valid.
> >
> > I did read the /en/dev/faq/admin/ pages but it did not help a lot.
> >
> > Any suggestions are very appreciated.
> >
> > Thanks!
> >
> > --
> > 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.



Re: Newbie: can't login as user via standard admin login page

2010-11-17 Thread Thomas Schreiber
Are you sure the user has been marked as is_staff or is_superuser?
http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.models.User.is_staff

On Wed, Nov 17, 2010 at 18:26, bingbang  wrote:
> Dear all,
>             Started learning Django 3 days ago. Great tutorials. Just
> made a modified version of the poll app. I am now facing a small
> problem, given my newbie-ishness with Python, its proving to be a
> little hard to solve for me. I searched this group and did find some
> similar issues reported, I tried out the suggestions but there is
> probably something I am missing here. Any suggestions will be
> great :-) .
>
> Problem: Can't login as a normal user via the standard http://127.0.0.1/admin/
> page.
> Can log in as admin, have created user account, have modified
> permission, user account is active but still I get :Please enter a
> correct username and passwd"
>
> I have entered user accounts via the shell and the web interface..
> neither user accounts work. Point to note is that in my urls.py I have
> not set up a view for users, I have also not written any login() code
> for users, I assumed that a user can login via the admin interface. Is
> this valid.
>
> I did read the /en/dev/faq/admin/ pages but it did not help a lot.
>
> Any suggestions are very appreciated.
>
> Thanks!
>
> --
> 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.



Newbie: can't login as user via standard admin login page

2010-11-17 Thread bingbang
Dear all,
 Started learning Django 3 days ago. Great tutorials. Just
made a modified version of the poll app. I am now facing a small
problem, given my newbie-ishness with Python, its proving to be a
little hard to solve for me. I searched this group and did find some
similar issues reported, I tried out the suggestions but there is
probably something I am missing here. Any suggestions will be
great :-) .

Problem: Can't login as a normal user via the standard http://127.0.0.1/admin/
page.
Can log in as admin, have created user account, have modified
permission, user account is active but still I get :Please enter a
correct username and passwd"

I have entered user accounts via the shell and the web interface..
neither user accounts work. Point to note is that in my urls.py I have
not set up a view for users, I have also not written any login() code
for users, I assumed that a user can login via the admin interface. Is
this valid.

I did read the /en/dev/faq/admin/ pages but it did not help a lot.

Any suggestions are very appreciated.

Thanks!

-- 
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 admin filters and tagging

2010-11-17 Thread Daniel Jewett
Hello,
I have a model that looks like this:

class Item(models.Model):
...other fields...
tags = TagField()

I have not defined any additional methods for tagging on the model.

In admin.py:

class ItemAdmin(admin.ModelAdmin):
list_filter = ('featured', 'available', 'tags',)

In admin, the tagging app is working as it should, updates and
additions work properly. However the list of tags that shows up in the
right side tag filters list does not appear to update properly or is
displaying tags erroneously.
For example, an item tagged 'bagues crystal sconces appliques' (no
quotes) appears in the tagging app list as four different tags as it
should. In the filter list for 'items,' all four tags show up as one
link and do not show as individual tags.

Is there something else I need to do?

Thanks,
Dan J.

-- 
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.



ReportLab and Django - templates? ; FK object has no attribute split

2010-11-17 Thread Victor Hooi
Hi,

I'm trying to use ReportLab to produce a PDF output for one of my
views.

My first question is - at the moment, I'm building up the PDF inside
my view. Is this really the recommended way of doing it? It's like
I've got presentation code inside my view (controller). Isn't there a
cleaner way of doing it, or going from a template to PDF somehow? (I
know ReportLab offers a commercial package using RML templates,
however I was hoping for an opensource/free method).

Second question, I have a model with several FK fields. E.g.

class Article(models.Model):
category = models.ForeignKey(Category)
subject = models.ForeignKey(Subject)

Both the category and subject classes have fields called "name", and
__unicode__ methods defined which return name.

I'm trying to refer to these fields in my PDF output. I have a list of
items in article_list (i.e. queryset):

for item in article_list:
text = item.category
category = Paragraph(text, styles['Heading2'])
story.append(category)

text = '%s' % item.subject
subject = Paragraph(text, styles['Heading3'])
story.append(subject)

When I try to run this code, I get:

'Category' object has no attribute 'split'

and the same error with subject, obviously, once it gets to that bit
of the code.

Any idea why this might be, or how to fix it? Any help is much
appreciated.

Cheers,
Victor

-- 
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: Generic relations

2010-11-17 Thread Jonas Geiregat

Op 17-nov-2010, om 23:46 heeft Marc Aymerich het volgende geschreven:

 GenericPost.objects.get(pk=1).content_object.content


That's the strange thing. It just doesn't work:

Some code:


In [3]: GenericPost.objects.get(pk=1).content_object

In [4]: GenericPost.objects.get(pk=1).content_object.content
---
AttributeErrorTraceback (most recent call last)

/Users/Jonas/Webdesign/genericv/ in ()

AttributeError: 'NoneType' object has no attribute 'content'





Jonas Geiregat
jo...@geiregat.org




-- 
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: Caching user and auth data

2010-11-17 Thread Joe Kondel
I would second Russ' memcached recommendation.

We use custom authorization modules that do some obj level lookups in
addition to some other ACL type stuff. We've cut down seriously on the
amount of DB hits by:

1- Caching a lot of the more static type of authorization rulesets ( the
ACLs )
2- Using cache-then-db backed sessions to store certain types of credential
information.

Depending on your needs it could be as quick of a win as Russ' flag(s)
method or you might ( as I have ) run into some migraine inducing cache
invalidation strategies.

Good luck either way!

-j


On Wed, Nov 17, 2010 at 9:59 AM, Russ B. wrote:

> Authorize them against the DB the first time, then attach some flag to
> their session that represents "authorized" that your views check on
> instead of having them work with the auth models (or however you're
> doing it). If the "authorized" flag doesn't exist, redirect them to
> the login page.
>
> You may also be interested in reading about memcached and how to
> configure Django to work with it; it's cut back a lot of my own
> database hits.
>
> Russ B.
>
> On Nov 16, 10:34 pm, Jani Tiainen  wrote:
> > Hi,
> >
> > I've application that uses ajax and most of my views are protected by
> > @login_required decorator, some of them with additional permissions.
> >
> > Problem is now that I get lot of hits to database to check rather static
> > credential information.
> >
> > Is there way to cache these credentials so that I would hit database more
> > infrequently?
> >
> > --
> >
> > Jani Tiainen
>
> --
> 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.



Re: Generic relations

2010-11-17 Thread Marc Aymerich
On Wed, Nov 17, 2010 at 11:46 PM, Marc Aymerich  wrote:
> On Wed, Nov 17, 2010 at 11:36 PM, Jonas Geiregat  wrote:
>> Hello,
>>
>>  Can I use django's generic relations to create a model (GenericPost) that 
>> can point to other model (APost) or model (ReviewPost) ?
>>  And then use this GenericPost model to get a list of all latest APost's and 
>> ReviewPost's ?
>>
>> I've been trying this all day long but I couldn't get around the API.
>>
>> Here's what I've done:
>>
>> from django.db import models
>> from django.contrib.contenttypes.models import ContentType
>> from django.contrib.contenttypes import generic
>>
>>
>> # Create your models here.
>>
>> class Post(models.Model):
>>    title = models.CharField(max_length=100)
>>
>>    class Meta:
>>        abstract = True
>>
>> class APost(Post):
>>    content = models.CharField(max_length=100)
>>
>> class Review(Post):
>>    rcontent = models.CharField(max_length=100)
>>
>> class GenericPost(models.Model):
>>    content_type = models.ForeignKey(ContentType)
>>    object_id = models.PositiveIntegerField()
>>    content_object = generic.GenericForeignKey('content_type', 'object_id')
>>
>>
>> Some shell code trying to build up some data:
>>
>> In [1]: from genericv.foo.models import APost, GenericPost, Review
>>
>> In [2]: a = APost(content="something")
>>
>> In [3]: a.save()
>>
>> In [4]: g = GenericPost(content_object=a)
>>
>> In [5]: g.save()
>>
>> In [6]: GenericPost.objects.all()
>> Out[6]: [, > object>, , > object>]
>>
>>
>>
>> Why is it that I have 4 objects already when I only have created one ?
>
> I don't know, but I try your code and I get only one object:
>
 GenericPost.objects.all()
> []
>
>>And how do I access that particular object by using the GenericPost model ?
>
> I'm not a master of generic relations and I donk now if this way is
> the best of, but you can use content_object manager for retrieve the

content_object is not a manager, I apologize for the confusion here.


-- 
Marc

-- 
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: Generic relations

2010-11-17 Thread Marc Aymerich
On Wed, Nov 17, 2010 at 11:36 PM, Jonas Geiregat  wrote:
> Hello,
>
>  Can I use django's generic relations to create a model (GenericPost) that 
> can point to other model (APost) or model (ReviewPost) ?
>  And then use this GenericPost model to get a list of all latest APost's and 
> ReviewPost's ?
>
> I've been trying this all day long but I couldn't get around the API.
>
> Here's what I've done:
>
> from django.db import models
> from django.contrib.contenttypes.models import ContentType
> from django.contrib.contenttypes import generic
>
>
> # Create your models here.
>
> class Post(models.Model):
>    title = models.CharField(max_length=100)
>
>    class Meta:
>        abstract = True
>
> class APost(Post):
>    content = models.CharField(max_length=100)
>
> class Review(Post):
>    rcontent = models.CharField(max_length=100)
>
> class GenericPost(models.Model):
>    content_type = models.ForeignKey(ContentType)
>    object_id = models.PositiveIntegerField()
>    content_object = generic.GenericForeignKey('content_type', 'object_id')
>
>
> Some shell code trying to build up some data:
>
> In [1]: from genericv.foo.models import APost, GenericPost, Review
>
> In [2]: a = APost(content="something")
>
> In [3]: a.save()
>
> In [4]: g = GenericPost(content_object=a)
>
> In [5]: g.save()
>
> In [6]: GenericPost.objects.all()
> Out[6]: [,  object>, , ]
>
>
>
> Why is it that I have 4 objects already when I only have created one ?

I don't know, but I try your code and I get only one object:

>>> GenericPost.objects.all()
[]

>And how do I access that particular object by using the GenericPost model ?

I'm not a master of generic relations and I donk now if this way is
the best of, but you can use content_object manager for retrieve the
object:
>>> GenericPost.objects.get(pk=1).content_object.content
u'something'



>



-- 
Marc

-- 
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.



Generic relations

2010-11-17 Thread Jonas Geiregat
Hello,

 Can I use django's generic relations to create a model (GenericPost) that can 
point to other model (APost) or model (ReviewPost) ?
 And then use this GenericPost model to get a list of all latest APost's and 
ReviewPost's ?

I've been trying this all day long but I couldn't get around the API.

Here's what I've done:

from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic


# Create your models here.

class Post(models.Model):
title = models.CharField(max_length=100)

class Meta:
abstract = True

class APost(Post):
content = models.CharField(max_length=100)

class Review(Post):
rcontent = models.CharField(max_length=100)

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


Some shell code trying to build up some data:

In [1]: from genericv.foo.models import APost, GenericPost, Review

In [2]: a = APost(content="something")

In [3]: a.save()

In [4]: g = GenericPost(content_object=a)

In [5]: g.save()

In [6]: GenericPost.objects.all()
Out[6]: [, , 
, ]



Why is it that I have 4 objects already when I only have created one ? And how 
do I access that particular object by using the GenericPost model ?



Regards,

Jonas Geiregat
jo...@geiregat.org




-- 
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, Tornado and wsgi

2010-11-17 Thread Masarliev
Hi all,
I am using this approach to run django on tornado.
https://github.com/koblas/django-on-tornado
Everything is OK, but I need example how to run it with wsgi or
fastcgi
Is it possible?

-- 
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-reviews: cannot set content-type

2010-11-17 Thread Ian
I'm using django-reviews (http://code.google.com/p/django-reviews/)
and having trouble getting the content-type set for a review. Simple
example:

def check_review(request):
if request.method == 'POST':
reviewed_item = get_object_or_404(MyModel,
pk=request.POST['object_pk'])
review_form = ReviewForm(target_object=reviewed_item,
data=request.POST)
review_form.content_type =
ContentType.objects.get_for_model(MyModel)

However the form's 'content_type' field has no value and the form has
the error "(Hidden field content_type) This field is required." I've
tried to set the content_type multiple ways with no luck. Any ideas?

-- 
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: INSTALLED_APPS doesn't check my projet dir

2010-11-17 Thread Michael Sprayberry
Also make sure that in you app folder and every folder for that matter has a 
__init__.py that way python will view it as a module.

--- On Wed, 11/17/10, Shawn Milochik  wrote:


From: Shawn Milochik 
Subject: Re: INSTALLED_APPS doesn't check my projet dir
To: django-users@googlegroups.com
Date: Wednesday, November 17, 2010, 11:14 AM


When you put an app into INSTALLED_APPS, it looks on your PYTHONPATH.

If you make an app intended to be pluggable, your users should be
installing your application with pip or something, and your app code
will exist on the PYTHONPATH, not in a subfolder of their Django
project.

If you want to develop your app in a manner more like it will be used,
then put your app outside of your Django project, and on your
PYTHONPATH. That will allow (force) you to import it as another
developer who plugged in your app would.

Shawn

-- 
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.



Re: App for the index?

2010-11-17 Thread Jason Mayfield
I will often do this via direct_to_template to an index.html template and have 
a set of template tags that pull in the dynamic content like latest blog posts, 
etc.

On Nov 17, 2010, at 5:29 AM, eiriks wrote:

> Most tutorials I've read organize apps into a structure of this sort:
> 
> domain.com/blog
> domain.com/map
> domain.com/links
> domain.com/another_app
> 
> What about the index: how would an app (or a flatpage?) for that look
> like? An index typically includes some of the blogpost from the blog,
> some of the links from the link app and perhaps a teaser for the map
> app.
> 
> Any hints on getting started on this "app to rule them all"?
> 
> -- 
> 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.
> 

- Jason

-- 
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: App for the index?

2010-11-17 Thread Thomas Rega
IMHO - an simple extra view might be enough to reach what you are
looking for - I do not see the need for an extra app - Am I missing
something?

In the directory of domain.com/ there is a simple views.py file which
defines a simple callback function.


2010/11/17 robos85 :
> I'm also beginner. I made an index app and just added it in my urls:
> (r'^$', 'index.views.index'),
> :)
>
> On 17 Lis, 11:29, eiriks  wrote:
>> Most tutorials I've read organize apps into a structure of this sort:
>>
>> domain.com/blog
>> domain.com/map
>> domain.com/links
>> domain.com/another_app
>>
>> What about the index: how would an app (or a flatpage?) for that look
>> like? An index typically includes some of the blogpost from the blog,
>> some of the links from the link app and perhaps a teaser for the map
>> app.
>>
>> Any hints on getting started on this "app to rule them all"?
>
> --
> 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://thoreg.org/ ---

-- 
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: INSTALLED_APPS doesn't check my projet dir

2010-11-17 Thread Shawn Milochik
When you put an app into INSTALLED_APPS, it looks on your PYTHONPATH.

If you make an app intended to be pluggable, your users should be
installing your application with pip or something, and your app code
will exist on the PYTHONPATH, not in a subfolder of their Django
project.

If you want to develop your app in a manner more like it will be used,
then put your app outside of your Django project, and on your
PYTHONPATH. That will allow (force) you to import it as another
developer who plugged in your app would.

Shawn

-- 
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: representing a possible future object in a form?

2010-11-17 Thread bobhaugen
I've done this several times, and Toby's description is pretty much
what I have done.

Sometimes three levels of non-data-model classes to represent the
matrix:
a table class
a row class
a cell class

Then formsets to populate the rows with data entry fields.

Then builder methods to morph the data-model objects into the cells
and rows, and from there to the formsets.  Usually one builder from
data to matrix classes, and another from matrix rows to formsets.

The formsets then populate the table rows.

Then a template with a table to represent the table class, with
formset form fields in the td's.

Then deconstruction methods to morph the formset forms with entries
back into the data-model objects.

Might be a simpler way, but that works.

-- 
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.



INSTALLED_APPS doesn't check my projet dir

2010-11-17 Thread mrmclovin
Hey! Im kinda following the offcial tutorial but I set up my project
using another tutorial.

My Problem now is that I'm trying to include the 'polls' app in the
INSTALLED_APPS config. I must put "myproject.polls" to get it to work.
But that's not very pluggable since in my apps I must refer to
"myproject.polls.models" etc. How can I solve this?

My directory structure is set to:
/srv/websites/myproject

Django error page shows:
Python Path:['/srv/websites', '/usr/lib/python2.6', '/usr/lib/
python2.6/plat-linux2', ...]

It doesn't look in the project dir, why?

-- 
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: do we need MEDIA_ROOT and MEDIA_URL anymore?

2010-11-17 Thread Adam V.


On Nov 17, 2:07 am, MiratCanBayrak  wrote:
> Hi,
>
> I understood that in new version of django we are using
> STATICFILES_ROOT and STATICFILES_URL instead OF MEDIA_ROOT and
> MEDIA_URL.
>
> But when i look at settings.py i see both of them. When do we use
> MEDIA? when do we use STATICFILES ?
>
> Note: pls dont give link to docs i already read them

Staticfiles are for serving js/css/img that come with apps; Media is
for accepting uploads of files (and possibly also serving them back
out.)

-- 
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: Caching user and auth data

2010-11-17 Thread Russ B.
Authorize them against the DB the first time, then attach some flag to
their session that represents "authorized" that your views check on
instead of having them work with the auth models (or however you're
doing it). If the "authorized" flag doesn't exist, redirect them to
the login page.

You may also be interested in reading about memcached and how to
configure Django to work with it; it's cut back a lot of my own
database hits.

Russ B.

On Nov 16, 10:34 pm, Jani Tiainen  wrote:
> Hi,
>
> I've application that uses ajax and most of my views are protected by
> @login_required decorator, some of them with additional permissions.
>
> Problem is now that I get lot of hits to database to check rather static
> credential information.
>
> Is there way to cache these credentials so that I would hit database more
> infrequently?
>
> --
>
> Jani Tiainen

-- 
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 Dropdown List

2010-11-17 Thread Shawn Milochik
On Tue, Nov 16, 2010 at 9:08 AM, derek  wrote:
> " you'll have to have all the states/provinces as 'choices' in the
> ChoiceField in the form, otherwise the form won't validate."
>
> Yup, this is a "real" gotcha.  IMO, its not really true filtering if
> you take this approach, as the initial form will still load the X
> million items, even though the user will only be shown a fraction at a
> time.
>

While this is the case, there's no reason you can't just accept and
validate the input yourself, and not make use of a Django forms.Form.
It's annoying, but nothing compared to writing, say, PHP or ASP
without a framework.

Hmmm. I think I'll search the tickets and see if some kind of "choices
= any" proposal has been made already.

Shawn

-- 
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: how to add poll app in Admin page

2010-11-17 Thread Robbington
when i added the Admin class to Poll class as inner class,

Guess you mean when you register your poll app with django admin?

Check a few things of the list.

You have added your poll app to 'installed apps' in your projects
settings.py file and ran 'python manage.py syncdb'

You have created a new file named admin,py in your poll app folder
that looks like this?

//admin.py//
from polls.models import Poll
from django.contrib import admin

admin.site.register(Poll)


-- 
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: how to add poll app in Admin page

2010-11-17 Thread Daniel Roseman
On Nov 17, 1:48 pm, frank  wrote:
> hi all
>
> i followed each step in tutorial to create poll app...i am able to see
> the admin page...when i added the Admin class to Poll class as inner
> class, i am not getting the poll app interface in admin page..what to
> do>>>

You must be following a very old tutorial. It's been over two years
since it was correct to use an inner Admin class. Where did you see
that tutorial? Why aren't you following the one linked to from the
actual live documentation:
http://docs.djangoproject.com/en/1.2/
--
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-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.



how to add poll app in Admin page

2010-11-17 Thread frank
hi all

i followed each step in tutorial to create poll app...i am able to see
the admin page...when i added the Admin class to Poll class as inner
class, i am not getting the poll app interface in admin page..what to
do>>>

-- 
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: Can I inport recaptcha?

2010-11-17 Thread Brett Parker
On 17 Nov 04:14, robos85 wrote:
> robo...@s27:~$ python setup.py install --home=~
> python: can't open file 'setup.py': [Errno 2] No such file or
> directory
> 
> That's what I get :/

Now try doing it in the folder that you've unpacked recaptcha in...
where the setup.py file is.

> On 17 Lis, 12:48, Daniel Roseman  wrote:
> > On Nov 17, 9:55 am, robos85  wrote:
> >
> > > I'm not guru in server side commands:)
> > > I have access to command line. I'm in python console but don't know
> > > what to do next to add this module. eazy_install requires root so I
> > > can't just install it:/
> >
> > Sigh. For the third time: just run this command:
> >     python setup.py install --home=~
> >
> > You don't need to be root.
> > --
> > 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-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.
> 
> 

-- 
Brett Parker http://www.sommitrealweird.co.uk/
PGP Fingerprint 1A9E C066 EDEE 6746 36CB  BD7F 479E C24F 95C7 1D61

-- 
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: Can I inport recaptcha?

2010-11-17 Thread Tom Evans
On Wed, Nov 17, 2010 at 12:14 PM, robos85  wrote:
> robo...@s27:~$ python setup.py install --home=~
> python: can't open file 'setup.py': [Errno 2] No such file or
> directory
>
> That's what I get :/
>

Run it in the directory containing the extracted library you wish to
install (big hint, it will have a file called 'setup.py' in it)

You may also like to check out some python tutorials..

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-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: Can I inport recaptcha?

2010-11-17 Thread robos85
robo...@s27:~$ python setup.py install --home=~
python: can't open file 'setup.py': [Errno 2] No such file or
directory

That's what I get :/

On 17 Lis, 12:48, Daniel Roseman  wrote:
> On Nov 17, 9:55 am, robos85  wrote:
>
> > I'm not guru in server side commands:)
> > I have access to command line. I'm in python console but don't know
> > what to do next to add this module. eazy_install requires root so I
> > can't just install it:/
>
> Sigh. For the third time: just run this command:
>     python setup.py install --home=~
>
> You don't need to be root.
> --
> 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-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: Can I inport recaptcha?

2010-11-17 Thread Daniel Roseman
On Nov 17, 9:55 am, robos85  wrote:
> I'm not guru in server side commands:)
> I have access to command line. I'm in python console but don't know
> what to do next to add this module. eazy_install requires root so I
> can't just install it:/

Sigh. For the third time: just run this command:
python setup.py install --home=~

You don't need to be root.
--
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-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: Can I inport recaptcha?

2010-11-17 Thread robos85
Thanks :)

On 17 Lis, 11:27, MikeKJ  wrote:
> Think it came from either django snippets or recaptcha but it is open source
> and been using it for a while
> as it works a treat.
>
> This is a mickey mouse site put together for one of my bosses that uses it
> sohttp://www.proofofpurchase.co.uk
> go look at register and you can see it works
>
> all the code I pasted to this thread came from that site
>
> --
> View this message in 
> context:http://old.nabble.com/Can-I-inport-recaptcha--tp30236419p30236891.html
> Sent from the django-users mailing list archive at Nabble.com.

-- 
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: App for the index?

2010-11-17 Thread robos85
I'm also beginner. I made an index app and just added it in my urls:
(r'^$', 'index.views.index'),
:)

On 17 Lis, 11:29, eiriks  wrote:
> Most tutorials I've read organize apps into a structure of this sort:
>
> domain.com/blog
> domain.com/map
> domain.com/links
> domain.com/another_app
>
> What about the index: how would an app (or a flatpage?) for that look
> like? An index typically includes some of the blogpost from the blog,
> some of the links from the link app and perhaps a teaser for the map
> app.
>
> Any hints on getting started on this "app to rule them all"?

-- 
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.



App for the index?

2010-11-17 Thread eiriks
Most tutorials I've read organize apps into a structure of this sort:

domain.com/blog
domain.com/map
domain.com/links
domain.com/another_app

What about the index: how would an app (or a flatpage?) for that look
like? An index typically includes some of the blogpost from the blog,
some of the links from the link app and perhaps a teaser for the map
app.

Any hints on getting started on this "app to rule them all"?

-- 
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: Can I inport recaptcha?

2010-11-17 Thread MikeKJ

Think it came from either django snippets or recaptcha but it is open source
and been using it for a while
as it works a treat.

This is a mickey mouse site put together for one of my bosses that uses it
so
http://www.proofofpurchase.co.uk
go look at register and you can see it works

all the code I pasted to this thread came from that site

-- 
View this message in context: 
http://old.nabble.com/Can-I-inport-recaptcha--tp30236419p30236891.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
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.



do we need MEDIA_ROOT and MEDIA_URL anymore?

2010-11-17 Thread MiratCanBayrak
Hi,

I understood that in new version of django we are using
STATICFILES_ROOT and STATICFILES_URL instead OF MEDIA_ROOT and
MEDIA_URL.

But when i look at settings.py i see both of them. When do we use
MEDIA? when do we use STATICFILES ?

Note: pls dont give link to docs i already read them

-- 
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 user registration email issues in dev enviroment

2010-11-17 Thread Johannes Nel
in case someone runs into this in the future, i had to set the default
from email to get it to work.


DEFAULT_FROM_EMAIL = 'sam...@domain.com'

nicer error messages would have been, well nice.

On Wed, Nov 17, 2010 at 9:52 AM, Johannes Nel  wrote:
> ok, I decided to switch to one of my SMTP servers I know works and
> which I send email from on my local machine via a java app I have.
>
> now I get a very non descriptive error
>
> Environment:
>
> Request Method: POST
> Request URL: http://localhost:8000/accounts/register/
> Django Version: 1.2.3
> Python Version: 2.7.0
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.messages',
>  'registration',
>  'django.contrib.admin']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware')
>
>
> Traceback:
> File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>  100.                     response = callback(request,
> *callback_args, **callback_kwargs)
> File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_registration-0.7-py2.7.egg/registration/views.py"
> in register
>  148.             new_user = form.save(profile_callback=profile_callback)
> File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_registration-0.7-py2.7.egg/registration/forms.py"
> in save
>  87.
>   profile_callback=profile_callback)
> File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_registration-0.7-py2.7.egg/registration/models.py"
> in create_inactive_user
>  127.             send_mail(subject, message,
> settings.DEFAULT_FROM_EMAIL, [new_user.email])
> File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/mail/__init__.py"
> in send_mail
>  61.                         connection=connection).send()
> File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/mail/message.py"
> in send
>  175.         return self.get_connection(fail_silently).send_messages([self])
> File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/mail/backends/smtp.py"
> in send_messages
>  85.                 sent = self._send(message)
> File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/mail/backends/smtp.py"
> in _send
>  101.                     email_message.message().as_string())
> File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py"
> in sendmail
>  712.             raise SMTPRecipientsRefused(senderrs)
>
> Exception Type: SMTPRecipientsRefused at /accounts/register/
> Exception Value: {u'xxx.x...@gmail.com': (451, 'Temporary local
> problem - please try later')}
>
> temporary local problem!!! SAY WHAT! this is not me using the postfix
> aliases I created.
>
> On Wed, Nov 17, 2010 at 9:33 AM, Johannes Nel  wrote:
>> Hi
>>
>> My dev enviroment is OS x 10.5
>> I grabbed the django registration application and configured it to
>> email via my local host spooler. After which I setup postfix alias's
>> for some dummy domains, these I tested from command line and my emails
>> are coming through. Then i proceed to get the register application to
>> try and send an email, so i can verify that things are working, but I
>> get a socket error saying that it could not connect. I double checked
>> and I have opened port 465 on my machine (by default I block
>> everything), any advice on where to look next?
>>
>> johan
>>
>> --
>> j:pn
>> \\no comment
>>
>
>
>
> --
> j:pn
> \\no comment
>



-- 
j:pn
\\no comment

-- 
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: Can I inport recaptcha?

2010-11-17 Thread robos85
Is it from some special source, or it's your own code:)
I could search it maybe on recaptcha site?

On 17 Lis, 10:40, MikeKJ  wrote:
> Ahh sorry m8 I forgot to add this
>  in the root of your project directory add captcha.py
>
> which is this
> -
>
> import urllib2, urllib
>
> API_SSL_SERVER="https://api-secure.recaptcha.net";
> API_SERVER="http://api.recaptcha.net";
> VERIFY_SERVER="api-verify.recaptcha.net"
>
> class RecaptchaResponse(object):
>     def __init__(self, is_valid, error_code=None):
>         self.is_valid = is_valid
>         self.error_code = error_code
>
> def displayhtml (public_key,
>                  use_ssl = False,
>                  error = None):
>     """Gets the HTML to display for reCAPTCHA
>
>     public_key -- The public api key
>     use_ssl -- Should the request be sent over ssl?
>     error -- An error message to display (from
> RecaptchaResponse.error_code)"""
>
>     error_param = ''
>     if error:
>         error_param = '&error=%s' % error
>
>     if use_ssl:
>         server = API_SSL_SERVER
>     else:
>         server = API_SERVER
>
>     return """ src="%(ApiServer)s/challenge?k=%(PublicKey)s%(ErrorParam)s">
>
> 
>    height="300" width="500" frameborder="0">
>   
>    value='manual_challenge' />
> 
> """ % {
>         'ApiServer' : server,
>         'PublicKey' : public_key,
>         'ErrorParam' : error_param,
>         }
>
> def submit (recaptcha_challenge_field,
>             recaptcha_response_field,
>             private_key,
>             remoteip):
>     """
>     Submits a reCAPTCHA request for verification. Returns RecaptchaResponse
>     for the request
>
>     recaptcha_challenge_field -- The value of recaptcha_challenge_field from
> the form
>     recaptcha_response_field -- The value of recaptcha_response_field from
> the form
>     private_key -- your reCAPTCHA private key
>     remoteip -- the user's ip address
>     """
>     if not (recaptcha_response_field and recaptcha_challenge_field and
>             len (recaptcha_response_field) and len
> (recaptcha_challenge_field)):
>         return RecaptchaResponse (is_valid = False, error_code =
> 'incorrect-captcha-sol')
>
>     def encode_if_necessary(s):
>         if isinstance(s, unicode):
>             return s.encode('utf-8')
>         return s
>
>     params = urllib.urlencode ({
>             'privatekey': encode_if_necessary(private_key),
>             'remoteip' :  encode_if_necessary(remoteip),
>             'challenge':  encode_if_necessary(recaptcha_challenge_field),
>             'response' :  encode_if_necessary(recaptcha_response_field),
>             })
>
>     request = urllib2.Request (
>         url = "http://%s/verify"; % VERIFY_SERVER,
>         data = params,
>         headers = {
>             "Content-type": "application/x-www-form-urlencoded",
>             "User-agent": "reCAPTCHA Python"
>             }
>         )
>
>     httpresp = urllib2.urlopen (request)
>
>     return_values = httpresp.read ().splitlines ();
>     httpresp.close();
>
>     return_code = return_values [0]
>
>     if (return_code == "true"):
>         return RecaptchaResponse (is_valid=True)
>     else:
>         return RecaptchaResponse (is_valid=False, error_code = return_values
> [1])
>
> --
> View this message in 
> context:http://old.nabble.com/Can-I-inport-recaptcha--tp30236419p30236595.html
> Sent from the django-users mailing list archive at Nabble.com.

-- 
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: Can I inport recaptcha?

2010-11-17 Thread robos85
I'm not guru in server side commands:)
I have access to command line. I'm in python console but don't know
what to do next to add this module. eazy_install requires root so I
can't just install it:/

On 17 Lis, 10:39, Daniel Roseman  wrote:
> On Nov 17, 9:28 am, robos85  wrote:
>
> > So, it's not possible to import it just from my project dir?
> > The only way it to ask my hosting provider to install it? I have SSH
> > terminal but I wanted it to be more portable and put it in my
> > project:/
>
> That's completely the opposite of what I just said. I just said that
> you *can* install it yourself locally, in your home directory or in a
> virtualenv.
>
> Really, try the command I gave before, or even better look into
> virtualenv - there are plenty of tutorials available on how to run a
> Django site in shared hosting with virtualenv.
> --
> 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-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: Nested Categories in Admin

2010-11-17 Thread Federico Capoano
Sorry I couldn't find anything, I'll search more.


On Nov 16, 3:00 pm, derek  wrote:
> You will need to use Javascipt: handwritten or via framework e.g.
> JQuery. Its been asked about before on this mailing list and numerous
> people have blogged on it.
>
> On Nov 16, 11:58 am, Federico Capoano 
> wrote:
>
>
>
>
>
>
>
> > Any suggestion?
>
> > On Nov 14, 6:15 pm, Federico Capoano  wrote:
>
> > > Hi all,
>
> > > I would like to find a way to get categories and subcategories
> > > displayed in the admin, in the form of a multiple select.
>
> > > Like:
>
> > > parent
> > > child1
> > > child2
> > > parent2
> > > child3
>
> > > Do I have to make a custom field or is there already a solution
> > > around?
>
> > > Thanks

-- 
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 user registration email issues in dev enviroment

2010-11-17 Thread Johannes Nel
ok, I decided to switch to one of my SMTP servers I know works and
which I send email from on my local machine via a java app I have.

now I get a very non descriptive error

Environment:

Request Method: POST
Request URL: http://localhost:8000/accounts/register/
Django Version: 1.2.3
Python Version: 2.7.0
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'registration',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_registration-0.7-py2.7.egg/registration/views.py"
in register
  148. new_user = form.save(profile_callback=profile_callback)
File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_registration-0.7-py2.7.egg/registration/forms.py"
in save
  87.
   profile_callback=profile_callback)
File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_registration-0.7-py2.7.egg/registration/models.py"
in create_inactive_user
  127. send_mail(subject, message,
settings.DEFAULT_FROM_EMAIL, [new_user.email])
File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/mail/__init__.py"
in send_mail
  61. connection=connection).send()
File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/mail/message.py"
in send
  175. return self.get_connection(fail_silently).send_messages([self])
File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/mail/backends/smtp.py"
in send_messages
  85. sent = self._send(message)
File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/mail/backends/smtp.py"
in _send
  101. email_message.message().as_string())
File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py"
in sendmail
  712. raise SMTPRecipientsRefused(senderrs)

Exception Type: SMTPRecipientsRefused at /accounts/register/
Exception Value: {u'xxx.x...@gmail.com': (451, 'Temporary local
problem - please try later')}

temporary local problem!!! SAY WHAT! this is not me using the postfix
aliases I created.

On Wed, Nov 17, 2010 at 9:33 AM, Johannes Nel  wrote:
> Hi
>
> My dev enviroment is OS x 10.5
> I grabbed the django registration application and configured it to
> email via my local host spooler. After which I setup postfix alias's
> for some dummy domains, these I tested from command line and my emails
> are coming through. Then i proceed to get the register application to
> try and send an email, so i can verify that things are working, but I
> get a socket error saying that it could not connect. I double checked
> and I have opened port 465 on my machine (by default I block
> everything), any advice on where to look next?
>
> johan
>
> --
> j:pn
> \\no comment
>



-- 
j:pn
\\no comment

-- 
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: Can I inport recaptcha?

2010-11-17 Thread MikeKJ

Ahh sorry m8 I forgot to add this
 in the root of your project directory add captcha.py

which is this
-

import urllib2, urllib

API_SSL_SERVER="https://api-secure.recaptcha.net";
API_SERVER="http://api.recaptcha.net";
VERIFY_SERVER="api-verify.recaptcha.net"

class RecaptchaResponse(object):
def __init__(self, is_valid, error_code=None):
self.is_valid = is_valid
self.error_code = error_code

def displayhtml (public_key,
 use_ssl = False,
 error = None):
"""Gets the HTML to display for reCAPTCHA

public_key -- The public api key
use_ssl -- Should the request be sent over ssl?
error -- An error message to display (from
RecaptchaResponse.error_code)"""

error_param = ''
if error:
error_param = '&error=%s' % error

if use_ssl:
server = API_SSL_SERVER
else:
server = API_SERVER

return """


  
  
  

""" % {
'ApiServer' : server,
'PublicKey' : public_key,
'ErrorParam' : error_param,
}


def submit (recaptcha_challenge_field,
recaptcha_response_field,
private_key,
remoteip):
"""
Submits a reCAPTCHA request for verification. Returns RecaptchaResponse
for the request

recaptcha_challenge_field -- The value of recaptcha_challenge_field from
the form
recaptcha_response_field -- The value of recaptcha_response_field from
the form
private_key -- your reCAPTCHA private key
remoteip -- the user's ip address
"""
if not (recaptcha_response_field and recaptcha_challenge_field and
len (recaptcha_response_field) and len
(recaptcha_challenge_field)):
return RecaptchaResponse (is_valid = False, error_code =
'incorrect-captcha-sol')


def encode_if_necessary(s):
if isinstance(s, unicode):
return s.encode('utf-8')
return s

params = urllib.urlencode ({
'privatekey': encode_if_necessary(private_key),
'remoteip' :  encode_if_necessary(remoteip),
'challenge':  encode_if_necessary(recaptcha_challenge_field),
'response' :  encode_if_necessary(recaptcha_response_field),
})

request = urllib2.Request (
url = "http://%s/verify"; % VERIFY_SERVER,
data = params,
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-agent": "reCAPTCHA Python"
}
)

httpresp = urllib2.urlopen (request)

return_values = httpresp.read ().splitlines ();
httpresp.close();

return_code = return_values [0]

if (return_code == "true"):
return RecaptchaResponse (is_valid=True)
else:
return RecaptchaResponse (is_valid=False, error_code = return_values
[1])




-- 
View this message in context: 
http://old.nabble.com/Can-I-inport-recaptcha--tp30236419p30236595.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
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: Can I inport recaptcha?

2010-11-17 Thread Daniel Roseman
On Nov 17, 9:28 am, robos85  wrote:
> So, it's not possible to import it just from my project dir?
> The only way it to ask my hosting provider to install it? I have SSH
> terminal but I wanted it to be more portable and put it in my
> project:/

That's completely the opposite of what I just said. I just said that
you *can* install it yourself locally, in your home directory or in a
virtualenv.

Really, try the command I gave before, or even better look into
virtualenv - there are plenty of tutorials available on how to run a
Django site in shared hosting with virtualenv.
--
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-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 user registration email issues in dev enviroment

2010-11-17 Thread Johannes Nel
Hi

My dev enviroment is OS x 10.5
I grabbed the django registration application and configured it to
email via my local host spooler. After which I setup postfix alias's
for some dummy domains, these I tested from command line and my emails
are coming through. Then i proceed to get the register application to
try and send an email, so i can verify that things are working, but I
get a socket error saying that it could not connect. I double checked
and I have opened port 465 on my machine (by default I block
everything), any advice on where to look next?

johan

-- 
j:pn
\\no comment

-- 
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: Can I inport recaptcha?

2010-11-17 Thread robos85
Yes - but import captcha gives me ERROR: Could not import index.views.
Error was: No module named captcha
I have to put it somewhere and want to avoid adding it as Python
module but as local package

On 17 Lis, 10:28, MikeKJ  wrote:
> you can use recaptcha directly in the form view
>
> add PUBLIC_KEY and PRIVATE_KEY to settings.py
>
> in the view of the form add
>
> import captcha
> from django.conf import settings
>
>     if request.method == "POST":
>         check_captcha =
> captcha.submit(request.POST['recaptcha_challenge_field'],
> request.POST['recaptcha_response_field'], settings.RECAPTCHA_PRIVATE_KEY,
> request.META['REMOTE_ADDR'])
>         if check_captcha.is_valid is False:
>             return HttpResponseRedirect('/user/register/')
>         userform = UserForm(request.POST) ...etc.
>
>     html_captcha = captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY)
>     return render_to_response("userprofile/join_form.html", {'userform':
> userform, 'content' : content, 'html_captcha': html_captcha,
>
> },context_instance=RequestContext(request))
>
> then in the template
>
> {{ userform.as_p }}
> {{ html_captcha }}
>
> 
>
> --
> View this message in 
> context:http://old.nabble.com/Can-I-inport-recaptcha--tp30236419p30236526.html
> Sent from the django-users mailing list archive at Nabble.com.

-- 
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: Can I inport recaptcha?

2010-11-17 Thread robos85
So, it's not possible to import it just from my project dir?
The only way it to ask my hosting provider to install it? I have SSH
terminal but I wanted it to be more portable and put it in my
project:/

On 17 Lis, 10:25, Daniel Roseman  wrote:
> On Nov 17, 9:11 am, robos85  wrote:
>
> > Hi,
> > I want to use reCaptcha on my site. It requires to add recaptcha
> > module. Is it possible to not to add this to python modules, but place
> > somewhere in my app, and then import it from there?
>
> > I placed it in my project main dir, co path looks like this: /project/
> > customlibs/recaptcha/...
> > I try to import it in my view:
> > from project.customlibs.recaptcha.client import captcha
> > It says: Could not import index.views. Error was: No module named
> > customlibs.recaptcha.client
>
> > It would be nice not to have to install it as Python module (shared
> > hosting server).
>
> Just because you're on shared hosting, it doesn't mean you can't
> install library modules. You can either install them in your own local
> lib directory (with `python setup.py install --home=~`), or even
> better use a virtualenv and install them inside that.
> --
> 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-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: Can I inport recaptcha?

2010-11-17 Thread MikeKJ

you can use recaptcha directly in the form view

add PUBLIC_KEY and PRIVATE_KEY to settings.py

in the view of the form add

import captcha
from django.conf import settings


if request.method == "POST":
check_captcha =
captcha.submit(request.POST['recaptcha_challenge_field'],
request.POST['recaptcha_response_field'], settings.RECAPTCHA_PRIVATE_KEY,
request.META['REMOTE_ADDR'])
if check_captcha.is_valid is False:
return HttpResponseRedirect('/user/register/')
userform = UserForm(request.POST) ...etc.

html_captcha = captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY)
return render_to_response("userprofile/join_form.html", {'userform':
userform, 'content' : content, 'html_captcha': html_captcha,
},context_instance=RequestContext(request))


then in the template

{{ userform.as_p }}
{{ html_captcha }}







-- 
View this message in context: 
http://old.nabble.com/Can-I-inport-recaptcha--tp30236419p30236526.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
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: Can I inport recaptcha?

2010-11-17 Thread Daniel Roseman
On Nov 17, 9:11 am, robos85  wrote:
> Hi,
> I want to use reCaptcha on my site. It requires to add recaptcha
> module. Is it possible to not to add this to python modules, but place
> somewhere in my app, and then import it from there?
>
> I placed it in my project main dir, co path looks like this: /project/
> customlibs/recaptcha/...
> I try to import it in my view:
> from project.customlibs.recaptcha.client import captcha
> It says: Could not import index.views. Error was: No module named
> customlibs.recaptcha.client
>
> It would be nice not to have to install it as Python module (shared
> hosting server).

Just because you're on shared hosting, it doesn't mean you can't
install library modules. You can either install them in your own local
lib directory (with `python setup.py install --home=~`), or even
better use a virtualenv and install them inside that.
--
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-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.



Can I inport recaptcha?

2010-11-17 Thread robos85
Hi,
I want to use reCaptcha on my site. It requires to add recaptcha
module. Is it possible to not to add this to python modules, but place
somewhere in my app, and then import it from there?

I placed it in my project main dir, co path looks like this: /project/
customlibs/recaptcha/...
I try to import it in my view:
from project.customlibs.recaptcha.client import captcha
It says: Could not import index.views. Error was: No module named
customlibs.recaptcha.client


It would be nice not to have to install it as Python module (shared
hosting server).

-- 
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.