Pre-deployment steps for Django apps?

2011-06-02 Thread shantp
Hi all,

I am almost ready to make my app live. I am curious what steps you all take 
while getting your app ready to deploy.

Other than setting DEBUG=False, what steps do you take with your app? Any 
reusable apps you add? Are there extra things I need to do for security?

I'm not asking for deployment instructions because I know that has been 
talked to death, I'm more interested in things to do before deploying.

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



Re: automatically create user profile on user creation

2011-03-16 Thread shantp
Check out this blog post for a one line solution to the same problem.

http://www.turnkeylinux.org/blog/django-profile

On Mar 16, 11:54 am, Ori Livneh  wrote:
> Hi guys,
>
> The Django docs explain that "the method get_profile() does not create the
> profile, if it does not exist. You need to register a handler for the signal
> django.db.models.signals.post_save on the User model, and, in the handler,
> if created=True, create the associated user profile." (http://goo.gl/jNo91)
>
> But there's no code sample. A few weeks ago (with some help from friendly
> people on #django) I came up with this snippet:
>
> # ~ snippet start ~
>
> @receiver(post_save, sender=User)
> def create_profile(sender, instance, created, **kwargs):
>     """Create a matching profile whenever a User is created."""
>     if created:
>         profile, new = UserProfile.objects.get_or_create(user=instance)
>
> # ~ snippet end ~
>
> (I use get_or_create as extra insurance against cases wherein a User is
> created, deleted, and then created anew.)
>
> Is there anything in this snippet that should be fixed or improved?
>
> If it's OK, do you think it makes sense to include it in the docs? I ask
> because getting user profiles to work is liable to be something new Django
> developers want to do, but signals are something of an intermediate/advanced
> topic.
>
> Thanks,
> Ori
>
> PS I wrote this up on my blog with a slightly lengthier explanation, in case
> anyone finds it 
> useful:http://floru.it/2011/using-signals-to-create-user-profiles-in-django-...

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



Re: Model Manager filtering on Boolean causing IntegrityError

2011-01-09 Thread Shantp
For anyone interested, this is the answer provided by the django IRC
channel. The admin looks for the first Manager by default. All I had
to do was flip the order they showed up in the Model. Even with the
admin.py overriding queryset and pointing to the other Manager, the
order is important.

fixed models.py

class Location(models.Model):
verified = models.BooleanField(default=False)
admin_objects = models.Manager()
objects = LocationManager()

On Jan 9, 1:14 pm, Shantp  wrote:
> The reason I mentioned the filtering is if I turn the filter off or
> filter for only objects where the "verified" Boolean is False instead
> of True, there is no unique integrity error. I did not have a
> unique=True attribute in the model at any time and this is happening
> on a fresh db. I'm pretty sure it has something to do the objects
> being inactive and unverified and this is causing some incrementing
> issue with the Postgres db. The admin is trying to create a new object
> with the same id instea dof overwriting. I am quite new to Django and
> SQL so I don't understand this enough to know exactly why it is
> happening.
>
> On Jan 9, 12:15 pm, Daniel Roseman  wrote:
>
>
>
>
>
>
>
> > On Sunday, January 9, 2011 6:40:17 PM UTC, Shantp wrote:
>
> > > I am using a Manager on a model based on a Boolean field to filter the
> > > objects displayed on the site while showing all objects in the admin
> > > unfiltered. The idea is that user's are submitting Locations but I do
> > > not want them to show on the site until they have been verified as a
> > > valid location based on my criteria.
>
> > > models.py
>
> > > class LocationManager(models.GeoManager):
> > >     def get_query_set(self):
> > >         return super(LocationManager,
> > > self).get_query_set().filter(verified=True)
>
> > > class Location(models.Model):
> > >     verified = models.BooleanField(default=False)
> > >     objects = LocationManager()
> > >     admin_objects = models.Manager()
>
> > > admin.py
>
> > > class LocationAdmin(admin.OSMGeoAdmin):
> > >     def queryset(self, request):
> > >         qs = self.model.admin_objects.get_query_set()
> > >         return qs
>
> > > admin.site.register(Location, LocationAdmin)
>
> > > In the admin, when I go into a record and check the verified Boolean
> > > to True and press save, I get an IntegrityError:
>
> > > duplicate key value violates unique constraint
> > > "localshare_location_pkey"
> > > traceback:http://dpaste.com/299829/
>
> > > This worked on another project when default was True and I filtered
> > > for False. I am using Postgres. Does anyone know why this is not
> > > working or have suggestions for a better way to achieve this?
>
> > This doesn't have anything to do with filtering on the boolean. As you
> > state, this happens when you *save* - integrity errors are raised by the
> > database when you try and update a row with data that violates one or more
> > constraints. In your case, you seem to have a unique constraint in the
> > Location model - did you previously have a unique=True on the boolean field?
> > If so, you'll need to remove it from the db manually.
> > --
> > 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: Model Manager filtering on Boolean causing IntegrityError

