Re: PyDev create new project wizard creates two folders in Aptana Studio 3?

2010-10-05 Thread Brandon Taylor
Hi Guys,

Yeah, I've just been creating projects by hand instead of using the
new PyDev Django actions. Fabio said it's because the project you
create has to be added to the Python Path, and it can't add a folder
that is above the path for some reason. Annoying.

Cheers,
Brandon

On Oct 5, 3:35 pm, Sandro Dutra  wrote:
> When you try to create a project, Aptana duplicates the root directory
> automatically. A issue...
>
> To correct this, you only have to observe the path when you're creating the
> Django project.
>
> 2010/10/2 payala 
>
>
>
> > Check if you are in the python perspective
>
> > On 1 oct, 19:34, Brandon Taylor  wrote:
> > > Hi everyone,
>
> > > I'm used to organizing my Django projects in one folder for the
> > > project and then sub folders for app modules...
>
> > > /my_project
> > >     -__init__.py
> > >     -settings.py
> > >     /some_app
>
> > > and so on. However, when I create a new Django project using the PyDev
> > > wizard, I get:
>
> > > /my_project
> > >     /my_project
> > >         -__init__.py
> > >         -settings.py
>
> > > Why is that?
>
> > > TIA,
> > > Brandon
>
> > --
> > 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.



Confused about testing a page protected with @login_required

2010-10-05 Thread Brandon Taylor
Hi everyone,

I set up a bare-bones project with one view decorated with
@login_required.
I created an initial_data.json fixture with a user.
I called self.client.login(username='foobar', passowrd='foobar') and
it returned True.
I assigned a response variable from self.client.get('/protected/')

and self.assertEqual(response.status_code, 200) fails.

Instead, it's returning a 302 to 'http://testserver/accounts/login/?
next=/protected
Why is that?

Here is my test case:

class SimpleTest(TestCase):
def test_protected(self):
logged_in = self.client.login(username='foobar',
passowrd='foobar')
self.failUnless(logged_in)

response = self.client.get('/protected/')
self.assertEqual(response.status_code, 200)

Which results in:
AssertionError: 302 != 200

What am I doing wrong? Any help GREATLY appreciated!
Brandon

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



Getting to manytomany objects from a form in the view, before saving to the database

2010-10-05 Thread chefsmart
(FYI - this is also on stackoverflow, awaiting answers)

For the following models: -

class Item(models.Model):
name = models.CharField(max_length=150)
value = models.DecimalField(max_digits=12,decimal_places=2)

class Organization(models.Model):
name = models.CharField(max_length=150)
items = models.ManyToManyField(Item, through='Customizable')

class Customizable(models.Model):
organization = models.ForeignKey(Organization)
item = models.ForeignKey (Item)
value = models.DecimalField(max_digits=12,decimal_places=2)

With the following form: -

class AssignItemsForm(forms.ModelForm):
items =
forms.ModelMultipleChoiceField(queryset=Item.objects.all(),required=False,widget=forms.CheckboxSelectMultiple)
class Meta:
model = Organization
exclude = ('name',)

How would I access the individual items that were checked after
form.is_valid and after form.save(commit=False)
 in the view?

Regards,
CM.

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



unit test :how to call a single test method alone

2010-10-05 Thread jimgardener
hi
In my application,I have the following structure for tests

myapp---__init__.py
|
|
tests- __init__.py #contains from functional import * from utility
import *
   |
   |
   functional - __init__.py
   |
-utility__init__.py #from myutil_tests import *
|
myutil_tests.py

in myutil_tests.py ,I have

import unittest
class UtilTests(unittest.TestCase):
def setUp(self):
   pass

def test_some_testA(self):
...

def test_some_testB(self):
...

When I run python manage.py test myapp  ,all the given tests are
executed.I would like to know ,how I can call test_some_testA() alone.
I tried python manage.py test
myapp.utility.myutil_tests.UtilTests.test_some_testA
but I am getting

ValueError: Test label
'myapp.utility.myutil_tests.UtilTests.test_some_testA' should be of
the form app.TestCase or app.TestCase.test_method

Can someone help me correct this?

thanks
jim

-- 
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: Where to create a Mezzanine project

2010-10-05 Thread Stephen McDonald
For anyone who comes along at a later point looking for an answer to
this, it was provided on the mezzanine-users mailing list.

http://groups.google.com/group/mezzanine-users/browse_thread/thread/c8b13c41a3168c94

Cheers,
Steve

On Oct 5, 7:37 am, Sithembewena Lloyd Dube  wrote:
> Hi Ken,
>
> Thought so too. I guess I am trying to figure out if I could have a nested
> project (mezzanine) inside my Django project?
>
>
>
>
>
>
>
>
>
> On Tue, Oct 5, 2010 at 1:04 PM, Kenneth Gonsalves  wrote:
> > On Tue, 2010-10-05 at 12:43 +0200, Sithembewena Lloyd Dube wrote:
> > > I have installed Mezzanine and would like to know where in my main
> > > Django
> > > project I should run mezzanine-project. Is it recommended to create
> > > the
> > > mezzanine-project inside the Django project, or outside it?
>
> > > The mezzanine project will integrate blogs in the main Django
> > > project.
>
> > from what I can see, mezzanine is not an app to run inside a 'main'
> > django project, but a standalone project of it's own - I could be wrong
> > as I have not tried it out.
> > --
> > regards
> > Kenneth Gonsalves
>
> > --
> > 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 > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Regards,
> Sithembewena Lloyd Dubehttp://www.lloyddube.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.



