Re: help with time

2012-03-02 Thread Scott Macri
OK, I guess a better question is how do I switch my time outputs using
datetime.time from 24-hour clock to 12-hour clock so I can use am/pm?

On Sat, Mar 3, 2012 at 12:13 AM, 赵帅  wrote:
> You can change the contents of TIME_CHOICES,every time before render one
> template, since django render one form up to the attribute of the form .
>
> 2012/3/3 Scott Macri 
>>
>> OK, I'm experimenting with time.  To be specific datetime.time.  My
>> goal is to generate a list of times in a pull down menu so when the
>> user saves the form it populates the db with the proper type.
>>
>> In order to use a model with choices, which is what I've done, I have
>> to do something like this:
>>
>> TIME_CHOICES = (
>>     (datetime.time(12,0), '12:00 PM')),
>>      (datetime.time(12,15), '12:15 PM')),
>> )
>>
>> Is there an easier way to do this?  Maybe a way to automate it without
>> having to create a nested mess?  I've tried automating it, but am not
>> having much luck.  I was hoping for something similar to the
>> SelectDateWidget, but it doesn't exist for time only.
>>
>> Thanks.
>>
>> --
>> Scott
>>
>> --
>> 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.
>>
>
> --
> 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.



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

-- 
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: help with time

2012-03-02 Thread 赵帅
You can change the contents of TIME_CHOICES,every time before render one
template, since django render one form up to the attribute of the form .

2012/3/3 Scott Macri 

> OK, I'm experimenting with time.  To be specific datetime.time.  My
> goal is to generate a list of times in a pull down menu so when the
> user saves the form it populates the db with the proper type.
>
> In order to use a model with choices, which is what I've done, I have
> to do something like this:
>
> TIME_CHOICES = (
> (datetime.time(12,0), '12:00 PM')),
>  (datetime.time(12,15), '12:15 PM')),
> )
>
> Is there an easier way to do this?  Maybe a way to automate it without
> having to create a nested mess?  I've tried automating it, but am not
> having much luck.  I was hoping for something similar to the
> SelectDateWidget, but it doesn't exist for time only.
>
> Thanks.
>
> --
> Scott
>
> --
> 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.
>
>

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



help with time

2012-03-02 Thread Scott Macri
OK, I'm experimenting with time.  To be specific datetime.time.  My
goal is to generate a list of times in a pull down menu so when the
user saves the form it populates the db with the proper type.

In order to use a model with choices, which is what I've done, I have
to do something like this:

TIME_CHOICES = (
 (datetime.time(12,0), '12:00 PM')),
  (datetime.time(12,15), '12:15 PM')),
)

Is there an easier way to do this?  Maybe a way to automate it without
having to create a nested mess?  I've tried automating it, but am not
having much luck.  I was hoping for something similar to the
SelectDateWidget, but it doesn't exist for time only.

Thanks.

-- 
Scott

-- 
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: Adding ImageField to Existing Models Results in Errors...and Confusion

2012-03-02 Thread 赵帅
"no such column: report_userprofile.profile_pic"
This error suggests that your database table has no such column profile_pic.
After you add one column in the model of django,you have to add the
according column with proper column type for the table.Django won't do it
for you.

You can refer to https://docs.djangoproject.com/en/1.3 for more details.
2012/3/3 DF 

> I'm currently working on my first Django project and have hit a
> roadblock in regard to adding an ImageField to an existing model.
>
> I currently have a model for a user posting content and one for django-
> profiles. For the former, I added an ImageField so the used can submit
> a photo to accompany the text content. For the latter, I want to allow
> users to upload a profile photo (not worried at the moment about
> avatar resizing).
>
> Things were working well until I added ImageFields to both models. I
> then synced the database with South. What resulted when I try to pull
> up the once working templates for profiles is:
>
> "no such column: report_userprofile.profile_pic"
>
> A similar error occurs when trying to view the submitted text content.
>
> I set both of the fields to "blank=True" so it seemed as if not having
> an image file would not cause an error. I'm obviously wrong.
>
> I did not initially put these fields in the models, which in hindsight
> was a big mistake. I've also just set up the MEDIA_ROOT and MEDIA_URL
> as follows:
>
> MEDIA_ROOT = 'os.path.join(BASE_DIR, "media")'
>
> MEDIA_URL = 'http://localhost:8000/media'
> The models I'm now using are:
>
> class Story(models.Model):
> title = models.CharField(max_length=100)
> topic = models.CharField(max_length=50)
> copy = models.TextField()
> author = models.ForeignKey(User)
> zip_code = models.CharField(max_length=10)
> latitude = models.FloatField(blank=False, null=False)
> longitude = models.FloatField(blank=False, null=False)
> date = models.DateTimeField(auto_now=True, auto_now_add=True)
> pic = models.ImageField(upload_to='pictures', blank=True)
> def __unicode__(self):
>return " %s" % (self.title)
>
> class UserProfile(models.Model):
> user = models.ForeignKey(User, unique=True)
> first_name = models.CharField(max_length=25)
> last_name = models.CharField(max_length=35)
> email = models.EmailField()
> birth_date = models.DateField(blank=True, null=True)
> city = models.CharField(max_length=25)
> state = models.CharField(max_length=20)
> zip_code = models.CharField(max_length=10)
> profile_pic = models.ImageField(upload_to='pictures', blank=True)
>
> The accompanying forms for submission:
>
> class ProfileForm(forms.ModelForm):
>class Meta:
>model = UserProfile
>
> class StoryForm(forms.ModelForm):
>class Meta:
>model = Story
>exclude = ('author',)
>
> The URLs file is set up as follows:
>
>url(r'^admin/', include(admin.site.urls)),
>
> (r'^media/(?P.*)$', 'django.views.static.serve',
>{'document_root': settings.MEDIA_ROOT},
>
> The core problem here is I have no idea what the error(s) might be
> (the previous templates aren't set up properly since there was no
> ImageField in the existing form for input? i didn't set up the
> MEDIA_ROOT and URL earlier?). Or better yet, errors, as I'm sure I've
> made several. It's a bit of a soup right now along with the resulting
> distress.
>
> Just as an FYI, I have installed the PIL.
>
> Part of the issue may be that when I used South to add these fields it
> didn't appear to migrate properly (I posted earlier about possibly
> wiping the sqlite3 clean and starting from scratch). But I tried the
> files on another computer without the potentially erroneous database
> and the same error resulted.
>
> Any insight at all, even a small insight, into what I need to do to
> remedy this situation would be beyond appreciated. I've searched for
> similar issues but none this specific emerges. (The first lesson for
> the future would be to obviously set up the ImageFiles when initially
> assembling the models.)
>
> Usually I can figure things out by researching previous questions or
> making a basic inquiry, but this time I'm in a hole. Hopefully, i can
> learn from this episode.
>
> Many 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.
>
>

-- 
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: Automated Processes

2012-03-02 Thread Scott Macri
Awsome, cron it is!  Thanks.  :)

On Fri, Mar 2, 2012 at 11:48 PM, Russell Keith-Magee
 wrote:
>
> On 03/03/2012, at 4:10 AM, Scott Macri wrote:
>
>> I'm trying to figure out the best way to create an automated in a
>> python/django web application.  My intention is to send an email
>> message in the future based on the given future date/time.  What is
>> the best approach to do this?
>>
>> I was thinking of creating a cron job and a python script, but I would
>> rather have the process be part of my django application so I don't
>> have to worry about extra stuff.
> ...
>> Any thoughts on how to handle this situation?  Thanks.
>
> Yeah - use a cron job and a Python script :-)
>
> Seriously -- Django is good at what it does, but just because you've got a 
> really good hammer, it doesn't mean every problem is a nail. The task you 
> describe sounds like almost exactly what cron scripts are designed to handle. 
> Rather than trying to bend Django into a shape that will solve your problem, 
> use the right tool for the job.
>
> You might also be able to attack the problem using a task queue like celery 
> [1]. However, celery is more complex to get set up than a cron script. There 
> are lots of benefits that come with that complexity, but if you just want to 
> get something going, you don't have any experience with task queues, and 
> you're not expecting any serious load problems, cron will be the easier 
> option.
>
> It's also worth pointing out that you can still use parts of Django (e.g., 
> your models, the ORM, the mail sending utilities) in a standalone Python 
> script that is called by cron/celery. Django is a just a set of Python 
> libraries. Yes, it's a set of libraries that is usually used to build web 
> sites, and most examples use Django APIs to service HTTP requests, but 
> there's no reason you can't write a standalone Python script that uses 
> Django's APIs to access and manipulate data.
>
> [1] http://celeryproject.org/
>
> Yours,
> Russ Magee %-)
>
> --
> 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.
>



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

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



Re: Is it time to start sqlite3 DB from scratch?

2012-03-02 Thread Shawn Milochik
You're welcome.

To clarify, South is wonderful. It's sqlite that is the problem. The
migrations only fail because sqlite doesn't support all normal SQL commands.

I love sqlite, but it's not always the best solution.

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



Re: Django, nginx, Passenger

2012-03-02 Thread 赵帅
I suggest you do a pressure test on the url that have triggered the problem
to see whether it will show up again.If yes, to see the system status such
as the number of sockets being used and the number of connections from
nginx to fastcgi service in the status of waiting to be accepted.

2012/3/3 Daniele Procida 

> We're having a devil of a time with our new server, which went live
> yesterday after two months of testing.
>
> Every so often, nginx will display a 502 gateway error page, and something
> like this will appear in the logs:
>
> 2012/03/02 18:05:38 [error] 29743#0: *1479 upstream prematurely closed
> connection while reading response header from upstream, client:
> nn.nn.nn.nn, server: nn.nn.nn.nn, request: "GET /some/path/ HTTP/1.1",
> upstream: "passenger:unix:/passenger_helper_server:", host: "example.com"
>
> This only occurs on some pages, but once it has happened on a page, it
> seems to keep happening.
>
> It doesn't happen straight away - the server can run happily for some time
> before the errors start occurring.
>
> The pages that trigger the error don't seem to be particularly hard work
> for the server. However, the same pages can be expected to trigger it,
> while some never do.
>
> Merely restarting nginx doesn't get rid of the errors - they come back
> again.
>
> As soon as DEBUG = True is applied in settings and nginx restarted, the
> errors disappear.
>
> Some things that seem to have improved matters:
>
> * increasing somaxconn to 1024
> * turning off cacheing
>
> In fact after turning off cacheing it was some hours before the errors
> returned.
>
> We are running nginx, with a passenger_wsgi.py file setting up the path
> and pointing to the settings.py file.
>
> I'd appeciate any tips on what the problem might be, or how to go about
> isolating it.
>
> Obviously an error that occurs under heavy load is not unusual, though I
> don't think the load is particualrly heavy (and this server has taken over
> from one rather less powerful that has been doing the same job for two
> years).
>
> What is puzzling is the error that occurs only on particular apparently
> arbitrary pages, and then persists, even after the load conditions (we were
> using ApacheBench to test) have disappeared.
>
> Daniele
>
> --
> 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.
>
>