2011-01-09 Thread Shantp
The reason I mentioned the filtering is if I turn the filter off or
filter for only objects where the "verified" Boolean is False instead
of True, there is no unique integrity error. I did not have a
unique=True attribute in the model at any time and this is happening
on a fresh db. I'm pretty sure it has something to do the objects
being inactive and unverified and this is causing some incrementing
issue with the Postgres db. The admin is trying to create a new object
with the same id instea dof overwriting. I am quite new to Django and
SQL so I don't understand this enough to know exactly why it is
happening.

On Jan 9, 12:15 pm, Daniel Roseman  wrote:
> On Sunday, January 9, 2011 6:40:17 PM UTC, Shantp wrote:
>
> > I am using a Manager on a model based on a Boolean field to filter the
> > objects displayed on the site while showing all objects in the admin
> > unfiltered. The idea is that user's are submitting Locations but I do
> > not want them to show on the site until they have been verified as a
> > valid location based on my criteria.
>
> > models.py
>
> > class LocationManager(models.GeoManager):
> >     def get_query_set(self):
> >         return super(LocationManager,
> > self).get_query_set().filter(verified=True)
>
> > class Location(models.Model):
> >     verified = models.BooleanField(default=False)
> >     objects = LocationManager()
> >     admin_objects = models.Manager()
>
> > admin.py
>
> > class LocationAdmin(admin.OSMGeoAdmin):
> >     def queryset(self, request):
> >         qs = self.model.admin_objects.get_query_set()
> >         return qs
>
> > admin.site.register(Location, LocationAdmin)
>
> > In the admin, when I go into a record and check the verified Boolean
> > to True and press save, I get an IntegrityError:
>
> > duplicate key value violates unique constraint
> > "localshare_location_pkey"
> > traceback:http://dpaste.com/299829/
>
> > This worked on another project when default was True and I filtered
> > for False. I am using Postgres. Does anyone know why this is not
> > working or have suggestions for a better way to achieve this?
>
> This doesn't have anything to do with filtering on the boolean. As you
> state, this happens when you *save* - integrity errors are raised by the
> database when you try and update a row with data that violates one or more
> constraints. In your case, you seem to have a unique constraint in the
> Location model - did you previously have a unique=True on the boolean field?
> If so, you'll need to remove it from the db manually.
> --
> 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.



Model Manager filtering on Boolean causing IntegrityError

2011-01-09 Thread Shantp
I am using a Manager on a model based on a Boolean field to filter the
objects displayed on the site while showing all objects in the admin
unfiltered. The idea is that user's are submitting Locations but I do
not want them to show on the site until they have been verified as a
valid location based on my criteria.

models.py

class LocationManager(models.GeoManager):
def get_query_set(self):
return super(LocationManager,
self).get_query_set().filter(verified=True)

class Location(models.Model):
verified = models.BooleanField(default=False)
objects = LocationManager()
admin_objects = models.Manager()

admin.py

class LocationAdmin(admin.OSMGeoAdmin):
def queryset(self, request):
qs = self.model.admin_objects.get_query_set()
return qs

admin.site.register(Location, LocationAdmin)

In the admin, when I go into a record and check the verified Boolean
to True and press save, I get an IntegrityError:

duplicate key value violates unique constraint
"localshare_location_pkey"
traceback: http://dpaste.com/299829/

This worked on another project when default was True and I filtered
for False. I am using Postgres. Does anyone know why this is not
working or have suggestions for a better way to achieve this?

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



Looking for some djangosearch/pysolr help in regard to deleting objects

2009-04-20 Thread Shantp

Hi,

When I run a delete() on one of my objects the delete works and the
object is removed from the db but pysolr throws a "mismatched tag"
error. Once I comment out any references to djangosearch and solr I
don't get that error obviously and the delete still goes through. I've
searched around and can't find any info about this mismatched tag
thing. Anyone know what's going on here?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Secure way to allow user with permission to delete a model instance from template?

2009-04-20 Thread Shantp

>From the docs:

"A good example is the delete() method on each Django model object.
The template system shouldn't be allowed to do something like this:

I will now delete this valuable data. {{ data.delete }}"

What method should I use for allowing a user to delete an instance of
the model using a link clicked on the template?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problem with django-voting

2009-03-13 Thread Shantp

I'm getting this error:

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

It's coming from this line in my template:

{% scores_for_objects share_list as score_dict %}

If I remove this line everything is fine. I wasn't getting this error
before but I had to wipe my server and create a new db. Anyone know
why this is happening?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with djangosearch setup

2009-02-11 Thread Shantp

If I switch the case at all it gives me only a few options and they
are all lowercase and solr is listed as "solr."

Inside the djangosearch app and pysolr, it's written as Solr though.

Anyone get this setup?

On Feb 10, 11:19 pm, Praveen  wrote:
> SEARCH_ENGINE is not able to find solr. i think some thing wrong in
> your configuration or try to change the case SOLR 'Solr' some thing
> like that
>
> On Feb 11, 6:15 am, Shantp  wrote:
>
> > Hi
>
> > I've installed Java, Tomcat and Solr. I followed the directions and
> > got pysolr as well. I put the djangosearch app on my python path and
> > put it in the installed_apps in my settings.py.
>
> >http://code.google.com/p/djangosearch/source/browse/branches/soc-new-...
>
> > In the read me it says to put this in my settings.py file:
>
> > SEARCH_ENGINE="solr"
>
> > I did this and when I run a shell to do a test query I get an error
> > saying "ImportError: No module named solr"
>
> > Did anyone successfully setup this app? Why is it giving this error?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problems with djangosearch setup

2009-02-10 Thread Shantp

Hi

I've installed Java, Tomcat and Solr. I followed the directions and
got pysolr as well. I put the djangosearch app on my python path and
put it in the installed_apps in my settings.py.

http://code.google.com/p/djangosearch/source/browse/branches/soc-new-backends/doc/README.txt

In the read me it says to put this in my settings.py file:

SEARCH_ENGINE="solr"

I did this and when I run a shell to do a test query I get an error
saying "ImportError: No module named solr"

Did anyone successfully setup this app? Why is it giving this error?

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



How to handle an error that throws an alert box and make it show an AJAX error message instead?

2009-02-09 Thread Shantp

I'm using Django and django-voting in an app I'm making. If a user who
is not authenticated tries to vote, an alert box is displayed telling
them they are not authenicated. How can I catch this error and make it
into a more elegant AJAX display so I can show it right on the page
when it happens?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Subclassing CommentForm

2009-02-07 Thread Shantp

Wow. Just removing the () after my subclassed commentform worked.
Thanks a lot. I hope that ticket is completed soon and added into
django.