inner join and only method

2010-10-05 Thread refreegrata
Hello list. I'm have a questio. if I have an "inner join" query an use
an "only" restriction, how can i put a field of the second table in
the "only" tuple?

Example:

Model
-
class Abc(models.Model):
fk_user = models.ForeignKey(User, related_name='user_pp')
fk_ee = models.ForeignKey(Dd, related_name='dd_dd')
ccc = models.BooleanField(default=False)

And my query

User.objects.filter(user_pp__fk_departamento='aa'].id).only('username')

But i want to do something like

User.objects.filter(user_pp__fk_departamento='aa'].id).only('username',
'ccc')
or
User.objects.filter(user_pp__fk_departamento='aa'].id).only('username',
'user_pp__ccc')
but that's don't work. How i can put the ccc field inside the 'only'
tuple.

Thanks for read,a and sorry for my poor english.

-- 
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 Registration password reset problem

2010-10-05 Thread Joel Klabo
Ok, so I'm pretty sure this has to do with the fact that the
post_reset_redirect argument defaults to the
django.contrib.auth.views.password_reset_done if no
post_reset_redirect is passed to the view. I am using django-
registration and it seems like there would be a better way to deal
with this... There is something I'm missing. If anyone has used this
and gotten it to work I would be grateful to hear about it. All the
other parts of the registration system work which makes me think this
has something to do with the fact that it is reverting back to the
django.contrib views and now using the ones that come with django-
registration... Here is the view where the error first pops up, this
is where post_reset_redirect is as well: http://dpaste.org/gatU/

Thanks for your time



On Oct 5, 1:56 pm, Steve Holden  wrote:
> On 10/5/2010 4:45 PM, Joel Klabo wrote:> Need to bump this, sorry. I don't 
> get it.
>
> > On Oct 5, 1:04 pm, Joel Klabo  wrote:
> >> This is the error and location of the 
> >> problem:http://gist.github.com/612210,
> >> I can't see what it's looking for. It seems like I could hard code the
> >> arguments it wants into the reverse() but that doesn't seem like the
> >> correct way to do it. Any advice?
>
> I can quite see how 41 minutes would appear to be an infinity to someone
> who is wanting the answer to a problem. Please remember, though, that
> people who post on this list aren't paid to do so, and mostly have
> full-time jobs.
>
> So a little patience will make it more likely people will help you.
>
> regards
>  Steve
> --
> DjangoCon US 2010 September 7-9http://djangocon.us/

-- 
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 site not working, problem with urls.py?

2010-10-05 Thread Sandro Dutra
You have to check if you enable the "admin" application on your settings.py.

2010/10/5 Sithembewena Lloyd Dube 

> Hey Lisa,
>
> Look at this line (supplied by you):
>
>
>  # (r'^ccu/', include('ccu.foo.urls')),
>
> ^^ the line above is correct.
>
> Now, the line that's giving you trouble is:
>
>  (r'^admin/', include(admin.site.urls)),
>
> ^^ spot the difference?
>
> I think you should use quotes around your argument to the include function.
> That function expects a string, I believe :)
>
>
>
> On Wed, Oct 6, 2010 at 12:01 AM, Lisa  wrote:
>
>> Hi all,
>> I'm sure I have a pretty simple problem...
>> here's my url.py file
>>
>> from django.conf.urls.defaults import *
>>
>> # Uncomment the next two lines to enable the admin:
>> from django.contrib import admin
>> admin.autodiscover()
>>
>> urlpatterns = patterns('',
>># Example:
>># (r'^ccu/', include('ccu.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'^stories/$','ccu_gen.views.all_stories'),
>>(r'^stories/(?P\d+)/$', 'ccu_gen.views.one_story'),
>>(r'^admin/', include(admin.site.urls)),
>>
>> )
>>
>> stories works fine, but for the admin url, I'm getting the error
>> __import__() argument 1 must be string, not instancemethod
>>
>> any ideas?
>>
>> 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.
>>
>>
>
>
> --
> Regards,
> Sithembewena Lloyd Dube
> http://www.lloyddube.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.
>

-- 
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 site not working, problem with urls.py?

2010-10-05 Thread Sithembewena Lloyd Dube
Hey Lisa,

Look at this line (supplied by you):

 # (r'^ccu/', include('ccu.foo.urls')),

^^ the line above is correct.

Now, the line that's giving you trouble is:
 (r'^admin/', include(admin.site.urls)),

^^ spot the difference?

I think you should use quotes around your argument to the include function.
That function expects a string, I believe :)


On Wed, Oct 6, 2010 at 12:01 AM, Lisa  wrote:

> Hi all,
> I'm sure I have a pretty simple problem...
> here's my url.py file
>
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
># Example:
># (r'^ccu/', include('ccu.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'^stories/$','ccu_gen.views.all_stories'),
>(r'^stories/(?P\d+)/$', 'ccu_gen.views.one_story'),
>(r'^admin/', include(admin.site.urls)),
>
> )
>
> stories works fine, but for the admin url, I'm getting the error
> __import__() argument 1 must be string, not instancemethod
>
> any ideas?
>
> 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.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.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: admin site not working, problem with urls.py?

2010-10-05 Thread Tran Cao Thai
hope this helps : http://botland.oebfare.com/logger/django/2009/2/14/15/

The conversation is very funny also :D