-- 
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: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

2012-03-02 Thread sillyou su
like this:
your_project---
   |---__init__.py
   |---settings.py
   |---urls.py
   |---manage.py
   |---app_A---
 |
 |---__init__.py
 |---models.py
 |---view.py
 |---templates---
|
|---index.html

-- 
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: Automated Processes

2012-03-02 Thread Russell Keith-Magee

On 03/03/2012, at 4:10 AM, Scott Macri wrote:

> I'm trying to figure out the best way to create an automated in a
> python/django web application.  My intention is to send an email
> message in the future based on the given future date/time.  What is
> the best approach to do this?
> 
> I was thinking of creating a cron job and a python script, but I would
> rather have the process be part of my django application so I don't
> have to worry about extra stuff.
...
> Any thoughts on how to handle this situation?  Thanks.

Yeah - use a cron job and a Python script :-)

Seriously -- Django is good at what it does, but just because you've got a 
really good hammer, it doesn't mean every problem is a nail. The task you 
describe sounds like almost exactly what cron scripts are designed to handle. 
Rather than trying to bend Django into a shape that will solve your problem, 
use the right tool for the job.

You might also be able to attack the problem using a task queue like celery 
[1]. However, celery is more complex to get set up than a cron script. There 
are lots of benefits that come with that complexity, but if you just want to 
get something going, you don't have any experience with task queues, and you're 
not expecting any serious load problems, cron will be the easier option.

It's also worth pointing out that you can still use parts of Django (e.g., your 
models, the ORM, the mail sending utilities) in a standalone Python script that 
is called by cron/celery. Django is a just a set of Python libraries. Yes, it's 
a set of libraries that is usually used to build web sites, and most examples 
use Django APIs to service HTTP requests, but there's no reason you can't write 
a standalone Python script that uses Django's APIs to access and manipulate 
data.

[1] http://celeryproject.org/

Yours,
Russ Magee %-)

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



Re: Is it time to start sqlite3 DB from scratch?

2012-03-02 Thread DF
The solution appears the have been simple: delete the offending
tables.

I have not tried to upload an actual image yet yet everything appears
9knock wood) to be working properly thus far.

Thanks for the advice, especially about how South isn't so friendly
with sqlite3!

On Mar 2, 10:02 pm, DF  wrote:
> Thanks. I'm having a bear of a time after I added an ImageFile and
> media folder and then tried to make a migration with South (made
> another post about this). I figure it might be best to just chuck it
> and start again.
>
> On Mar 2, 9:59 pm, Shawn Milochik  wrote:
>
>
>
>
>
>
>
> > On 03/02/2012 09:55 PM, DF wrote:
>
> > > Thanks. Still not sure how to wipe the database before starting fresh
> > > with South.
>
> > If it's a sqlite database you just delete the file.

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



Re: Is it time to start sqlite3 DB from scratch?

2012-03-02 Thread DF
Thanks. I'm having a bear of a time after I added an ImageFile and
media folder and then tried to make a migration with South (made
another post about this). I figure it might be best to just chuck it
and start again.

On Mar 2, 9:59 pm, Shawn Milochik  wrote:
> On 03/02/2012 09:55 PM, DF wrote:
>
> > Thanks. Still not sure how to wipe the database before starting fresh
> > with South.
>
> If it's a sqlite database you just delete the file.

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



Re: Is it time to start sqlite3 DB from scratch?

2012-03-02 Thread Shawn Milochik

On 03/02/2012 09:55 PM, DF wrote:

Thanks. Still not sure how to wipe the database before starting fresh
with South.



If it's a sqlite database you just delete the file.

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



Re: Is it time to start sqlite3 DB from scratch?

2012-03-02 Thread DF
Thanks. Still not sure how to wipe the database before starting fresh
with South.