On Feb 7, 8:31 pm, Eric Abrahamsen  wrote:
> On Feb 8, 2009, at 12:15 PM, Shantp wrote:
>
>
>
>
>
> > Hi,
>
> > I've got a custom comment form in my template using "get_comment_form"
> > and I'd like email to not be required. From some searching I see that
> > I need to subclass the CommentForm, but I don't know exactly how to go
> > about this. Here's what I put into my forms.py
>
> > from django.contrib.comments.forms import CommentForm
> > class EmailFreeCommentForm(CommentForm):
> >    email = forms.EmailField(label='Email address', required=False)
>
> > Then I put this in my urls.py
>
> > from django.contrib import admin, comments
> > from sharing.forms import EmailFreeCommentForm
> > def override_get_form():
> >    return EmailFreeCommentForm()
>
> > comments.get_form = override_get_form
>
> > This is giving me errors. Am I missing something?
>
> This is how I do it:
>
> def my_get_form():
>      return MyCommentForm
>
> comments.get_form = my_get_form
>
> This is a monkeypatch and not the way it should be done, but full  
> customizability for the comments app is a work in progress (see ticket  
> #8630http://code.djangoproject.com/ticket/8630), and until that's  
> finished I think this is what people are doing.
>
> Yours,
> Eric
>
> > If you can point me towards good subclassing docs that would be
> > appreciated as well. 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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Subclassing CommentForm

2009-02-07 Thread Shantp

Hi,

I've got a custom comment form in my template using "get_comment_form"
and I'd like email to not be required. From some searching I see that
I need to subclass the CommentForm, but I don't know exactly how to go
about this. Here's what I put into my forms.py

from django.contrib.comments.forms import CommentForm
class EmailFreeCommentForm(CommentForm):
email = forms.EmailField(label='Email address', required=False)

Then I put this in my urls.py

from django.contrib import admin, comments
from sharing.forms import EmailFreeCommentForm
def override_get_form():
return EmailFreeCommentForm()

comments.get_form = override_get_form

This is giving me errors. Am I missing something?

If you can point me towards good subclassing docs that would be
appreciated as well. 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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using slug in comments urls

2008-09-13 Thread Shantp


Just to clear up some confusion, I posted only the relevant part of my
urls.py file. I have all the other necessary stuff in it but i'm still
getting this error.


On Sep 12, 8:14 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On Sep 13, 2008, at 8:32 AM, Shantp wrote:
>
>
>
> > Hi,
>
> > I did a lot of searching on this and can't figure out what I'm doing
> > wrong. Here's what's in my urls.py:
>
> > share_detail = {
> >    'queryset': Share.objects.all(),
> > }
>
> > (r'^comments/', include('django.contrib.comments.urls')),
> > (r'^comments/(?P[-\w]+)/?$',
> > 'django.views.generic.list_detail.object_detail',
> >        dict(share_detail, slug_field='slug',
> > template_object_name='share', template_name='share_page.html')),
>
> This looks like you're putting your urlconf patterns directly at the  
> top level of the file. They need to be encapsulated in a patterns()  
> call, and assigned to a variable called 'urlpatterns'. Right now  
> django's looking for that 'urlpatterns' variable, and not finding it.  
> Take a look at the sample urlconf file:
>
> http://docs.djangoproject.com/en/dev/topics/http/urls/#example
>
> Yours,
> Eric
>
>
>
> > I'm getting this error:
>
> > Exception Type:    AttributeError
> > Exception Value:   'module' object has no attribute 'urlpatterns'
>
> > Can anyone help me understand what is wrong with my urls?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using slug in comments urls

2008-09-12 Thread Shantp

Hi,

I did a lot of searching on this and can't figure out what I'm doing
wrong. Here's what's in my urls.py:

share_detail = {
'queryset': Share.objects.all(),
}

(r'^comments/', include('django.contrib.comments.urls')),
(r'^comments/(?P[-\w]+)/?$',
'django.views.generic.list_detail.object_detail',
dict(share_detail, slug_field='slug',
template_object_name='share', template_name='share_page.html')),

I'm getting this error:

Exception Type: AttributeError
Exception Value:'module' object has no attribute 'urlpatterns'

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



Re: django web hosting

2008-09-03 Thread Shantp

I was a beginner to linux and django and SliceHost has been awesome
for getting myself going and learning.
http://www.slicehost.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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



timesince truncating

2008-07-15 Thread Shantp

Hi all,

This seems like it will have an obvious answer but I did a lot of
searching and can't find the answer. The timesince template tag
returns 2 outputs like "2 days, 3 hours". How can I limit the output
to only 1 thing?

-Shant

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