On Wed, Oct 6, 2010 at 9:01 AM, Lisa  wrote:
> Hi all,
> I'm sure I have a pretty simple problem...
> here's my url.py file
>
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>    # Example:
>    # (r'^ccu/', include('ccu.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'^stories/$','ccu_gen.views.all_stories'),
>    (r'^stories/(?P\d+)/$', 'ccu_gen.views.one_story'),
>    (r'^admin/', include(admin.site.urls)),
>
> )
>
> stories works fine, but for the admin url, I'm getting the error
> __import__() argument 1 must be string, not instancemethod
>
> any ideas?
>
> 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.



admin site not working, problem with urls.py?

2010-10-05 Thread Lisa
Hi all,
I'm sure I have a pretty simple problem...
here's my url.py file

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^ccu/', include('ccu.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'^stories/$','ccu_gen.views.all_stories'),
(r'^stories/(?P\d+)/$', 'ccu_gen.views.one_story'),
(r'^admin/', include(admin.site.urls)),

)

stories works fine, but for the admin url, I'm getting the error
__import__() argument 1 must be string, not instancemethod

any ideas?

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: What's the best way to implement project permissions in a project management app?

2010-10-05 Thread tracul

On Oct 5, 3:32 am, Stodge  wrote:
>  What's the best way to implement project permissions in a project
> management app? Should I just create the concept of membership and
> have a function is_member on the project model?

You could create a group for each project , and include members in
that group , then implement group based permissions .

-- 
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 Registration password reset problem

2010-10-05 Thread Steve Holden
On 10/5/2010 4:45 PM, Joel Klabo wrote:
> Need to bump this, sorry. I don't get it.
> 
> On Oct 5, 1:04 pm, Joel Klabo  wrote:
>> This is the error and location of the problem:http://gist.github.com/612210,
>> I can't see what it's looking for. It seems like I could hard code the
>> arguments it wants into the reverse() but that doesn't seem like the
>> correct way to do it. Any advice?
> 
I can quite see how 41 minutes would appear to be an infinity to someone
who is wanting the answer to a problem. Please remember, though, that
people who post on this list aren't paid to do so, and mostly have
full-time jobs.

So a little patience will make it more likely people will help you.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
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 Registration password reset problem

2010-10-05 Thread Joel Klabo
Need to bump this, sorry. I don't get it.

On Oct 5, 1:04 pm, Joel Klabo  wrote:
> This is the error and location of the problem:http://gist.github.com/612210,
> I can't see what it's looking for. It seems like I could hard code the
> arguments it wants into the reverse() but that doesn't seem like the
> correct way to do it. Any advice?

-- 
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: PyDev create new project wizard creates two folders in Aptana Studio 3?

2010-10-05 Thread Sandro Dutra
When you try to create a project, Aptana duplicates the root directory
automatically. A issue...

To correct this, you only have to observe the path when you're creating the
Django project.

2010/10/2 payala 

>
> Check if you are in the python perspective
>
> On 1 oct, 19:34, Brandon Taylor  wrote:
> > Hi everyone,
> >
> > I'm used to organizing my Django projects in one folder for the
> > project and then sub folders for app modules...
> >
> > /my_project
> > -__init__.py
> > -settings.py
> > /some_app
> >
> > and so on. However, when I create a new Django project using the PyDev
> > wizard, I get:
> >
> > /my_project
> > /my_project
> > -__init__.py
> > -settings.py
> >
> > Why is that?
> >
> > TIA,
> > Brandon
>
> --
> 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 accounts/login page looping

2010-10-05 Thread Cesar Devera
hi,

I'm using django' standard auth system, and decorating my views with
@user_passes_test(lambda u: u.is_staff) or something alike.

everything works fine 99% of the time, but sometimes, one day when I
get back to my application, I go to the login page, type my correct
username and correct password, hit the Submit button, and then the app
takes me back to the login page, with no error message or log.

after then, any username/password will behave the same: loop back to
the login page.

the only way to fix this is restarting Apache. just this and
everything gets back to normal for the next days.

I'm using Ubuntu 10.04, Apache2, Python 2.6, WSGI and Django 1.2.x.

any ideias?

thanks in advance.

-- 
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 Registration password reset problem

2010-10-05 Thread Joel Klabo
This is the error and location of the problem: http://gist.github.com/612210,
I can't see what it's looking for. It seems like I could hard code the
arguments it wants into the reverse() but that doesn't seem like the
correct way to do it. Any advice?

-- 
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 regroup not working as expected

2010-10-05 Thread Gath
Guys

I have the following view in my django application

def ViewSale( request ):
salecur = Sale.objects.filter(user=2).order_by('sale_date')
return render_to_response('myapp/sale.html',{'salecur':salecur})
my template looks like this

{% regroup salecur by sale_date as sale_list %}


{% for sale_date in sale_list.list %}
{{ sale_date.grouper }}

{% for sale in sale_list %}
 {{ sale.item }} - {{ sale.qty }} 
{% endfor %}


{% endfor %}


When i render the page i get the grouper sale_date.grouper printed,
but {{ sale.item }} and {{ sale.qty }} in the inner loop shows
nothing! Blank.

What am i missing?

Gath

-- 
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: treating different versions of website urls as one