On Mar 2, 8:50 pm, Shawn Milochik  wrote:
> If it's dummy data then you can always wipe it and reset South.
>
> There are some issues with sqlite. Not all constraints are enforced and
> it doesn't support removing fields, for two biggies. So you can't delete
> a field from a model (the migration will fail), and you can't use the
> 'unique_together' meta feature either. It will never raise an error and
> it'll let you put duplicate records in.
>
> A lot of people develop locally with sqlite for the convenience then
> deploy PostgreSQL for a robust DB.
>
> To answer your questions:
>
> 1. If you're going to wipe the DB and start over then you're already set.
> However, if you want to start South from scratch (it'll make your tests
> run faster because you'll have fewer migrations), you can do this:
>     A: ./manage.py reset south
>     B: rm appname/migrations/*
>     C: ./manage.py convert_to_south appname
>
> 2. If you wipe the DB it'll obviously destroy all data and you'll have
> to reload. You could export fixtures first, but restoring them will
> depend on whether they were tied to your app's data.
>
> 3. No.
>
> 4. Not if you're not worried about losing any data.

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



Adding ImageField to Existing Models Results in Errors...and Confusion

2012-03-02 Thread DF
I'm currently working on my first Django project and have hit a
roadblock in regard to adding an ImageField to an existing model.

I currently have a model for a user posting content and one for django-
profiles. For the former, I added an ImageField so the used can submit
a photo to accompany the text content. For the latter, I want to allow
users to upload a profile photo (not worried at the moment about
avatar resizing).

Things were working well until I added ImageFields to both models. I
then synced the database with South. What resulted when I try to pull
up the once working templates for profiles is:

"no such column: report_userprofile.profile_pic"

A similar error occurs when trying to view the submitted text content.

I set both of the fields to "blank=True" so it seemed as if not having
an image file would not cause an error. I'm obviously wrong.

I did not initially put these fields in the models, which in hindsight
was a big mistake. I've also just set up the MEDIA_ROOT and MEDIA_URL
as follows:

MEDIA_ROOT = 'os.path.join(BASE_DIR, "media")'

MEDIA_URL = 'http://localhost:8000/media'
The models I'm now using are:

class Story(models.Model):
title = models.CharField(max_length=100)
topic = models.CharField(max_length=50)
copy = models.TextField()
author = models.ForeignKey(User)
zip_code = models.CharField(max_length=10)
latitude = models.FloatField(blank=False, null=False)
longitude = models.FloatField(blank=False, null=False)
date = models.DateTimeField(auto_now=True, auto_now_add=True)
pic = models.ImageField(upload_to='pictures', blank=True)
def __unicode__(self):
return " %s" % (self.title)

class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
first_name = models.CharField(max_length=25)
last_name = models.CharField(max_length=35)
email = models.EmailField()
birth_date = models.DateField(blank=True, null=True)
city = models.CharField(max_length=25)
state = models.CharField(max_length=20)
zip_code = models.CharField(max_length=10)
profile_pic = models.ImageField(upload_to='pictures', blank=True)

The accompanying forms for submission:

class ProfileForm(forms.ModelForm):
class Meta:
model = UserProfile

class StoryForm(forms.ModelForm):
class Meta:
model = Story
exclude = ('author',)

The URLs file is set up as follows:

url(r'^admin/', include(admin.site.urls)),

(r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT},

The core problem here is I have no idea what the error(s) might be
(the previous templates aren't set up properly since there was no
ImageField in the existing form for input? i didn't set up the
MEDIA_ROOT and URL earlier?). Or better yet, errors, as I'm sure I've
made several. It's a bit of a soup right now along with the resulting
distress.

Just as an FYI, I have installed the PIL.

Part of the issue may be that when I used South to add these fields it
didn't appear to migrate properly (I posted earlier about possibly
wiping the sqlite3 clean and starting from scratch). But I tried the
files on another computer without the potentially erroneous database
and the same error resulted.

Any insight at all, even a small insight, into what I need to do to
remedy this situation would be beyond appreciated. I've searched for
similar issues but none this specific emerges. (The first lesson for
the future would be to obviously set up the ImageFiles when initially
assembling the models.)

Usually I can figure things out by researching previous questions or
making a basic inquiry, but this time I'm in a hole. Hopefully, i can
learn from this episode.

Many 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: Is it time to start sqlite3 DB from scratch?

2012-03-02 Thread Shawn Milochik

If it's dummy data then you can always wipe it and reset South.

There are some issues with sqlite. Not all constraints are enforced and 
it doesn't support removing fields, for two biggies. So you can't delete 
a field from a model (the migration will fail), and you can't use the 
'unique_together' meta feature either. It will never raise an error and 
it'll let you put duplicate records in.


A lot of people develop locally with sqlite for the convenience then 
deploy PostgreSQL for a robust DB.


To answer your questions:

1. If you're going to wipe the DB and start over then you're already set.
However, if you want to start South from scratch (it'll make your tests 
run faster because you'll have fewer migrations), you can do this:

   A: ./manage.py reset south
   B: rm appname/migrations/*
   C: ./manage.py convert_to_south appname

2. If you wipe the DB it'll obviously destroy all data and you'll have 
to reload. You could export fixtures first, but restoring them will 
depend on whether they were tied to your app's data.


3. No.

4. Not if you're not worried about losing any data.


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



Extra data for form(set) display?

2012-03-02 Thread Carsten Fuchs

Hi all,

using a formset with a large number of forms, I would like to add "extra 
data" to each of the forms that I can render in the template as 
read-only info near the fields of the related form.


For example, let's assume we have a formset with one form for each day 
in the month, and each form has input fields "start time" and "end time" 
that the user is supposed to enter. When the user edits previously saved 
data, for each form I would like to print the precomputed duration, end 
minus start, next to the two input fields (my real computation is more 
complicated than that so it must run on the server and cannot e.g. be 
done in JavaScript).


What is the proper way to do that, especially when validating a 
POST-submitted form fails and the form must be redisplayed?



Allow me to explain this in more detail:

Let's consider each of the three code paths for processing a form as 
described at 
:



1. No form(set) has been submitted, and we're creating a new unbound one 
with initial data, e.g. like this:


Inits = [ {...}, ... one dict per form with initial data ]
myFormSet = myFormSetFactory(initial=Inits)

In this case I've successfully used either of two approaches for 
combining the forms with the extra data for rendering in the template: 
(However, I believe that both approaches are wrong or at least 
questionable...)


1a. Create another list of dictionaries like Inits like this:

Tabelle = [{} for i in Inits]
FormNr = 0
for Zeile in Tabelle:
Zeile['extra'] = per_form_static_info_data[FormNr]
Zeile['form'] = myFormSet.forms[FormNr]
FormNr += 1

per_form_static_info_data is a list of the same size as Inits, created 
at the same time, and contains the expensively computed extra data.


Then we pass Tabelle to the template and loop over it for rendering the 
forms and the extra data. Given that, myFormSet itself is needed in the 
template only for the management form and the csrf-token.


1b. Alternatively, add the extra data to the forms instead, like this:

for Nr, Form in enumerate(myFormSet.forms):
Form.Extra = per_form_static_info_data[Nr]

In this case, we pass myFormSet to the template where we loop over its 
forms and take the extra data directly from it.



Both methods work, but both feel wrong to me, and from the Django 
perspective, I cannot even tell which one is preferable?


Notice that in both cases, when the form is submitted, the extra data is 
not transferred from the client to the server, because it's just static 
text that is not part of any input field.



2. When the formset is submitted and valid, the matter is easy: We 
really should be able to save the submitted data from what we have in 
the form fields, without any need to bother about the extra stuff at all.



3. The really problematic case that really motivated me to post this 
question here: The formset was submitted, fails validation, and thus 
should be redisplayed, both with the error messages *and* - as before - 
with the extra data.


In this situation, we could regenerate the per_form_static_info_data 
list and *hope* that the submitted forms and the 
per_form_static_info_data list are still parallel, and then use one of 
the methods described in 1a or 1b again to combine them...


But if this felt wrong in step 1., it feels like a receipt to disaster 
now: During the time that the user took to fill-in the forms, other 
users may have added/deleted/changed the underlying models totally, so 
that the list with extra data would be totally out of sync with what 
arrived in request.POST.


This seems like a type of problem that occurs frequently, but I 
seemingly cannot see a good solution.


How do you handle it?
Are there any best practices?  (Django-style solutions? ;-) )


Epilogue:

Instead of 1a and 1b, what do you think of putting the extra data into 
hidden fields instead? (Would this work even if some of the extra data 
were instances of models.Model?)


The extra data would then be part of the Inits list, and (re-)creating 
the separate per_form_static_info_data would totally be eliminated.


But in the template, how do I render? If "form" is a form in the 
formset, {{ form.some_field }} would render the *hidden* field, but I'd 
*also* need the text string besides it...?



I'd be very grateful for your help, and many thanks if you've read until 
here!


Thank you very much for your time,
and best regards,
Carsten



--
   Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
  Learn more at http://www.cafu.de

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

Django, nginx, Passenger

2012-03-02 Thread Daniele Procida
We're having a devil of a time with our new server, which went live yesterday 
after two months of testing.

Every so often, nginx will display a 502 gateway error page, and something like 
this will appear in the logs:

2012/03/02 18:05:38 [error] 29743#0: *1479 upstream prematurely closed 
connection while reading response header from upstream, client: nn.nn.nn.nn, 
server: nn.nn.nn.nn, request: "GET /some/path/ HTTP/1.1", upstream: 
"passenger:unix:/passenger_helper_server:", host: "example.com"

This only occurs on some pages, but once it has happened on a page, it seems to 
keep happening.

It doesn't happen straight away - the server can run happily for some time 
before the errors start occurring.

The pages that trigger the error don't seem to be particularly hard work for 
the server. However, the same pages can be expected to trigger it, while some 
never do.

Merely restarting nginx doesn't get rid of the errors - they come back again.

As soon as DEBUG = True is applied in settings and nginx restarted, the errors 
disappear.

Some things that seem to have improved matters:

* increasing somaxconn to 1024
* turning off cacheing

In fact after turning off cacheing it was some hours before the errors returned.

We are running nginx, with a passenger_wsgi.py file setting up the path and 
pointing to the settings.py file.

I'd appeciate any tips on what the problem might be, or how to go about 
isolating it.

Obviously an error that occurs under heavy load is not unusual, though I don't 
think the load is particualrly heavy (and this server has taken over from one 
rather less powerful that has been doing the same job for two years).

What is puzzling is the error that occurs only on particular apparently 
arbitrary pages, and then persists, even after the load conditions (we were 
using ApacheBench to test) have disappeared.

Daniele

-- 
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: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

2012-03-02 Thread Sami Balbaky
Thank you for the clarification DR. I finished the beginning tutorial on
djangoproject.com. I'm certainly going to need a lot more practice. I'll
fix my code with your changes.

Best,

SB

On Fri, Mar 2, 2012 at 2:21 PM, Daniel Roseman wrote:

> On Friday, 2 March 2012 21:47:54 UTC, Django_for_SB wrote:
>>
>> Thank you everyone for your very insightful and helps remarks. I had 2
>> issues with my code:
>>
>> 1) I didn't properly separate my directory strings with commas and
>> 2) I need to code the directory structure, and the absolute path to the
>> file itself.
>>
>> Here is the correct code from within settings.py:
>>
>> TEMPLATE_DIRS = (
>> # Put strings here, like "/home/html/django_templates" or
>> "C:/www/django/templates".
>> # Always use forward slashes, even on Windows.
>> # Don't forget to use absolute paths, not relative paths.
>> 'C:/Python27/my_Djando_
>> projects/mysite/My_Templates/**admin/base_site.html',
>> 'C:/Python27/my_Djando_**projects/mysite/My_Templates/**
>> admin/index.html',
>> 'C:/Python27/my_Djando_**projects/mysite/My_Templates/'**,
>> )
>>
>
> No, this is *not* correct. It may work, but that's because the first two
> will simply not be found.
>
> You *only* need the last line here (including the comma).
> --
> DR.
>
>>
>>
>  --
> 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/-/xcPMN9h-SIgJ.
>
> 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.
>



-- 
Sami Balbaky
System Engineer - Ultrawave Labs

-- 
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: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

2012-03-02 Thread Daniel Roseman
On Friday, 2 March 2012 21:47:54 UTC, Django_for_SB wrote:
>
> Thank you everyone for your very insightful and helps remarks. I had 2 
> issues with my code:
>
> 1) I didn't properly separate my directory strings with commas and 
> 2) I need to code the directory structure, and the absolute path to the 
> file itself. 
>
> Here is the correct code from within settings.py:
>
> TEMPLATE_DIRS = (
> # Put strings here, like "/home/html/django_templates" or 
> "C:/www/django/templates".
> # Always use forward slashes, even on Windows.
> # Don't forget to use absolute paths, not relative paths.
> 'C:/Python27/my_Djando_
> projects/mysite/My_Templates/admin/base_site.html',
> 'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/index.html',
> 'C:/Python27/my_Djando_projects/mysite/My_Templates/',
> )
>

No, this is *not* correct. It may work, but that's because the first two 
will simply not be found.

You *only* need the last line here (including the comma).
--
DR. 

>  
>

-- 
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/-/xcPMN9h-SIgJ.
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: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

2012-03-02 Thread Sami Balbaky
Thank you everyone for your very insightful and helps remarks. I had 2
issues with my code:

1) I didn't properly separate my directory strings with commas and
2) I need to code the directory structure, and the absolute path to the
file itself.

Here is the correct code from within settings.py:

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or
"C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'C:/Python27/my_Djando_
projects/mysite/My_Templates/admin/base_site.html',
'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/index.html',
'C:/Python27/my_Djando_projects/mysite/My_Templates/',
)





On Thu, Mar 1, 2012 at 3:42 PM, Python_Junkie  wrote:

>
>
> On Wednesday, February 29, 2012 2:46:11 PM UTC-5, Django_for_SB wrote:
>>
>> Hello All,
>>
>> I'm going through the tutorial on djangoproject.com, and can't seem to
>> hurdle over this section that reads "Write views that actually do
>> something"
>>
>> Here's the code I have so far, which is directly copied from the
>> tutorial or prescribed by the tutorial:
>>
>> views.py:
>> "from django.template import Context, loader
>> from polls.models import Poll
>> from django.http import HttpResponse
>>
>> def index(request):
>> latest_poll_list = Poll.objects.all().order_by('-**pub_date')[:5]
>> t = loader.get_template('polls/**index.html')
>> c = Context({
>> 'latest_poll_list': latest_poll_list,
>> })
>> return HttpResponse(t.render(c))"
>>
>>
>>
>> settings.py:
>> "...
>> TEMPLATE_DIRS = (
>> # Put strings here, like "/home/html/django_templates" or "C:/www/
>> django/templates".
>> # Always use forward slashes, even on Windows.
>> # Don't forget to use absolute paths, not relative paths.
>> 'C:/Python27/my_Djando_**projects/mysite/My_Templates/**admin/
>> base_site.html'
>> 'C:/Python27/my_Djando_**projects/mysite/My_Templates/**admin/
>> index.html'
>> 'C:/Python27/my_Djando_**projects/mysite/My_Templates/**polls/
>> index.html'
>> )
>> ..."
>>
>>
>> index.html:
>> "{% if latest_poll_list %}
>> 
>> {% for poll in latest_poll_list %}
>> {{ poll.question }}> li>
>> {% endfor %}
>> 
>> {% else %}
>> No polls are available.
>> {% endif %}
>> "
>>
>>
>>
>>
>> I keep getting the same error, which reads:
>>
>>
>> TemplateDoesNotExist at /polls/
>>
>> polls/index.html
>>
>> Request Method: GET
>> Request URL: http://localhost:8000/polls/
>> Django Version: 1.3.1
>> Exception Type: TemplateDoesNotExist
>> Exception Value:
>>
>> polls/index.html
>>
>> Exception Location: C:\Python27\lib\site-**packages\django\template
>>
>> \loader.py in find_template, line 138
>> Python Executable: C:\Python27\python.exe
>> Python Version: 2.7.2
>> Python Path:
>>
>> ['C:\\Python27\\my_Djando_**projects\\mysite',
>>  'C:\\Windows\\system32\\**python27.zip',
>>  'C:\\Python27\\DLLs',
>>  'C:\\Python27\\lib',
>>  'C:\\Python27\\lib\\plat-win'**,
>>  'C:\\Python27\\lib\\lib-tk',
>>  'C:\\Python27',
>>  'C:\\Python27\\lib\\site-**packages']
>>
>> Server time: Wed, 29 Feb 2012 11:32:54 -0800
>> Template-loader postmortem
>>
>> Django tried loading these templates, in this order:
>>
>> Using loader django.template.loaders.**filesystem.Loader:
>> c:\python27\my_djando_**projects\mysite\my_templates\**admin
>> \base_site.html
>> c:\python27\my_djando_**projects\mysite\my_templates\**admin\index.html
>> c:\python27\my_djando_**projects\mysite\my_templates\**polls\index.html
>> \polls\index.html (File does not exist)
>> Using loader django.template.loaders.app_**directories.Loader:
>> c:\python27\lib\site-packages\**django\contrib\admin\**templates\polls
>> \index.html (File does not exist)
>>
>>
>>
>>
>> What on earth am I doing wrong here? I've so many different variations
>> of my settings.py, views.py, and index.html. Any help would be much
>> appreciated.
>>
>>
>> Thanks,
>>
>> SB
>>
>>  --
> 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/-/klXbEFxYWH4J.
>
> 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.
>



-- 
Sami Balbaky
System Engineer - Ultrawave Labs

-- 
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: Unable to open database file

2012-03-02 Thread Brian Schott
Is the WSGI server running as www-data user, perhaps?  Check the permissions on 
the file with "ls -l".   Simple check would be "chmod a+rw "  to 
guarantee that it is writable by www-data.  

Brian Schott
bfsch...@gmail.com



On Feb 18, 2012, at 4:24 PM, j...@jsdey.com wrote:

> I'm another newbe and need you patient consideration.
> 
> I've worked my way through the polls tutorial.  Thinks seem to be
> working with django server.  When I use Django/Wsgi I vote from an
> external site but django is unable to open database from the line
> selected_choice.save().  The error message from debug is listed
> below.  Any guidance would be greatly appeciated. Thanks.
> 
> John
> 
> DatabaseError at /polls/1/vote/
> 
> unable to open database file
> 
> Request Method:   POST
> Request URL:  http://jsdey.com/polls/1/vote/
> Django Version:   1.3.1
> Exception Type:   DatabaseError
> Exception Value:
> 
> unable to open database file
> 
> Exception Location:   /usr/local/lib/python2.7/dist-packages/django/db/
> backends/sqlite3/base.py in execute, line 234
> Python Executable:/usr/bin/python
> Python Version:   2.7.1
> Python Path:
> 
> ['/usr/lib/python2.7',
> '/usr/lib/python2.7/plat-linux2',
> '/usr/lib/python2.7/lib-tk',
> '/usr/lib/python2.7/lib-old',
> '/usr/lib/python2.7/lib-dynload',
> '/usr/local/lib/python2.7/dist-packages',
> '/usr/lib/python2.7/dist-packages',
> '/usr/lib/python2.7/dist-packages/gtk-2.0',
> '/usr/lib/pymodules/python2.7',
> '/home/robo5/Django',
> '/home/robo5/Django/mysite']
> 
> Server time:  Sat, 18 Feb 2012 15:15:47 -0600
> Traceback Switch to copy-and-paste view
> 
>/usr/local/lib/python2.7/dist-packages/django/core/handlers/
> base.py in get_response
> 
>response = callback(request,
> *callback_args, **callback_kwargs)
> 
>...
>▶ Local vars
>/home/robo5/Django/mysite/polls/views.py in vote
> 
>selected_choice.save()
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/models/base.py in
> save
> 
>self.save_base(using=using, force_insert=force_insert,
> force_update=force_update)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/models/base.py in
> save_base
> 
>rows =
> manager.using(using).filter(pk=pk_val)._update(values)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/models/query.py
> in _update
> 
>return query.get_compiler(self.db).execute_sql(None)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/models/sql/
> compiler.py in execute_sql
> 
>cursor = super(SQLUpdateCompiler,
> self).execute_sql(result_type)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/models/sql/
> compiler.py in execute_sql
> 
>cursor.execute(sql, params)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py
> in execute
> 
>return self.cursor.execute(sql, params)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/
> base.py in execute
> 
>return Database.Cursor.execute(self, query,
> params)
> 
>...
>▶ Local vars
> 
> Request information
> GET
> 
> No GET data
> POST
> Variable  Value
> csrfmiddlewaretoken
> 
> u'de79b7a128450683be3814aad7a1af65'
> 
> choice
> 
> u'1'
> 
> FILES
> 
> No FILES data
> COOKIES
> Variable  Value
> csrftoken
> 
> 'de79b7a128450683be3814aad7a1af65'
> 
> __utma
> 
> '164886436.1396980123.1309309134.1325027492.1325041095.10'
> 
> __utmz
> 
> '164886436.1309309134.1.1.utmcsr=(direct)|utmccn=(direct)|
> utmcmd=(none)'
> 
> META
> Variable  Value
> mod_wsgi.listener_port
> 
> '80'
> 
> HTTP_COOKIE
> 
> '__utma=164886436.1396980123.1309309134.1325027492.1325041095.10;
> __utmz=164886436.1309309134.1.1.utmcsr=(direct)|utmccn=(direct)|
> utmcmd=(none); csrftoken=de79b7a128450683be3814aad7a1af65'
> 
> mod_wsgi.listener_host
> 
> ''
> 
> SERVER_SOFTWARE
> 
> 'Apache/2.2.17 (Ubuntu)'
> 
> SCRIPT_NAME
> 
> u''
> 
> mod_wsgi.handler_script
> 
> ''
> 
> SERVER_SIGNATURE
> 
> 'Apache/2.2.17 (Ubuntu) Server at jsdey.com Port 80
> \n'
> 
> REQUEST_METHOD
> 
> 'POST'
> 
> PATH_INFO
> 
> u'/polls/1/vote/'
> 
> SERVER_PROTOCOL
> 
> 'HTTP/1.1'
> 
> QUERY_STRING
> 
> ''
> 
> CONTENT_LENGTH
> 
> '61'
> 
> HTTP_ACCEPT_CHARSET
> 
> 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
> 
> HTTP_USER_AGENT
> 
> 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:9.0.1) Gecko/20100101
> Firefox/9.0.1'
> 
> HTTP_CONNECTION
> 
> 'keep-alive'
> 
> HTTP_REFERER
> 
> 'http://jsdey.com/polls/1/'
> 
> SERVER_NAME
> 
> 'jsdey.com'
> 
> REMOTE_ADDR
> 
> '96.242.86.85'
> 
> mod_wsgi.request_handler
> 
> 'wsgi-script'
> 
> wsgi.url_scheme
> 
> 'http'
> 
> PATH_TRANSLATED
> 
> 

Re: best resources for learning django

2012-03-02 Thread Larry Martell
On Fri, Mar 2, 2012 at 2:00 PM, Jonathan Holloway
 wrote:
> I sympathise with you.  I'm following the 1.3 online docs and hacking a site
> together at the moment.
>
> an up to date book would be awesome !!!
>
> I found looking at example projects on Github very useful.
>
> Cheers,
> Jon.
>
> --
> 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.

I think both of these books are excellent:

http://www.amazon.com/gp/product/143021936X/
http://www.amazon.com/Pro-Django-Experts-Voice-Development/dp/1430210478/

-- 
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: best resources for learning django

2012-03-02 Thread Djamel Gasbakid
I find this a very good ressource Django by Example: Django Tutorials -
Django by Example 

2012/3/2 Jonathan Holloway 

> I sympathise with you.  I'm following the 1.3 online docs and hacking a
> site together at the moment.
>
> an up to date book would be awesome !!!
>
> I found looking at example projects on Github very useful.
>
> Cheers,
> Jon.
>
> --
> 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.
>

-- 
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: best resources for learning django

2012-03-02 Thread Jonathan Holloway
I sympathise with you.  I'm following the 1.3 online docs and hacking a
site together at the moment.

an up to date book would be awesome !!!

I found looking at example projects on Github very useful.

Cheers,
Jon.

-- 
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: South with multiple virtual hosts

2012-03-02 Thread Greg
As a kind soul nicely pointed out to me elsewhere, I don't have a
problem.  The migration history is DB specific, so simply run the
schemamigration using any settings file, then do the migrate with all
settings files.  Doh!

It's been a long week.


On Mar 2, 3:55 pm, Greg  wrote:

-- 
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: Traceback from csrf_exempt in 1.3.1

2012-03-02 Thread Ethan Whitt
I get a 403 error when I comment out csrf_example as such:

auth/views.py
from django.http import HttpResponse
from django.utils import simplejson
#from django.views.decorators.csrf import csrf_exempt

#@csrf_exempt
def json_api(request):
  return HttpResponse(simplejson.dumps(request), mimetype="application/
json")

Here is my urls.py

url(r'^auth/', 'auth.views.json_api'),

Once I uncomment the two csrf_exempt statements, I get the 500 error?
Any ideas?



On Mar 2, 6:57 am, Thomas Orozco  wrote:
> You seem to have no 500.html page.
>
> This traceback won't actually show the error that happened, but error out
> on the fact that it can't find a template to display the 500 error.
>
> 1. Are you running DEBUG = True?
> 2. Wouldn't you rather want to simplejson.dum
>
>
>
>
>
>
>
>
>
> > I have never used csrf_exempt before.  I keep experiencing a traceback
> > with 1.3.1, which may be self-induced. Here is my views file:
>
> > auth/views.py
> > from django.http import HttpResponse
> > from django.utils import simplejson
> > from django.views.decorators.csrf import csrf_exempt
>
> > @csrf_exempt
> > def json_api(request):
> >    return HttpResponse(simplejson.dumps(request),
> > mimetype="application/json")
>
> > When I do a curl:
>
> > curl -i -X POST -d '{"screencast":{"subject":"tools"}}'
> >http://127.0.0.1:8000/auth/
>
> > I experience 500 Internal Server Error:
>
> > Traceback (most recent call last):
>
> >  File "/Library/Python/2.7/site-packages/django/core/servers/
> > basehttp.py", line 283, in run
> >    self.result = application(self.environ, self.start_response)
>
> >  File "/Library/Python/2.7/site-packages/django/core/handlers/
> > wsgi.py", line 272, in __call__
> >    response = self.get_response(request)
>
> >  File "/Library/Python/2.7/site-packages/django/core/handlers/
> > base.py", line 169, in get_response
> >    response = self.handle_uncaught_exception(request, resolver,
> > sys.exc_info())
>
> >  File "/Library/Python/2.7/site-packages/django/core/handlers/
> > base.py", line 218, in handle_uncaught_exception
> >    return callback(request, **param_dict)
>
> >  File "/Library/Python/2.7/site-packages/django/utils/decorators.py",
> > line 93, in _wrapped_view
> >    response = view_func(request, *args, **kwargs)
>
> >  File "/Library/Python/2.7/site-packages/django/views/defaults.py",
> > line 30, in server_error
> >    t = loader.get_template(template_name) # You need to create a
> > 500.html template.
>
> >  File "/Library/Python/2.7/site-packages/django/template/loader.py",
> > line 157, in get_template
> >    template, origin = find_template(template_name)
>
> >  File "/Library/Python/2.7/site-packages/django/template/loader.py",
> > line 138, in find_template
> >    raise TemplateDoesNotExist(name)
>
> > --
> > 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.

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



Re: Django profile

2012-03-02 Thread Bolang

On 03/03/2012 03:33 AM, Denis Darii wrote:

1. http://pinaxproject.com/
2. http://django-userena.org/


Thanks Denis,
Django userena looks very interesting.



On Fri, Mar 2, 2012 at 9:26 PM, Bolang > wrote:

Can someone suggest me an application for adding user profile to django?
I have found http://code.google.com/p/__django-profile/
 and
https://bitbucket.org/__ubernostrum/django-profiles
 but those 2
projects don't receive update recently.

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: Django profile

2012-03-02 Thread creecode
Hello Bo,

On Friday, March 2, 2012 12:26:05 PM UTC-8, Bo Lang wrote:
>
> Can someone suggest me an application for adding user profile to django?
> I have found
> https://bitbucket.org/ubernostrum/django-profiles


Give James Bennett's django-profiles a go if you think it will meet your 
needs.  James does excellent work!
 

> but those 2 projects 
> don't receive update recently.


Just because something hasn't been updated recently doesn't mean it's not 
current, useful, or popular.  It can simply mean that the software does 
what it needs to and there has been no reason to update it.

Toodle-loo...
creecode

-- 
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/-/o-5oXFPLUJkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django profile

2012-03-02 Thread Denis Darii
1. http://pinaxproject.com/
2. http://django-userena.org/

On Fri, Mar 2, 2012 at 9:26 PM, Bolang  wrote:

> Can someone suggest me an application for adding user profile to django?
> I have found 
> http://code.google.com/p/**django-profile/and
> https://bitbucket.org/**ubernostrum/django-profilesbut
>  those 2 projects don't receive update recently.
>
> 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>


-- 
This e-mail and any file transmitted with it is intended only for the
person or entity to which is addressed and may contain information that is
privileged, confidential or otherwise protected from disclosure. Copying,
dissemination or use of this e-mail or the information herein by anyone
other than the intended recipient is prohibited. If you are not the
intended recipient, please notify the sender immediately by return e-mail,
delete this communication and destroy all copies.

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



Django profile

2012-03-02 Thread Bolang

Can someone suggest me an application for adding user profile to django?
I have found http://code.google.com/p/django-profile/ and 
https://bitbucket.org/ubernostrum/django-profiles but those 2 projects 
don't receive update recently.


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: Automated Processes

2012-03-02 Thread Jamie Lawrence

On Mar 2, 2012, at 12:10 PM, Scott Macri wrote:

> I'm trying to figure out the best way to create an automated in a
> python/django web application.  My intention is to send an email
> message in the future based on the given future date/time.  What is
> the best approach to do this?
> 
> I was thinking of creating a cron job and a python script, but I would
> rather have the process be part of my django application so I don't
> have to worry about extra stuff.

If you want to have the active code in Django, you could run a cron to call 
wget or similar to call a specific URL that does whatever. If you choose to do 
this, make sure it is locked down - perhaps only execute if REMOTE_HOST is 
127.0.0.1.

I generally don't recommend this approach, because it really is mixing distinct 
functions. What happens if you grow to multiple servers? What happens if you're 
sending enough mail that you split that off to its own cluster?

Note that it should be straightforward to pull in the Django template classes, 
if you want to use that for generating your messages.

Also, note that this is precisely what cron is for. Attempting to recreate cron 
inside of a web application is going to end in tears. Keep your cron job and 
support scripts in a separate directory in your source repository, and add a 
checklist for setting it up to your documentation (which is also versioned, 
right?).

My .02 units of your currency,

-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-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: Automated Processes

2012-03-02 Thread Scott Macri
Sorry, that should read "create an automated process".

On Fri, Mar 2, 2012 at 3:10 PM, Scott Macri  wrote:
> I'm trying to figure out the best way to create an automated in a
> python/django web application.  My intention is to send an email
> message in the future based on the given future date/time.  What is
> the best approach to do this?
>
> I was thinking of creating a cron job and a python script, but I would
> rather have the process be part of my django application so I don't
> have to worry about extra stuff.
>
> Another thought was to use a time, but if the timer process stops
> before the message is sent, that's it KABAM.
>
> Any thoughts on how to handle this situation?  Thanks.
>
> Scott



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

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



Automated Processes

2012-03-02 Thread Scott Macri
I'm trying to figure out the best way to create an automated in a
python/django web application.  My intention is to send an email
message in the future based on the given future date/time.  What is
the best approach to do this?

I was thinking of creating a cron job and a python script, but I would
rather have the process be part of my django application so I don't
have to worry about extra stuff.

Another thought was to use a time, but if the timer process stops
before the message is sent, that's it KABAM.

Any thoughts on how to handle this situation?  Thanks.

Scott

-- 
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: best resources for learning django

2012-03-02 Thread Zeengr
After reading the django tutorial mentioned above,
 I recommend reading http://www.djangobook.com/en/2.0/
then start reading more about any topic you need to work with from django 
documentaion https://docs.djangoproject.com/

On Friday, March 2, 2012 8:11:07 PM UTC+2, arvapo wrote:
>
> Hi all, 
>
> Simple question: For a newbie like me, what is (are) the best 
> resource(s) to learn django? books, etc... 
>
> I just installed version 1.3.1 
>
> Looking forward to your replies. 
>
> Cheers, 
> Arvapo

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



Registration and Authentication using google accounts.

2012-03-02 Thread Zeengr
Hi,

I want to let my users to register using there google accounts so later can 
communicate with there google apps services like Documents, Picasa , 
Calendar ... etc.

What is your advice.

-- 
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/-/6bU_mmpDAg8J.
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.



South with multiple virtual hosts

2012-03-02 Thread Greg
Hi,

We have a setup where multiple domains via Apache's VirtualHost are
pointed to individual settings.py files using WSGI.  Works great.
Each domain shares the same codebase and each domain has its own DB
specified in the settings file.  Again, works great.  Now the
problem.  If I need to do a South migration I can specify a settings
module, but how do I do the same migration on more than one settings
file/DB?  So far, the only thing I can think of is to delete the
migration files, and delete the migration history records. Then redo
the schemamigration and migrate.  But, that's a little scary.

Any thoughts on how this could be streamlined?

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: best resources for learning django

2012-03-02 Thread Andre Terra
First of all, welcome to Django!

If you're not familiar with python (and specially managing python
packages), I recommend you setup a sane development environment. Namely
using virtualenv and pip, and optionally mkvirtualenv (if you're not on
windows).

Having to figure out import errors is usually very a frustrating obstacle,
especially for newbies.



http://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django/
http://www.doughellmann.com/docs/virtualenvwrapper/


Cheers,
AT


On Fri, Mar 2, 2012 at 3:48 PM, Javier Guerra Giraldez
wrote:

> On Fri, Mar 2, 2012 at 1:23 PM, gowtham  wrote:
> > Not sure if it is the best one (would like to here from Pros on this).
> But
> > following really helped me to get started. I  finishing this tutorial in
> 2
> > days and the next two days, i started and had a working application
> (simple
> > though) for my project..
> >
> > https://docs.djangoproject.com/en/1.2/intro/tutorial01/
>
>
> even if you find any other 'better' source, the tutorials are a
> necessary prerequisite.  there are lots of times where a newcomer asks
> something in the list and even if the answer might not be in the
> tutorials themselves, not doing them leads to a big obstacle to
> communication.
>
> for me, the best order is:
>
> - the tutorials (all of them, even if they're not related to your needs)
> - ask a little in the list.
> - read other sections in the documentation.
> - read the Django Book.  even if it's a little dated, the concepts stay
> valid.
> - ask a little more on the list
> - read the whole docs.
> - start answering on the list!  yes, that helps learning too
>
> --
> Javier
>
> --
> 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.
>
>

-- 
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: select_related() and RawQuerySet

2012-03-02 Thread akaariai
On Friday, March 2, 2012 7:24:00 PM UTC+2, Tom Evans wrote:
>
> Hi all
>
> I have a particular query that requires me to use a RawQuerySet - I
> need to left join the table to itself in order to select the highest
> 'priority' row from the table for each distinct value of a foreign key
> on the model, and I need to join to the related table in order to
> filter the results.
>
> Having generated the queryset, I then want to make a dictionary of {
> foreign_key_object : model_object }. So I have this working, but I
> cannot use select_related() with a RawQuerySet, and so this runs N+1
> queries, where N is the number of distinct foreign keys.
>
> Here is some code, which might explain it better:
>
> connection.queries=[]
> base_products_qs = Product.objects.raw(
> """
> SELECT idp_product.*, idp_productclass.*
> FROM idp_product
> JOIN idp_productclass
> ON idp_product.product_class_id = idp_productclass.id
> LEFT JOIN idp_product p2
> ON idp_product.product_class_id = p2.product_class_id
> AND p2.class_priority < idp_product.class_priority
> WHERE p2.id IS NULL and idp_productclass.product_type != 4
> """)
> base_products = dict([ (p.product_class, p) for p in base_products_qs ])
> len(connection.queries) # 7 queries (6 product classes)
>
> Is there any simple way around this? I can reduce it to two queries
> already, but it seems wrong to select out the info I want, throw it
> away, and then fetch it again.
>
 Some suggestions:
  - If the 2-query version is fast enough, use it. Premature optimization 
and all that... :)
  - You could of course manually iterate through the SQL and instantiate 
the models by hand.
  - Beware of the left join, it seems if you have a lot of rows with 
different class_priorities for each product_class_id you might be in 
trouble. The filtering on IS NULL happens after doing the join, so before 
the filter you could have a lot of intermediate rows. It might be there is 
no problem depending of the amount of rows and SQL vendor. Hard to know 
without testing. There are a couple of other ways to do the query, either 
by subquery doing a select min(class_priority), product_class_id or if you 
are using PostgreSQL, distinct on would do the job for you, too.

All that being said, I would really like the ability to have select_related 
available for RawQuerySet. It might be judged to be a feature not needed 
commonly enough, so it is possible it would not get in even with a good 
quality patch. However, if it had a nice API, and the implementation reused 
the code of QuerySet select_related, I think it could have a chance to get 
in.

 - Anssi

-- 
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/-/18iQZDj801EJ.
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: best resources for learning django

2012-03-02 Thread Javier Guerra Giraldez
On Fri, Mar 2, 2012 at 1:23 PM, gowtham  wrote:
> Not sure if it is the best one (would like to here from Pros on this). But
> following really helped me to get started. I  finishing this tutorial in 2
> days and the next two days, i started and had a working application (simple
> though) for my project..
>
> https://docs.djangoproject.com/en/1.2/intro/tutorial01/


even if you find any other 'better' source, the tutorials are a
necessary prerequisite.  there are lots of times where a newcomer asks
something in the list and even if the answer might not be in the
tutorials themselves, not doing them leads to a big obstacle to
communication.

for me, the best order is:

- the tutorials (all of them, even if they're not related to your needs)
- ask a little in the list.
- read other sections in the documentation.
- read the Django Book.  even if it's a little dated, the concepts stay valid.
- ask a little more on the list
- read the whole docs.
- start answering on the list!  yes, that helps learning too

-- 
Javier

-- 
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: best resources for learning django

2012-03-02 Thread gowtham
Not sure if it is the best one (would like to here from Pros on this). But
following really helped me to get started. I  finishing this tutorial in 2
days and the next two days, i started and had a working application (simple
though) for my project..

https://docs.djangoproject.com/en/1.2/intro/tutorial01/


-Gowthaman
On Fri, Mar 2, 2012 at 10:11 AM, arvapo  wrote:

> Hi all,
>
> Simple question: For a newbie like me, what is (are) the best
> resource(s) to learn django? books, etc...
>
> I just installed version 1.3.1
>
> Looking forward to your replies.
>
> Cheers,
> Arvapo
>
> --
> 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.
>
>


-- 
Gowthaman

Bioinformatics Systems Programmer.
SBRI, 307 West lake Ave N Suite 500
Seattle, WA. 98109-5219
Phone : LAB 206-256-7188 (direct).

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



best resources for learning django

2012-03-02 Thread arvapo
Hi all,

Simple question: For a newbie like me, what is (are) the best
resource(s) to learn django? books, etc...

I just installed version 1.3.1

Looking forward to your replies.

Cheers,
Arvapo

-- 
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: UnicodeEncodeError in file uploads

2012-03-02 Thread Andreas Hasenkopf
In some older group post I found a nice django-based solution: Using a
customized ImageField instance:

class MyImageField(ImageField):

def __init__(self, *args, **kwargs):
super(MyImageField, self).__init__(*args, **kwargs)

def clean(self, *args, **kwargs):
data = super(MyImageField, self).clean(*args, **kwargs)
data.name = slugify_name(data.name)
return data



signature.asc
Description: OpenPGP digital signature


Re: UnicodeEncodeError in file uploads

2012-03-02 Thread Andreas Hasenkopf
Hi there,
tried upload of file containing file with umlaut in filename on a Ubuntu
server with de_DE.UTF8 locale setting. This server also produces a
UnicodeEncodeError error.

locale -a gives the following output:
C
en_AG
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_NG
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZW.utf8
POSIX

The server with German locale setting also has de_XX.UTF8 codings...

cu Andi



signature.asc
Description: OpenPGP digital signature


Re: Is GeoDjango Too Much For This?

2012-03-02 Thread Josh Cartmell
I have two quick comments, check out geopy:
http://code.google.com/p/geopy/
and this website 
http://www.movable-type.co.uk/scripts/latlong-db.html

Geopy can give you lat/lng for a given address and that other website has 
formulas for using lat/lng to calculate a bounding box/circle.  It may be a 
little simpler to do things that way vs. using GeoDjango although possibly 
not as efficient.

On Friday, March 2, 2012 6:11:46 AM UTC-8, Ethan Jucovy wrote:
>
> On Mon, Feb 27, 2012 at 11:42 PM, DF  wrote:
>
>> I'm on a Mac. The Django GeoDjango installation instructions are
>> somewhat obtuse and there aren't alternative sites I've found with
>> more straightforward instructions. It's lame that these are confusing
>> but, well, they are. I will no doubt review the sites you recommended.
>>
>
> Oh .. yeah, I've never tried installation on a Mac.  Googling around a bit 
> turns up 
> http://lincolnloop.com/blog/2010/apr/30/installing-geodjango-dependencies-homebrew/
>  (as 
> well as a lot of confusing stufff that scared me off) -- maybe that would 
> Just Work?
>  
>
>> As a newcomer who suddenly feels he may be biting off more than he can
>> chew, one of my worries it that if I utilize the sqlite3 database for
>> development with Spatialite, when I finally deploy this to, say, a
>> Postgres database, it won't transition correctly. This is most likely
>> due to my naiveté about databases, but I'm just concerned once it's
>> deployed, it won't work because I screwed something up by using
>> sqlite3 and I'm now trying to use another type of database.
>>
>
> That is a reasonable concern.  For what it's worth, you're *likely* to not 
> have any problems switching from sqlite to postgres midstream, as long as 
> you stick to Django's ORM and querying methods; of course if you drop down 
> into raw SQL problems will be more likely.  I usually start out local 
> development on sqlite and switch to postgres sometime later.  But of course 
> you're right that the most conservative approach is to pick one database 
> and start with it.
>  
>
>> From your textbook descriptions (awesome) it seems that GeoIP is what
>> I'm looking for. Essentially, a logged-in user's coordinates would be
>> taken from their IP address (not sure if GeoDjango has a way to do
>> this without front-end JS work (more terror)) 
>
>
> Yes, using GeoIP doesn't require any front-end work.  Your backend just 
> gets an IP address with every request, and you can ask django.contrib.gis 
> to locate that IP.  Something like this: https://gist.github.com/1958529 -- 
> which you would then store in your database through a GeoDjango PointField.
>  
>
>> The problem with using HTML5 is, while it seems easy (there's pre-
>> formatted code out there that makes it a cinch to identify IP
>> location), it really provides no simple way to store or search for
>> content that's identified via GeoIP.
>>
>
> Literally speaking this is true, but you would use it in conjunction with 
> backend code.  HTML5 Geolocation is just concerned with reliably 
> identifying the user's location on the client side.  You could then write a 
> bit of Javascript attached to your submission forms that inserts that 
> location data into the form submission.  Then on the server side, you have 
> a lat/lng you can store with GeoDjango's PointField for future querying.
>
> HTML5 Geolocation is most useful (and I believe has the most 
> implementations) in the mobile world. If your users will be uploading 
> content to your application from smartphones then this is a good feature to 
> use.
>
> It's best to think about (client-side) HTML5 Geolocation and (server-side) 
> GeoIP as complementary features for graceful degredation.  If data from 
> HTML5 Geolocation is available, use it; if not, you can fall back on GeoIP. 
>  HTML5 Geolocation data, if present, is more likely to be both accurate and 
> precise; geotagging content based on the user's IP address is a 
> coarser-grained solution and can also return incorrect data in some 
> circumstances -- depending on the details of the user's internet 
> connection, the originating IP address could be somewhere else entirely.
>
> - GeoDjango using the GeoIP features
>> - OpenLayers (have heard about it; need to research more)
>> - Google Maps or another mapping service, being wary of limits
>>
>
> Yup, that sounds right, with the caveat above that you may want to layer 
> on HTML5 Geolocation as a progressive enhancement.
>
> Hope this helps,
> Ethan
>

On Friday, March 2, 2012 6:11:46 AM UTC-8, Ethan Jucovy wrote:
>
> On Mon, Feb 27, 2012 at 11:42 PM, DF  wrote:
>
>> I'm on a Mac. The Django GeoDjango installation instructions are
>> somewhat obtuse and there aren't alternative sites I've found with
>> more straightforward instructions. It's lame that these are confusing
>> but, well, they are. I will no doubt review the sites you recommended.
>>
>
> Oh .. yeah, I've never tried installation 

select_related() and RawQuerySet

2012-03-02 Thread Tom Evans
Hi all

I have a particular query that requires me to use a RawQuerySet - I
need to left join the table to itself in order to select the highest
'priority' row from the table for each distinct value of a foreign key
on the model, and I need to join to the related table in order to
filter the results.

Having generated the queryset, I then want to make a dictionary of {
foreign_key_object : model_object }. So I have this working, but I
cannot use select_related() with a RawQuerySet, and so this runs N+1
queries, where N is the number of distinct foreign keys.

Here is some code, which might explain it better:

connection.queries=[]
base_products_qs = Product.objects.raw(
"""
SELECT idp_product.*, idp_productclass.*
FROM idp_product
JOIN idp_productclass
ON idp_product.product_class_id = idp_productclass.id
LEFT JOIN idp_product p2
ON idp_product.product_class_id = p2.product_class_id
AND p2.class_priority < idp_product.class_priority
WHERE p2.id IS NULL and idp_productclass.product_type != 4
""")
base_products = dict([ (p.product_class, p) for p in base_products_qs ])
len(connection.queries) # 7 queries (6 product classes)

Is there any simple way around this? I can reduce it to two queries
already, but it seems wrong to select out the info I want, throw it
away, and then fetch it again.

two query version:

base_products_qs = Product.objects.raw(
"""
SELECT idp_product.*
FROM idp_product
JOIN idp_productclass
ON idp_product.product_class_id = idp_productclass.id
LEFT JOIN idp_product p2
ON idp_product.product_class_id = p2.product_class_id
AND p2.class_priority < idp_product.class_priority
WHERE p2.id IS NULL and idp_productclass.product_type != 4
""")
base_products_ = dict([ (p.product_class_id, p) for p in base_products_qs ])
prod_classes_qs = ProductClass.objects.filter(pk__in=base_products_.keys())
prod_classes = dict([ (pc.id, pc) for pc in prod_classes_qs ])
base_products = dict([ (prod_classes.get(k), v)
for k, v in base_products_.items() ])


Cheers for any pointers

Tom

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



Re: Traceback from csrf_exempt in 1.3.1

2012-03-02 Thread Thomas Orozco
You seem to have no 500.html page.

This traceback won't actually show the error that happened, but error out
on the fact that it can't find a template to display the 500 error.

1. Are you running DEBUG = True?
2. Wouldn't you rather want to simplejson.dum
>
> I have never used csrf_exempt before.  I keep experiencing a traceback
> with 1.3.1, which may be self-induced. Here is my views file:
>
> auth/views.py
> from django.http import HttpResponse
> from django.utils import simplejson
> from django.views.decorators.csrf import csrf_exempt
>
> @csrf_exempt
> def json_api(request):
>return HttpResponse(simplejson.dumps(request),
> mimetype="application/json")
>
> When I do a curl:
>
> curl -i -X POST -d '{"screencast":{"subject":"tools"}}'
> http://127.0.0.1:8000/auth/
>
> I experience 500 Internal Server Error:
>
> Traceback (most recent call last):
>
>  File "/Library/Python/2.7/site-packages/django/core/servers/
> basehttp.py", line 283, in run
>self.result = application(self.environ, self.start_response)
>
>  File "/Library/Python/2.7/site-packages/django/core/handlers/
> wsgi.py", line 272, in __call__
>response = self.get_response(request)
>
>  File "/Library/Python/2.7/site-packages/django/core/handlers/
> base.py", line 169, in get_response
>response = self.handle_uncaught_exception(request, resolver,
> sys.exc_info())
>
>  File "/Library/Python/2.7/site-packages/django/core/handlers/
> base.py", line 218, in handle_uncaught_exception
>return callback(request, **param_dict)
>
>  File "/Library/Python/2.7/site-packages/django/utils/decorators.py",
> line 93, in _wrapped_view
>response = view_func(request, *args, **kwargs)
>
>  File "/Library/Python/2.7/site-packages/django/views/defaults.py",
> line 30, in server_error
>t = loader.get_template(template_name) # You need to create a
> 500.html template.
>
>  File "/Library/Python/2.7/site-packages/django/template/loader.py",
> line 157, in get_template
>template, origin = find_template(template_name)
>
>  File "/Library/Python/2.7/site-packages/django/template/loader.py",
> line 138, in find_template
>raise TemplateDoesNotExist(name)
>
> --
> 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.
>
>

-- 
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: Keeping filters when adding in the admin interface

2012-03-02 Thread Mauro Sánchez
El día 2 de marzo de 2012 11:06, Marc Aymerich  escribió:
> On Fri, Mar 2, 2012 at 2:18 PM, Mauro Sánchez  wrote:
>> El día 29 de febrero de 2012 19:04, Marc Aymerich
>>  escribió:
>>> On Wed, Feb 29, 2012 at 10:55 PM, Marc Aymerich  wrote:
 On Wed, Feb 29, 2012 at 8:22 PM, Mauro Sánchez  wrote:
> Hello, if I have the following Model:
>
> class A:
>    name
>
> class B:
>    name
>    a = models.ForeignKey(A)
>
> class C:
>    name
>    b = models.ForeignKey(B)
>
> And let's suppose that in the Admin Site I have a Filter in the C list
> that refers to the A model. Is there a way to keep that filter when I
> am going to add a new C object and use it to filter the combobox of
> the b filed so that it will only show the b objects that are related
> to the A model in the filter?
> For example:
> If the filter I choose points to the id=1 in the A model, the combobox
> for the b field when I add a C object only has to show the B objects
> that has a = 1
>

 If I understand you righ, it's a bit triky stuff, you have to do two 
 things:
 1)  Define a custom add_form and override their __init__ method with
 something like:
  self.fields['b'].queryset = self.fields['b'].queryset.filter(a=a_pk)
 2)  Provides the current value of your filter (a_pk) to the defined form 
 on 1)
  I think this can be done overriding modeladmin.get_form() method
 since request is one of their args, so you can extract the value of
 the filter on the http referer url and provide it to the form that
 this method creates.

>>>
>>> More specifically:
>>>
>>> def get_form(self, request, *args **kwargs):
>>>    form = super(YourModelAdmin, self).get_form(request, *args, **kwargs)
>>>    a_pk = get_a_pk_from_http_referer(request)
>>>    form.a_pk = a_pk
>>>    return form
>>>
>>> def __init__(self, *args, **kwargs):
>>>   super(YourModelForm, self).__init__(*args, **kwargs)
>>>   self.fields['b'].queryset = self.fields['b'].queryset.filter(a=self.a_pk)
>>>
>>
>> Hello Marc,
>> the filter in the __init__ method works fine. I know this because I
>> have set a value manually.
>> But I have a problem when I try to pass the value self.a_pk to the
>> filter in the queryset defined in the __init__ method. This is the
>> error I get:
>>
>> 'CForm' object has no attribute 'a_pk'
>>
>> It's like the form never received this new variable. What can be the
>> problem here?
>>
>
> Mmm I never overrided get_form before, so I can not tell for sure what
> is wrong. But something you can try with more chances of success is:
>
> def get_form(self, request, *args **kwargs):
>   self.form.a_pk = get_a_pk_from_http_referer(request)
>   return  super(YourModelAdmin, self).get_form(request, *args, **kwargs)
>
> Or maybe... are you working with inlines? if it is the case, you must
> override get_formset of the inline class.
>

Hello Marc, I has just realized that I was placing the get_form
definition in the wrong place. The correct place to place it is in the
CAdmin redefinition.
The code you paste in the first place works great.
Thanks a lot for the help.
Greetings.
Mauro.

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



Re: Is GeoDjango Too Much For This?

2012-03-02 Thread Ethan Jucovy
On Mon, Feb 27, 2012 at 11:42 PM, DF  wrote:

> I'm on a Mac. The Django GeoDjango installation instructions are
> somewhat obtuse and there aren't alternative sites I've found with
> more straightforward instructions. It's lame that these are confusing
> but, well, they are. I will no doubt review the sites you recommended.
>

Oh .. yeah, I've never tried installation on a Mac.  Googling around a bit
turns up
http://lincolnloop.com/blog/2010/apr/30/installing-geodjango-dependencies-homebrew/
(as
well as a lot of confusing stufff that scared me off) -- maybe that would
Just Work?


> As a newcomer who suddenly feels he may be biting off more than he can
> chew, one of my worries it that if I utilize the sqlite3 database for
> development with Spatialite, when I finally deploy this to, say, a
> Postgres database, it won't transition correctly. This is most likely
> due to my naiveté about databases, but I'm just concerned once it's
> deployed, it won't work because I screwed something up by using
> sqlite3 and I'm now trying to use another type of database.
>

That is a reasonable concern.  For what it's worth, you're *likely* to not
have any problems switching from sqlite to postgres midstream, as long as
you stick to Django's ORM and querying methods; of course if you drop down
into raw SQL problems will be more likely.  I usually start out local
development on sqlite and switch to postgres sometime later.  But of course
you're right that the most conservative approach is to pick one database
and start with it.


> From your textbook descriptions (awesome) it seems that GeoIP is what
> I'm looking for. Essentially, a logged-in user's coordinates would be
> taken from their IP address (not sure if GeoDjango has a way to do
> this without front-end JS work (more terror))


Yes, using GeoIP doesn't require any front-end work.  Your backend just
gets an IP address with every request, and you can ask django.contrib.gis
to locate that IP.  Something like this: https://gist.github.com/1958529 --
which you would then store in your database through a GeoDjango PointField.


> The problem with using HTML5 is, while it seems easy (there's pre-
> formatted code out there that makes it a cinch to identify IP
> location), it really provides no simple way to store or search for
> content that's identified via GeoIP.
>

Literally speaking this is true, but you would use it in conjunction with
backend code.  HTML5 Geolocation is just concerned with reliably
identifying the user's location on the client side.  You could then write a
bit of Javascript attached to your submission forms that inserts that
location data into the form submission.  Then on the server side, you have
a lat/lng you can store with GeoDjango's PointField for future querying.

HTML5 Geolocation is most useful (and I believe has the most
implementations) in the mobile world. If your users will be uploading
content to your application from smartphones then this is a good feature to
use.

It's best to think about (client-side) HTML5 Geolocation and (server-side)
GeoIP as complementary features for graceful degredation.  If data from
HTML5 Geolocation is available, use it; if not, you can fall back on GeoIP.
 HTML5 Geolocation data, if present, is more likely to be both accurate and
precise; geotagging content based on the user's IP address is a
coarser-grained solution and can also return incorrect data in some
circumstances -- depending on the details of the user's internet
connection, the originating IP address could be somewhere else entirely.

- GeoDjango using the GeoIP features
> - OpenLayers (have heard about it; need to research more)
> - Google Maps or another mapping service, being wary of limits
>

Yup, that sounds right, with the caveat above that you may want to layer on
HTML5 Geolocation as a progressive enhancement.

Hope this helps,
Ethan

-- 
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: Keeping filters when adding in the admin interface

2012-03-02 Thread Marc Aymerich
On Fri, Mar 2, 2012 at 2:18 PM, Mauro Sánchez  wrote:
> El día 29 de febrero de 2012 19:04, Marc Aymerich
>  escribió:
>> On Wed, Feb 29, 2012 at 10:55 PM, Marc Aymerich  wrote:
>>> On Wed, Feb 29, 2012 at 8:22 PM, Mauro Sánchez  wrote:
 Hello, if I have the following Model:

 class A:
    name

 class B:
    name
    a = models.ForeignKey(A)

 class C:
    name
    b = models.ForeignKey(B)

 And let's suppose that in the Admin Site I have a Filter in the C list
 that refers to the A model. Is there a way to keep that filter when I
 am going to add a new C object and use it to filter the combobox of
 the b filed so that it will only show the b objects that are related
 to the A model in the filter?
 For example:
 If the filter I choose points to the id=1 in the A model, the combobox
 for the b field when I add a C object only has to show the B objects
 that has a = 1

>>>
>>> If I understand you righ, it's a bit triky stuff, you have to do two things:
>>> 1)  Define a custom add_form and override their __init__ method with
>>> something like:
>>>  self.fields['b'].queryset = self.fields['b'].queryset.filter(a=a_pk)
>>> 2)  Provides the current value of your filter (a_pk) to the defined form on 
>>> 1)
>>>  I think this can be done overriding modeladmin.get_form() method
>>> since request is one of their args, so you can extract the value of
>>> the filter on the http referer url and provide it to the form that
>>> this method creates.
>>>
>>
>> More specifically:
>>
>> def get_form(self, request, *args **kwargs):
>>    form = super(YourModelAdmin, self).get_form(request, *args, **kwargs)
>>    a_pk = get_a_pk_from_http_referer(request)
>>    form.a_pk = a_pk
>>    return form
>>
>> def __init__(self, *args, **kwargs):
>>   super(YourModelForm, self).__init__(*args, **kwargs)
>>   self.fields['b'].queryset = self.fields['b'].queryset.filter(a=self.a_pk)
>>
>
> Hello Marc,
> the filter in the __init__ method works fine. I know this because I
> have set a value manually.
> But I have a problem when I try to pass the value self.a_pk to the
> filter in the queryset defined in the __init__ method. This is the
> error I get:
>
> 'CForm' object has no attribute 'a_pk'
>
> It's like the form never received this new variable. What can be the
> problem here?
>

Mmm I never overrided get_form before, so I can not tell for sure what
is wrong. But something you can try with more chances of success is:

def get_form(self, request, *args **kwargs):
   self.form.a_pk = get_a_pk_from_http_referer(request)
   return  super(YourModelAdmin, self).get_form(request, *args, **kwargs)

Or maybe... are you working with inlines? if it is the case, you must
override get_formset of the inline class.

-- 
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-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: Keeping filters when adding in the admin interface

2012-03-02 Thread Mauro Sánchez
El día 29 de febrero de 2012 19:04, Marc Aymerich
 escribió:
> On Wed, Feb 29, 2012 at 10:55 PM, Marc Aymerich  wrote:
>> On Wed, Feb 29, 2012 at 8:22 PM, Mauro Sánchez  wrote:
>>> Hello, if I have the following Model:
>>>
>>> class A:
>>>    name
>>>
>>> class B:
>>>    name
>>>    a = models.ForeignKey(A)
>>>
>>> class C:
>>>    name
>>>    b = models.ForeignKey(B)
>>>
>>> And let's suppose that in the Admin Site I have a Filter in the C list
>>> that refers to the A model. Is there a way to keep that filter when I
>>> am going to add a new C object and use it to filter the combobox of
>>> the b filed so that it will only show the b objects that are related
>>> to the A model in the filter?
>>> For example:
>>> If the filter I choose points to the id=1 in the A model, the combobox
>>> for the b field when I add a C object only has to show the B objects
>>> that has a = 1
>>>
>>
>> If I understand you righ, it's a bit triky stuff, you have to do two things:
>> 1)  Define a custom add_form and override their __init__ method with
>> something like:
>>  self.fields['b'].queryset = self.fields['b'].queryset.filter(a=a_pk)
>> 2)  Provides the current value of your filter (a_pk) to the defined form on 
>> 1)
>>  I think this can be done overriding modeladmin.get_form() method
>> since request is one of their args, so you can extract the value of
>> the filter on the http referer url and provide it to the form that
>> this method creates.
>>
>
> More specifically:
>
> def get_form(self, request, *args **kwargs):
>    form = super(YourModelAdmin, self).get_form(request, *args, **kwargs)
>    a_pk = get_a_pk_from_http_referer(request)
>    form.a_pk = a_pk
>    return form
>
> def __init__(self, *args, **kwargs):
>   super(YourModelForm, self).__init__(*args, **kwargs)
>   self.fields['b'].queryset = self.fields['b'].queryset.filter(a=self.a_pk)
>

Hello Marc,
the filter in the __init__ method works fine. I know this because I
have set a value manually.
But I have a problem when I try to pass the value self.a_pk to the
filter in the queryset defined in the __init__ method. This is the
error I get:

'CForm' object has no attribute 'a_pk'

It's like the form never received this new variable. What can be the
problem here?

Thanks for the help.
Mauro.

-- 
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: Caught TypeError while rendering: __init__() got an unexpected keyword argument 'maxlength'

2012-03-02 Thread Daniel Roseman
On Friday, 2 March 2012 09:56:26 UTC, Vipulb wrote:
>
> I tried to enable admin and i got this error...
>
> I am running Django on Ubuntu 11.10 and installed Django using apt-get...
>
>
>
> Exception Value: 
>
> Caught TypeError while rendering: __init__() got an unexpected keyword 
> argument 'maxlength'
>
>  
There is no argument `maxlength`. There is a `max_length`, though.
--
DR. 

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



Caught TypeError while rendering: __init__() got an unexpected keyword argument 'maxlength'

2012-03-02 Thread vipul borikar
I tried to enable admin and i got this error...

I am running Django on Ubuntu 11.10 and installed Django using apt-get...



Request Method: GET  Request URL: http://localhost:8000/admin/  Django
Version: 1.3.1  Exception Type: TemplateSyntaxError  Exception Value:

Caught TypeError while rendering: __init__() got an unexpected keyword
argument 'maxlength'

 Exception Location:
/usr/local/lib/python2.7/dist-packages/Django-1.3.1-py2.7.egg/django/db/models/fields/__init__.py
in __init__, line 545  Python Executable: /usr/bin/python  Python Version:
2.7.2  Python Path:

['/home/vipul/Django/mysite',
 
'/usr/local/lib/python2.7/dist-packages/elementtree-1.2.7_20070827_preview-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/lxml-2.3.3-py2.7-linux-i686.egg',
 '/usr/local/lib/python2.7/dist-packages/Django-1.3.1-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/stockphoto-0.2.1-py2.7.egg',
 '/usr/lib/python2.7/dist-packages/PIL',
 '/usr/local/lib/python2.7/dist-packages/Satchmo-0.9.2-py2.7.egg',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/gst-0.10',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/pymodules/python2.7',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
 '/usr/lib/python2.7/dist-packages/ubuntuone-couch',
 '/usr/lib/python2.7/dist-packages/ubuntuone-installer',
 '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
 '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']

 Server time: Fri, 2 Mar 2012 03:39:05 -0600

-- 
Thanks

Vipul Borikar
"Our task must be to free ourselves...by widening our circle of compassion
to embrace all living creatures and the whole of nature and its beauty."

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



Traceback from csrf_exempt in 1.3.1

2012-03-02 Thread Ethan Whitt
I have never used csrf_exempt before.  I keep experiencing a traceback
with 1.3.1, which may be self-induced. Here is my views file:

auth/views.py
from django.http import HttpResponse
from django.utils import simplejson
from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def json_api(request):
return HttpResponse(simplejson.dumps(request),
mimetype="application/json")

When I do a curl:

curl -i -X POST -d '{"screencast":{"subject":"tools"}}' 
http://127.0.0.1:8000/auth/

I experience 500 Internal Server Error:

Traceback (most recent call last):

  File "/Library/Python/2.7/site-packages/django/core/servers/
basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)

  File "/Library/Python/2.7/site-packages/django/core/handlers/
wsgi.py", line 272, in __call__
response = self.get_response(request)

  File "/Library/Python/2.7/site-packages/django/core/handlers/
base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver,
sys.exc_info())

  File "/Library/Python/2.7/site-packages/django/core/handlers/
base.py", line 218, in handle_uncaught_exception
return callback(request, **param_dict)

  File "/Library/Python/2.7/site-packages/django/utils/decorators.py",
line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)

  File "/Library/Python/2.7/site-packages/django/views/defaults.py",
line 30, in server_error
t = loader.get_template(template_name) # You need to create a
500.html template.

  File "/Library/Python/2.7/site-packages/django/template/loader.py",
line 157, in get_template
template, origin = find_template(template_name)

  File "/Library/Python/2.7/site-packages/django/template/loader.py",
line 138, in find_template
raise TemplateDoesNotExist(name)

-- 
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 does the multiple database concept work after django 1.2

2012-03-02 Thread Amit Sethi
Hi all , My app has started breaking after moving to django 1.3 . I
don't really understand why?

I am working  using site framework and given model definition through
app_label. The only majot change as I can see is that I use UUID
Fields rather than AutoField. Now somehow i see that my app is trying
to make a connection to some other db essentially.

ConnectionDoesNotExist: The connection myapp doesn't exist

myapp here is one of applications in my site famework and the model
definations are given as


myapp/
 __init__.py
 Circle.py
 Sqaure.py

where Circle and Square are the different models ... Can someone tell
me how this came out ...

I checked again by moving the back to 1.1 and it works like a charm
... Interesting while I have given defination of one more database in
my settings ... I am not actually using it anywhere as yet...


Thanks
Amit




-- 
A-M-I-T S|S

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