2010-10-05 Thread Steve Holden
On 10/5/2010 1:35 PM, harryos wrote:
> The user can enter a website address which will be tracked by the
> program for certain info and then a message is sent to the user's
> mail.The  user can enter many such addresses.The problem is that he
> may accidently enter different variations of the url..and if I don't
> validate it for duplicates ,the program will be doing the same work
> again unnecessarily.
> if user gives http://www.djangocon.us and djangocon.us or http://djangocon.us
> ,the program will use those in urllib.urlopen(urlstring) ,and the read
> page /data will be the same.
> .This is why I need to consider the validation for duplicates
> thanks for the replies
> harry
> 
> On Oct 5, 10:00 pm, Steve Holden  wrote:
>> What aboutwww.mysite.com/default.asp?It might be helpful if you could
>> give us a little more insight into the real requirement here, rather
>> than a technical question based on some interpretation of the requirement.
>>
> 
But then the problem is that you don't actually *know* that
www.example.com and example.com are equivalent, let alone whether the
root page in a directory is represented by index.html, index.php,
default.asp, default.aspx or some other bizarre default imposed by a
site administrator.

The site is effectively a black box - you cannot truly know which URLs
are equivalent without knowing how it's configured.

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
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: treating different versions of website urls as one

2010-10-05 Thread ringemup

Part of your problem will be that there is no way to consistently
determine whether the addresses are duplicate.  In most cases, yes,
www.example.com and example.com are the same site -- but in some
they're not.  Ditto for index.html, index.php, etc. (yes, I've seen
sites where index.html and index.php were different pages and both in
use -- *facepalm*), and URL parameters (how do you tell which are
search parameters and which are session tracking parameters, or
what?)  All of that can differ from one site to another.

Unless the duplicate-checking is an absolutely crucial feature, my
advice would be to treat the URL with and without "http://; as the
same, and assume other variants are all different.

On Oct 5, 1:35 pm, harryos  wrote:
> The user can enter a website address which will be tracked by the
> program for certain info and then a message is sent to the user's
> mail.The  user can enter many such addresses.The problem is that he
> may accidently enter different variations of the url..and if I don't
> validate it for duplicates ,the program will be doing the same work
> again unnecessarily.
> if user giveshttp://www.djangocon.usand djangocon.us orhttp://djangocon.us
> ,the program will use those in urllib.urlopen(urlstring) ,and the read
> page /data will be the same.
> .This is why I need to consider the validation for duplicates
> thanks for the replies
> harry
>
> On Oct 5, 10:00 pm, Steve Holden  wrote:
>
> > What aboutwww.mysite.com/default.asp?Itmight be helpful if you could
> > give us a little more insight into the real requirement here, rather
> > than a technical question based on some interpretation of the requirement.
>
>

-- 
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: What's the best way to implement project permissions in a project management app?

2010-10-05 Thread Stodge
Thanks. I just found django-authority. That might work.

http://packages.python.org/django-authority/

On Oct 5, 11:47 am, Godshall  wrote:
> I would recommend looking at the projects app in Pinax for a good
> approach for 
> this:http://github.com/pinax/pinax/blob/master/pinax/apps/projects/models.py
>
> Basically, it uses a ManyToMany "members" field that you can add and
> remove users to/from the project.  That particular example uses an
> intermediary User model called ProjectMember to store extra info for
> the user, but that's optional.  If you don't use an intermediary User
> model, you will need to change the user_is_member method to something
> like:
>
> def user_is_member(self, user):
>     return user in self.member_queryset() # where
> self.member_queryset() returns self.members.all()
>
> This approach will give you per-project permissions like you
> requested.
>
> On Oct 5, 5:23 am, Stodge  wrote:
>
>
>
> > That looks like what I need. Thanks. Though I also need per-project
> > permissions; so user 'bob' can access tickets on Project A but not on
> > Project B. I'll have to re-read django-todo's code when I have more
> > time to see if they implement per group permissions.
>
> > On Oct 4, 9:03 pm, Mike Dewhirst  wrote:
>
> > > On 5/10/2010 11:32am, Stodge wrote:
>
> > > >   What's the best way to implement project permissions in a project
> > > > management app? Should I just create the concept of membership and
> > > > have a function is_member on the project model?
>
> > > Have a look at django-todo. A quick read the other day indicated to me
> > > that it has what you are looking for. I'm planning to look more closely
> > > but haven't had time yet.
>
> > > Mike

-- 
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: treating different versions of website urls as one

2010-10-05 Thread harryos
The user can enter a website address which will be tracked by the
program for certain info and then a message is sent to the user's
mail.The  user can enter many such addresses.The problem is that he
may accidently enter different variations of the url..and if I don't
validate it for duplicates ,the program will be doing the same work
again unnecessarily.
if user gives http://www.djangocon.us and djangocon.us or http://djangocon.us
,the program will use those in urllib.urlopen(urlstring) ,and the read
page /data will be the same.
.This is why I need to consider the validation for duplicates
thanks for the replies
harry

On Oct 5, 10:00 pm, Steve Holden  wrote:
> What aboutwww.mysite.com/default.asp?It might be helpful if you could
> give us a little more insight into the real requirement here, rather
> than a technical question based on some interpretation of the requirement.
>

-- 
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: treating different versions of website urls as one

2010-10-05 Thread ringemup
Is this for request routing, or for data input processing?

On Oct 5, 12:17 pm, harryos  wrote:
> hi
> I am trying out a web app where it needs to process user given website
> addresses .My problem is that ,I need to treat
>  http://mysite.com,www.mysite.com,
> mysite.com,www.mysite.com/index.html,www.mysite.com/index.php...etc as the 
> same and not different urls.How
> can I do the validation in this case?Do I have to manually do the
> string parsing and validate?
> Any suggestions most welcome
> thanks
> harry

-- 
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: treating different versions of website urls as one

2010-10-05 Thread Steve Holden
What about www.mysite.com/default.asp? It might be helpful if you could
give us a little more insight into the real requirement here, rather
than a technical question based on some interpretation of the requirement.

regards
 Steve

On 10/5/2010 12:57 PM, Alec Shaner wrote:
> Definitely sounds like a regular expression is what you need.
> 
> Not sure what you mean by etcare you saying any variation of a web
> address for mysite.com, i.e., with or without www prefix, with our
> without protocol http://, and with our without the index page, which
> itself could be any variation of index.html, index.php, or
> index.whatever?
> 
> On Tue, Oct 5, 2010 at 12:17 PM, harryos  wrote:
>> hi
>> I am trying out a web app where it needs to process user given website
>> addresses .My problem is that ,I need to treat
>>  http://mysite.com ,
>> www.mysite.com,
>> mysite.com,
>> www.mysite.com/index.html,
>> www.mysite.com/index.php ...etc as the same and not different urls.How
>> can I do the validation in this case?Do I have to manually do the
>> string parsing and validate?
>> Any suggestions most welcome
>> thanks
>> harry
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
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: treating different versions of website urls as one

2010-10-05 Thread Alec Shaner
Definitely sounds like a regular expression is what you need.

Not sure what you mean by etcare you saying any variation of a web
address for mysite.com, i.e., with or without www prefix, with our
without protocol http://, and with our without the index page, which
itself could be any variation of index.html, index.php, or
index.whatever?

On Tue, Oct 5, 2010 at 12:17 PM, harryos  wrote:
> hi
> I am trying out a web app where it needs to process user given website
> addresses .My problem is that ,I need to treat
>  http://mysite.com ,
> www.mysite.com,
> mysite.com,
> www.mysite.com/index.html,
> www.mysite.com/index.php ...etc as the same and not different urls.How
> can I do the validation in this case?Do I have to manually do the
> string parsing and validate?
> Any suggestions most welcome
> thanks
> harry
>
> --
> 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: treating different versions of website urls as one

2010-10-05 Thread Michel Thadeu Sabchuk
Why not redirect all variants to http://mysite.com/?

Nginx could do the job for you ;)

Best regards.

On 5 out, 13:17, harryos  wrote:
> hi
> I am trying out a web app where it needs to process user given website
> addresses .My problem is that ,I need to treat
>  http://mysite.com,www.mysite.com,
> mysite.com,www.mysite.com/index.html,www.mysite.com/index.php...etc as the 
> same and not different urls.How
> can I do the validation in this case?Do I have to manually do the
> string parsing and validate?
> Any suggestions most welcome
> thanks
> harry

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



treating different versions of website urls as one

2010-10-05 Thread harryos
hi
I am trying out a web app where it needs to process user given website
addresses .My problem is that ,I need to treat
 http://mysite.com ,
www.mysite.com,
mysite.com,
www.mysite.com/index.html,
www.mysite.com/index.php ...etc as the same and not different urls.How
can I do the validation in this case?Do I have to manually do the
string parsing and validate?
Any suggestions most welcome
thanks
harry

-- 
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: What's the best way to implement project permissions in a project management app?

2010-10-05 Thread Godshall
I would recommend looking at the projects app in Pinax for a good
approach for this: 
http://github.com/pinax/pinax/blob/master/pinax/apps/projects/models.py

Basically, it uses a ManyToMany "members" field that you can add and
remove users to/from the project.  That particular example uses an
intermediary User model called ProjectMember to store extra info for
the user, but that's optional.  If you don't use an intermediary User
model, you will need to change the user_is_member method to something
like:

def user_is_member(self, user):
return user in self.member_queryset() # where
self.member_queryset() returns self.members.all()

This approach will give you per-project permissions like you
requested.

On Oct 5, 5:23 am, Stodge  wrote:
> That looks like what I need. Thanks. Though I also need per-project
> permissions; so user 'bob' can access tickets on Project A but not on
> Project B. I'll have to re-read django-todo's code when I have more
> time to see if they implement per group permissions.
>
> On Oct 4, 9:03 pm, Mike Dewhirst  wrote:
>
>
>
> > On 5/10/2010 11:32am, Stodge wrote:
>
> > >   What's the best way to implement project permissions in a project
> > > management app? Should I just create the concept of membership and
> > > have a function is_member on the project model?
>
> > Have a look at django-todo. A quick read the other day indicated to me
> > that it has what you are looking for. I'm planning to look more closely
> > but haven't had time yet.
>
> > Mike

-- 
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: unique constraint

2010-10-05 Thread Shawn Milochik
I think your model should have a foreign key to User, and the user field in 
your model should be set by the time you're doing this validation. That makes 
more sense and is also a lot easier to do.

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: unique constraint

2010-10-05 Thread mark jason
thanks for the reply Shawn,
the reason why I am not using ModelForm is

in the clean_url() I am using this validation
url=self.cleaned_data['url']
user_given_urls=[x.url for x in
MyModel.objects.filter(creator_of_entry=self.instance.creator_of_entry)]
if url in user_given_urls:
raise forms.ValidationError('duplicate url')

That would not work for a Modelform because creator is not set when
is_valid() is called and so no validation error occurs.

if request.method=='POST' and form.is_valid():
mymdl=form.save()
mymdl.creator_of_entry=request.user
mymdl.save()

Is there some other way to get user_given_urls other than the list
comprehension above?If so please tell me
thanks
mark




On Oct 5, 6:45 pm, Shawn Milochik  wrote:
> Why not just use a ModelForm?
>
> You can override the form's clean() or add a clean_url() method. You'll be 
> able to use self.instance to get the model instance of the model form, and 
> from that you can get the previously-used URLs.
>
> 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: Customising comment framework and keeping moderation working

2010-10-05 Thread Phil Gyford
I've made as minimal a complete demonstration of this as possible, to
try and work out where I'm going wrong:
http://github.com/philgyford/django-commentstest/

It works fine: comments can successfully be disabled on a per-Entry
basis. But, if you add "from weblog.models import Entry" to either
customcomments/forms.py or customcomments/models.py then comments are
*always* allowed through. Any idea why? Thanks.


On Tue, Oct 5, 2010 at 2:46 PM, Phil Gyford  wrote:
> I've investigated further and... it's very strange.
>
> I've got a version of my custom comments framework, with
> enable_comments moderation, working fine. Here are the contents of my
> working customcomments/forms.py and customcomments/models.py:
> http://dpaste.com/253382/
>
> However, if I add "from weblog.models import Blog" to either of those
> files, my custom moderation has no effect.
>
> This is a problem, because what I really want to do is not add a
> 'title' field to each custom comment, but add a ForeignKey field that
> links to the Blog object (comments are posted on Entries, each of
> which is associated with a Blog). So I will need to import the Blog
> class.
>
> In case it helps, here's the contents of weblog/models.py that
> contains the Blog class: http://dpaste.com/253384/
>
> This modification really isn't worth the two days I've now spent
> puzzling over it, but it's got personal, and I just want to understand
> the solution now! Any help very much appreciated.
>
>
> On Tue, Oct 5, 2010 at 11:27 AM, Phil Gyford  wrote:
>> Hi,
>>
>> I can't get my extended version of django.contrib.comments to take
>> notice of moderation.
>>
>> If I use the standard comments framework, then my subclass of
>> CommentModerator does the job - I've just used it to define
>> enable_field, and this allows or prohibits comments as expected.
>>
>> But if I switch to using my custom version of the comments framework
>> (which adds an extra field) it seems like the moderator is ignored -
>> all comments are allowed through, no matter whether the enable_field
>> on the commented-on object is true or false.
>>
>> I can't see what I'm missing. Here's the code for my moderator, in
>> case it helps: http://dpaste.com/253308/ It works fine like that, with
>> the standard framework, but if I switch the import lines over, add my
>> custom comments app to INSTALLED_APPS and COMMENTS_APP settings, the
>> enable_field has no effect.
>>
>> What's the magical missing step? Thanks.
>>
>> Phil
>>
>> --
>> http://www.gyford.com/
>>
>
>
>
> --
> http://www.gyford.com/
>



-- 
http://www.gyford.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: newbie error

2010-10-05 Thread Daniel Roseman
On Oct 5, 12:52 pm, chocolatero  wrote:
> Hi Friends! I'm working with django and i have this error:
>
> Request Method:         GET
> Request URL:    http://127.0.0.1:8000/myapp/New_page/
> Django Version:         1.2.3
> Exception Type:         ValueError
> Exception Value:
>
> invalid literal for int() with base 10: 'New_page'
>
> Exception Location:     /usr/local/lib/python2.6/dist-packages/django/db/
> models/fields/__init__.py in get_prep_value, line 479
> Python Executable:      /usr/bin/python
> Python Version:         2.6.4
>
> Resume, i want that the identify of my webs will be the title of the
> page. Now, i'm using the "id" of the page, but i want to put the
> page.title instead page.id
>
> The structure of url is :
>
> url(r'^(?P[^/]+)/$', 'view_page'),
>
> is correct?
>
> and function view_page is:
>
> def view_page(request, page_title):
>
>     if request.user.is_authenticated():
>         page_qs = Page.objects.filter(Q(id=page_title) &
> (Q(author=request.user)|Q(public=True)))
>     else:
>         page_qs = Page.objects.filter(id=page_title, public=True)
>
>     if page_qs.count() == 0:
>         raise HttpResponseNotAllowed()
>
>     pag = page_qs[0]
>
>     return render_to_response(
>         "v/schema.html",
>         {"pag":pag},
>         context_instance=RequestContext(request))
>
> Someone who wants help me?!!

In your two calls to filter, you're trying to get all objects where
the id is equal to your page_title value. Obviously, that can't work.
You want to query against the model field that contains that page
title:

 Page.objects.filter(title=page_title, public=True)

(or whatever your title field is called).
--
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: Customising comment framework and keeping moderation working

2010-10-05 Thread Phil Gyford
I've investigated further and... it's very strange.

I've got a version of my custom comments framework, with
enable_comments moderation, working fine. Here are the contents of my
working customcomments/forms.py and customcomments/models.py:
http://dpaste.com/253382/

However, if I add "from weblog.models import Blog" to either of those
files, my custom moderation has no effect.

This is a problem, because what I really want to do is not add a
'title' field to each custom comment, but add a ForeignKey field that
links to the Blog object (comments are posted on Entries, each of
which is associated with a Blog). So I will need to import the Blog
class.

In case it helps, here's the contents of weblog/models.py that
contains the Blog class: http://dpaste.com/253384/

This modification really isn't worth the two days I've now spent
puzzling over it, but it's got personal, and I just want to understand
the solution now! Any help very much appreciated.


On Tue, Oct 5, 2010 at 11:27 AM, Phil Gyford  wrote:
> Hi,
>
> I can't get my extended version of django.contrib.comments to take
> notice of moderation.
>
> If I use the standard comments framework, then my subclass of
> CommentModerator does the job - I've just used it to define
> enable_field, and this allows or prohibits comments as expected.
>
> But if I switch to using my custom version of the comments framework
> (which adds an extra field) it seems like the moderator is ignored -
> all comments are allowed through, no matter whether the enable_field
> on the commented-on object is true or false.
>
> I can't see what I'm missing. Here's the code for my moderator, in
> case it helps: http://dpaste.com/253308/ It works fine like that, with
> the standard framework, but if I switch the import lines over, add my
> custom comments app to INSTALLED_APPS and COMMENTS_APP settings, the
> enable_field has no effect.
>
> What's the magical missing step? Thanks.
>
> Phil
>
> --
> http://www.gyford.com/
>



-- 
http://www.gyford.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: unique constraint

2010-10-05 Thread Shawn Milochik
Why not just use a ModelForm? 

You can override the form's clean() or add a clean_url() method. You'll be able 
to use self.instance to get the model instance of the model form, and from that 
you can get the previously-used URLs.

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 error

2010-10-05 Thread Xavier Ordoquy
Hi,

New_page isn't a valid ID. By default, the id field is a number.

Regards,
Xavier.

Le 5 oct. 2010 à 13:52, chocolatero a écrit :

> Hi Friends! I'm working with django and i have this error:
> 
> Request Method:   GET
> Request URL:  http://127.0.0.1:8000/myapp/New_page/
> Django Version:   1.2.3
> Exception Type:   ValueError
> Exception Value:
> 
> invalid literal for int() with base 10: 'New_page'
> 
> Exception Location:   /usr/local/lib/python2.6/dist-packages/django/db/
> models/fields/__init__.py in get_prep_value, line 479
> Python Executable:/usr/bin/python
> Python Version:   2.6.4
> 
> 
> Resume, i want that the identify of my webs will be the title of the
> page. Now, i'm using the "id" of the page, but i want to put the
> page.title instead page.id
> 
> The structure of url is :
> 
> url(r'^(?P[^/]+)/$', 'view_page'),
> 
> is correct?
> 
> 
> and function view_page is:
> 
> def view_page(request, page_title):
> 
>if request.user.is_authenticated():
>page_qs = Page.objects.filter(Q(id=page_title) &
> (Q(author=request.user)|Q(public=True)))
>else:
>page_qs = Page.objects.filter(id=page_title, public=True)
> 
>if page_qs.count() == 0:
>raise HttpResponseNotAllowed()
> 
>pag = page_qs[0]
> 
>return render_to_response(
>"v/schema.html",
>{"pag":pag},
>context_instance=RequestContext(request))
> 
> Someone who wants help me?!!
> 
> 
> 
> 
> 
> 
> -- 
> 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: What's the best way to implement project permissions in a project management app?

2010-10-05 Thread Stodge
That looks like what I need. Thanks. Though I also need per-project
permissions; so user 'bob' can access tickets on Project A but not on
Project B. I'll have to re-read django-todo's code when I have more
time to see if they implement per group permissions.

On Oct 4, 9:03 pm, Mike Dewhirst  wrote:
> On 5/10/2010 11:32am, Stodge wrote:
>
> >   What's the best way to implement project permissions in a project
> > management app? Should I just create the concept of membership and
> > have a function is_member on the project model?
>
> Have a look at django-todo. A quick read the other day indicated to me
> that it has what you are looking for. I'm planning to look more closely
> but haven't had time yet.
>
> Mike

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

2010-10-05 Thread chocolatero
Hi Friends! I'm working with django and i have this error:

Request Method: GET
Request URL:http://127.0.0.1:8000/myapp/New_page/
Django Version: 1.2.3
Exception Type: ValueError
Exception Value:

invalid literal for int() with base 10: 'New_page'

Exception Location: /usr/local/lib/python2.6/dist-packages/django/db/
models/fields/__init__.py in get_prep_value, line 479
Python Executable:  /usr/bin/python
Python Version: 2.6.4


Resume, i want that the identify of my webs will be the title of the
page. Now, i'm using the "id" of the page, but i want to put the
page.title instead page.id

The structure of url is :

url(r'^(?P[^/]+)/$', 'view_page'),

is correct?


and function view_page is:

def view_page(request, page_title):

if request.user.is_authenticated():
page_qs = Page.objects.filter(Q(id=page_title) &
(Q(author=request.user)|Q(public=True)))
else:
page_qs = Page.objects.filter(id=page_title, public=True)

if page_qs.count() == 0:
raise HttpResponseNotAllowed()

pag = page_qs[0]

return render_to_response(
"v/schema.html",
{"pag":pag},
context_instance=RequestContext(request))

Someone who wants help me?!!






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

2010-10-05 Thread Paul Msegeya
[image: Learning Website Development with Django (From Technologies to
Solutions)]

[image: Buy]
*Learning Website Development with Django (From Technologies to
Solutions)
*, *9781847193353* (*1847193358*), *Packt
Publishing
*, *2008* 


On Mon, Oct 4, 2010 at 12:10 PM, parameswar  wrote:

> Hi, i am a newbie to the django framework. I would like to know the
> best book which can guide me in django. A very basic book shall be
> helpful !
>
> --
> 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: Where to create a Mezzanine project

2010-10-05 Thread Sithembewena Lloyd Dube
Hi Ken,

Thought so too. I guess I am trying to figure out if I could have a nested
project (mezzanine) inside my Django project?

On Tue, Oct 5, 2010 at 1:04 PM, Kenneth Gonsalves  wrote:

> On Tue, 2010-10-05 at 12:43 +0200, Sithembewena Lloyd Dube wrote:
> > I have installed Mezzanine and would like to know where in my main
> > Django
> > project I should run mezzanine-project. Is it recommended to create
> > the
> > mezzanine-project inside the Django project, or outside it?
> >
> > The mezzanine project will integrate blogs in the main Django
> > project.
>
> from what I can see, mezzanine is not an app to run inside a 'main'
> django project, but a standalone project of it's own - I could be wrong
> as I have not tried it out.
> --
> regards
> Kenneth Gonsalves
>
> --
> 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.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.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: Where to create a Mezzanine project

2010-10-05 Thread Kenneth Gonsalves
On Tue, 2010-10-05 at 12:43 +0200, Sithembewena Lloyd Dube wrote:
> I have installed Mezzanine and would like to know where in my main
> Django
> project I should run mezzanine-project. Is it recommended to create
> the
> mezzanine-project inside the Django project, or outside it?
> 
> The mezzanine project will integrate blogs in the main Django
> project. 

from what I can see, mezzanine is not an app to run inside a 'main'
django project, but a standalone project of it's own - I could be wrong
as I have not tried it out.
-- 
regards
Kenneth Gonsalves

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



Where to create a Mezzanine project

2010-10-05 Thread Sithembewena Lloyd Dube
Hi all,

I have installed Mezzanine and would like to know where in my main Django
project I should run mezzanine-project. Is it recommended to create the
mezzanine-project inside the Django project, or outside it?

The mezzanine project will integrate blogs in the main Django project.

Thanks,

-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.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.



Customising comment framework and keeping moderation working

2010-10-05 Thread Phil Gyford
Hi,

I can't get my extended version of django.contrib.comments to take
notice of moderation.

If I use the standard comments framework, then my subclass of
CommentModerator does the job - I've just used it to define
enable_field, and this allows or prohibits comments as expected.

But if I switch to using my custom version of the comments framework
(which adds an extra field) it seems like the moderator is ignored -
all comments are allowed through, no matter whether the enable_field
on the commented-on object is true or false.

I can't see what I'm missing. Here's the code for my moderator, in
case it helps: http://dpaste.com/253308/ It works fine like that, with
the standard framework, but if I switch the import lines over, add my
custom comments app to INSTALLED_APPS and COMMENTS_APP settings, the
enable_field has no effect.

What's the magical missing step? Thanks.

Phil

-- 
http://www.gyford.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: convert list into a comma separated string

2010-10-05 Thread Sam Lai
On 4 October 2010 21:41, ashy  wrote:
> Hi All,
>
> I am writing a django function in which I have a following list:
> li = ['a','b','c']
> I want to create a string from the list which should look like
> str = 'a,b,c'
>
> I plan to pass this string to not in () function of my sql query.

If you're using the Django ORM, you can do this without writing your own SQL.

model.objects.exclude(field__in=li)

Where model is your model class, and field is the name of the field
you want to apply the 'not in' filter on.

> Any Ideas?
>
> thanks
>    ashy
>
>
>
> --
> 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: unique constraint

2010-10-05 Thread mark jason
I tried this by making a separate form and adding clean_field()
method.

class MyDataForm(forms.Form):
url=forms.URLField()

def __init__(self,formdata,request,*args,**kwargs):
forms.Form.__init__(self,formdata, *args, **kwargs)
self.user=request.user
def clean_url(self):
try:
url=self.cleaned_data['url']

except KeyError:
raise forms.ValidationError('you must give a url')

#user_given_urls=how to do this??
if url in user_given_urls:
raise  forms.ValidationError('duplicate url')

return url

I couldn't figure out how to get the user_given_urls through filter
method on MyModel..can anybody help?

thanks
mark

-- 
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: urls and form

2010-10-05 Thread Tonton
On Mon, Oct 4, 2010 at 3:20 PM, Tonton  wrote:

> hello
>
> i use this form to have a choice list and change to another on select
>  
> 
>   
> {{carte.titre}}
>   {% for carte in latest_carte_list %}
> {{carte.titre}}
>   {% endfor %}
>   
> 
>
> and it is return a url like http://mywebsite/cartes/?=id
>
> This is my urls line to use  http://mywebsite/cartes/id what i want to
> have
>
> (r'^(?P\d+)', 'suivix'),
>
> and it is not working great :o(
>
> so i don't know what to write in my form to have  /cartes/id or in my
> urls.py file to translate /cartes/?=id in /cartes/id ?
>
> Thanks for your help
>
> Tonton
>
>
>

Hello

yes my question have no response
so  i change my form method to POST and use a name carte_id
 I change ma action in views.py

and i test the method

if request.method == 'GET':
do_something() (that works with /cartes/ )
elif request.method == 'POST':
do_something_else() (that works with my form !)

and i use the name of my form  cid=request.REQUEST["carte_id"])

so it is solve

thanks
tonton

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