Re: Avoiding code repetition in views

2012-06-29 Thread Timothy Makobu
@grimmus

I have a file called shared.py, and In it, i have created a
dict template_dict { } which has stuff that all the views share. I import
it into views.py and any app that will use that dict. I can then add more
items or alter existing ones via template_dict.update().


On Fri, Jun 29, 2012 at 9:01 AM, kenneth gonsalves
wrote:

> On Fri, 2012-06-29 at 01:07 +0200, Christophe Pettus wrote:
> > > I hope i have been clear
> >
> > I'm going to take a guess and surmise that you have a lot of different
> > view functions, each one of which needs to pass a list of gigs into
> > the context for the template and then render that page, and you're
> > trying to avoid repeating the code that builds the list of gigs.  Is
> > that correct?
> >
> > You might look at whether you really need all those separate view
> > functions, or if they can be rolled together.  You might also look at
> > using class-based Views in 1.4 as a way to factor out the
> > gig-list-building code in a reasonable way.
>
> or use templatetags
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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: how to manage range of hours in models and forms in django1.4

2012-06-29 Thread Jon Black
I understand that institue_hours_of_operation is a count of the
hours the user has worked, is that correct? If so, I suppose you
just need to count the hours with each form submition and add
that to the current institue_hours_of_operation value. You can do
that logic in a few places. In class-based views, I tend to put
it in form_valid().

Apologies if I've misunderstood :)

--
Jon Black
www.jonblack.org


On Fri, Jun 29, 2012, at 10:16, Nikhil Verma wrote:

Hi
I am developing an event app which has users who publish events ,
other users also.
Now users have their profile info for which i have made a very
common UserProfile Model with all the necessary details in it.
I have a requirement where in UserProfile model i need to display
a field institue_hours_of_operation( no. of hours that an
institute works)
class UserProfile(models.Model):
user = models.ForeignKey(User, blank=True, null=True,
unique=True)
first_name = models.CharField(max_length=30, blank=True)
last_name = models.CharField(max_length=30, blank=True)
gender = models.CharField(max_length=1,
choices=GENDER_CHOICES, blank=True)
birth_date = models.DateField(auto_now_add=True)
street_address = models.CharField(max_length=75, blank=True)
city = models.CharField(max_length=30, blank=True)
zip_code = models.IntegerField(max_length=7, blank=True,
null=True)
country = models.CharField(max_length=30, blank=True)
mobile = models.CharField(max_length=15, blank=True)
home_phone = models.CharField(max_length=15, blank=True)
primary_email = models.EmailField(max_length=60, blank=True)
secondary_email = models.EmailField(max_length=60,
blank=True)
institution_name =
models.CharField(max_length=100,blank=True,null=True)
institution_website =
models.CharField(max_length=100,blank=True,null=True)
# Field to be added
It will be displayed in html like this
Insitutue hour of operation :   Monday  9.00 - 17.00 (Monday
will be hardcoded,Time will be filled by user)
  Tuesday 9.00 -
17.00 (Monday will be hardcoded,Time will be filled by user)
   and so on
# Note the weekdays like monday,  tuesday they are all hardcoded
as requirement but i don't want that to be hardcoded.
Also i am using a django forms  to display this.
How can i design this form field as well in models or What should
be the type of this field both in models and forms such that
weekdays remain dynamic(i can simply generate them from loop) and
the user can fill the time  and when he hits submit it will get
saved.
Thanks in advance.

  --
  Regards
  Nikhil Verma
  +91-958-273-3156


  --
  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: how to manage range of hours in models and forms in django1.4

2012-06-29 Thread Nikhil Verma
Hi Jon

Yes it is the count of the hours.They will enter in the following manner "-

Monday : 0900-1800, Tuesday and so on ... This will be entered by the user
who is filling the form.

Now the text Moday(weekdays can be hardcoded but i personally don't want.)
Now if you see this is a simple CharField where the user enters details for
the number_of_hours.
So i want to know what type of model field should i create CharField or
Time Field.

If i   go for CharField it will simply save the details like 0900-1800. So
if i need to know how many hours that particular person is available for
work then how will subtract that from CharField.

So i need help to know what exactly the field i should create such that it
satisfies the template look and backened queries also.



On Fri, Jun 29, 2012 at 2:18 PM, Jon Black  wrote:

>  I understand that institue_hours_of_operation is a count of the hours the
> user has worked, is that correct? If so, I suppose you just need to count
> the hours with each form submition and add that to the current
> institue_hours_of_operation value. You can do that logic in a few places.
> In class-based views, I tend to put it in form_valid().
>
>  Apologies if I've misunderstood :)
>
>  --
>  Jon Black
>  www.jonblack.org
>
>
>  On Fri, Jun 29, 2012, at 10:16, Nikhil Verma wrote:
>
>
>  Hi
>
> I am developing an event app which has users who publish events , other
> users also.
> Now users have their profile info for which i have made a very common
> UserProfile Model with all the necessary details in it.
>
> I have a requirement where in UserProfile model i need to display a field
> institue_hours_of_operation( no. of hours that an institute works)
>
>
> class UserProfile(models.Model):
> user = models.ForeignKey(User, blank=True, null=True, unique=True)
> first_name = models.CharField(max_length=30, blank=True)
> last_name = models.CharField(max_length=30, blank=True)
> gender = models.CharField(max_length=1, choices=GENDER_CHOICES,
> blank=True)
> birth_date = models.DateField(auto_now_add=True)
> street_address = models.CharField(max_length=75, blank=True)
> city = models.CharField(max_length=30, blank=True)
> zip_code = models.IntegerField(max_length=7, blank=True, null=True)
> country = models.CharField(max_length=30, blank=True)
> mobile = models.CharField(max_length=15, blank=True)
> home_phone = models.CharField(max_length=15, blank=True)
> primary_email = models.EmailField(max_length=60, blank=True)
> secondary_email = models.EmailField(max_length=60, blank=True)
> institution_name =
> models.CharField(max_length=100,blank=True,null=True)
> institution_website =
> models.CharField(max_length=100,blank=True,null=True)
>
>
> # Field to be added
>
> It will be displayed in html like this
>
> Insitutue hour of operation :   Monday  9.00 - 17.00 (Monday will be
> hardcoded,Time will be filled by user)
>   Tuesday 9.00 - 17.00
> (Monday will be hardcoded,Time will be filled by user)
>
>and so on
>
> # Note the weekdays like monday,  tuesday they are all hardcoded as
> requirement but i don't want that to be hardcoded.
> Also i am using a django forms  to display this.
>
>
> How can i design this form field as well in models or What should be the
> type of this field both in models and forms such that weekdays remain
> dynamic(i can simply generate them from loop) and the user can fill the
> time  and when he hits submit it will get saved.
>
>
> Thanks in advance.
>
>
>
> --
> Regards
> Nikhil Verma
> +91-958-273-3156
>
>
> --
> 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.
>



-- 
Regards
Nikhil Verma
+91-958-273-3156

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



Re: how to manage range of hours in models and forms in django1.4

2012-06-29 Thread Jon Black
If the days have to be hardcoded (I imagine you have a row/field
for each day), then you could use a hardcoded string for the day
(not editable nor related to your model), and provide two Time
fields. Using Time gives you advantages:

* You can use python's DateTime module to calculate the hours
* You can more easily use a funky date/time style widget if you
ever need it
* You will avoid making mistakes trying to calculate the hours
manually
* You can validate the form data using python's date/time module

If you're really open to suggestions (just thinking outside the
box, and possible outside of the scope), but you could use a
separate table to record all hours recorded rather than just
counting the hours as they're entered.

--
Jon Black
www.jonblack.org


On Fri, Jun 29, 2012, at 14:31, Nikhil Verma wrote:

  Hi Jon
  Yes it is the count of the hours.They will enter in the
  following manner "-
  Monday : 0900-1800, Tuesday and so on ... This will be entered
  by the user who is filling the form.
  Now the text Moday(weekdays can be hardcoded but i personally
  don't want.)
  Now if you see this is a simple CharField where the user
  enters details for the number_of_hours.
  So i want to know what type of model field should i create
  CharField or Time Field.
  If i   go for CharField it will simply save the details like
  0900-1800. So if i need to know how many hours that particular
  person is available for work then how will subtract that from
  CharField.
  So i need help to know what exactly the field i should create
  such that it satisfies the template look and backened queries
  also.

On Fri, Jun 29, 2012 at 2:18 PM, Jon Black <[1]jon_bl...@mm.st>
wrote:

I understand that institue_hours_of_operation is a count of the
hours the user has worked, is that correct? If so, I suppose you
just need to count the hours with each form submition and add
that to the current institue_hours_of_operation value. You can do
that logic in a few places. In class-based views, I tend to put
it in form_valid().

Apologies if I've misunderstood :)

--
Jon Black
[2]www.jonblack.org


On Fri, Jun 29, 2012, at 10:16, Nikhil Verma wrote:

Hi
I am developing an event app which has users who publish events ,
other users also.
Now users have their profile info for which i have made a very
common UserProfile Model with all the necessary details in it.
I have a requirement where in UserProfile model i need to display
a field institue_hours_of_operation( no. of hours that an
institute works)
class UserProfile(models.Model):
user = models.ForeignKey(User, blank=True, null=True,
unique=True)
first_name = models.CharField(max_length=30, blank=True)
last_name = models.CharField(max_length=30, blank=True)
gender = models.CharField(max_length=1,
choices=GENDER_CHOICES, blank=True)
birth_date = models.DateField(auto_now_add=True)
street_address = models.CharField(max_length=75, blank=True)
city = models.CharField(max_length=30, blank=True)
zip_code = models.IntegerField(max_length=7, blank=True,
null=True)
country = models.CharField(max_length=30, blank=True)
mobile = models.CharField(max_length=15, blank=True)
home_phone = models.CharField(max_length=15, blank=True)
primary_email = models.EmailField(max_length=60, blank=True)
secondary_email = models.EmailField(max_length=60,
blank=True)
institution_name =
models.CharField(max_length=100,blank=True,null=True)
institution_website =
models.CharField(max_length=100,blank=True,null=True)
# Field to be added
It will be displayed in html like this
Insitutue hour of operation :   Monday  9.00 - 17.00 (Monday
will be hardcoded,Time will be filled by user)
  Tuesday 9.00 -
17.00 (Monday will be hardcoded,Time will be filled by user)
   and so on
# Note the weekdays like monday,  tuesday they are all hardcoded
as requirement but i don't want that to be hardcoded.
Also i am using a django forms  to display this.
How can i design this form field as well in models or What should
be the type of this field both in models and forms such that
weekdays remain dynamic(i can simply generate them from loop) and
the user can fill the time  and when he hits submit it will get
saved.
Thanks in advance.
--
Regards
Nikhil Verma
+91-958-273-3156


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  [3]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [4]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [5]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
  [6]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [7]django-users+u

Re: WebService WSDL

2012-06-29 Thread Tim Sawyer

I did it manually, not using the WSDL.

http://drumcoder.co.uk/blog/2009/nov/23/running-soap-webservice-without-library/

Tim.

On 28/06/12 20:51, Anurag Chourasia wrote:

Try using gSOAP if that fits your needs.

http://www.cs.fsu.edu/~engelen/soap.html

Regards,
Guddu

On Thu, Jun 28, 2012 at 2:47 PM, Rene mailto:r...@pubdesign.com.br>> wrote:

Pessoal,

Preciso montar um webservice que gere um wsdl, mas não achei algo
que fosse mais direto na web, alguém tem um caminho para indicar.

Abraço

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


--
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: Avoiding code repetition in views

2012-06-29 Thread Melvyn Sopacua
On 29-6-2012 5:45, Ryan Nowakowski wrote:
> Or a custom template context processor that adds gigs to every request
> context.

Or just use an iframe in your template that loads the gigs rendering view.
Iframe bad, yes, and all that, but the simplest solution in this case if
your layout can handle it.
A variation is to have them loaded by Ajax, with the drawback that
javascript-disabled browsers miss content. As I browse with noscript all
the time, this isn't a big problem. If I get to a page I'm interested
in, I will grant the domain the privileges in an instant.

Point being, refactoring code duplication isn't limited to the django layer.

-- 
Melvyn Sopacua


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



Re: how to manage range of hours in models and forms in django1.4

2012-06-29 Thread Melvyn Sopacua
On 29-6-2012 11:01, Nikhil Verma wrote:

> Yes it is the count of the hours.They will enter in the following manner "-
> 
> Monday : 0900-1800, Tuesday and so on ... This will be entered by the user
> who is filling the form.
> 
> Now the text Moday(weekdays can be hardcoded but i personally don't want.)

Untested, but I'd try this:
class DaysOfWeek(models.Model) :
name = models.CharField(max_length=32)

class BusinessHours(models.Model) :
day = models.ForeignKey(DaysOfWeek)
start = models.TimeField()
end = models.TimeField()

class Institute(models.Model) :
   # ...
   business_hours = models.ManyToManyField(BusinessHours)

Not sure if the Admin handles this ok though. An alternative:
class DaysOfWeek(models.Model) :
name = models.CharField(max_length=32)

def __iter__(self) :
return self

def next(self) :
for entry in DaysOfWeek.objects.all() :
 return (entry.id, entry.name)

class BusinessHours(models.Model) :
day = models.CharField(max_length=32, choices=DaysOfWeek)
start = models.TimeField()
end = models.TimeField()

-- 
Melvyn Sopacua


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



Re: how to manage range of hours in models and forms in django1.4

2012-06-29 Thread jonas

Nikhil Verma wrote:


How can i design this form field as well in models or What should be
the type of this field both in models and forms such that weekdays
remain dynamic(i can simply generate them from loop) and the user can
fill the time  and when he hits submit it will get saved.



I would create an extra Model which defines these opening times:

class OpeningTimes(models.Model):
day = models.CharField(max_length=10)
start = models.DateTimeField()
end = models.DateTimeField()

and define a manytomany relation ship from the UserProfile to your 
OpeningTimes model.


I've opted for the DateTimeField here, there's no Time Field in django 
by default. But you could just use any date (maybe use some kind of 
default date or use the current date)
and make sure the time has been filled in correctly. And then just 
extract the right hour from the DateTime field.


Regards,

Jonas;

--
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: have an object available in every templates

2012-06-29 Thread bruno desthuilliers


On Thursday, June 28, 2012 5:53:46 PM UTC+2, Bastian wrote:
>
> Well, I was curious to see if it worked with a context processor so I 
> tried and indeed it works. After all it's only returning an object or list 
> of objects in a dictionary. Now I don't know which method is the most 
> efficient.
>


The context_processor will be called for each and every RequestContext (so 
for each and every view AND templatetag creating a RequestContext), so 
better to avoid anything "intensive" here. 

Also, it won't have access to the existing context - which may or not be a 
problem, but for something "my favorite books" (which really means : "the 
favorité books of request.user"), you can bet one day or another you will 
want to show "the favorite books of _another_ user", and this is something 
that won't work with a context processor.

To make a long story short : use a custom template tag that will take the 
user as an argument. 

My 2 cents...

 

>
> On Thursday, June 28, 2012 2:11:37 PM UTC+2, Bastian wrote:
>>
>> Hi,
>>
>> I don't know if this is possible or how to do it. I would like to write a 
>> sort of context processor where I pass an object to the template. I have 
>> always passed strings to these variables. Let's say I have a Book model and 
>> in a view I list the latest books I've added to the database. In the 
>> corresponding template I will then have an objects list with these objects. 
>> But I also want to be able to call a variable containing another list of 
>> objects, say my favorite books, without having to pass it explicitly from 
>> the view and being able to call it from any template.
>> Can I do it with context processors, or anything else actually?
>>
>> Thanks.
>>
>

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



Re: how to manage range of hours in models and forms in django1.4

2012-06-29 Thread Sunny Nanda
One way to store such information can be like this:
Create a model "Day". This will hold entries for each day i.e. from Monday 
till Sunday
In the UserProfile model, create a ManyToMany relation to the above defined 
Day model through an intermediate table (say WorkingHours) which can hold 
the "from" and "to" time.

Partial example below:

class UserProfile(models.Model):
> working_hours = models.ManyToManyField("Day", through="WorkingHours")
>
> class WorkingHours(models.Model)
> profile = models.ForeignKey("UserProfile")
> day = models.ForeignKey("Day")
> from_time = models.**TimeField()
> to_time = models.**TimeField()
>

While creating the forms, take input from the user for the WorkingHours 
model. This way, the days of work will not be hardcoded, and user can 
select mutiple choices.

Regards,
Sandeep


On Friday, June 29, 2012 10:16:47 AM UTC+5:30, Nikhil Verma wrote:
>
>
> Hi
>
> I am developing an event app which has users who publish events , other 
> users also.
> Now users have their profile info for which i have made a very common 
> UserProfile Model with all the necessary details in it.
>
> I have a requirement where in UserProfile model i need to display a field 
> institue_hours_of_operation( no. of hours that an institute works)
>
>
> class UserProfile(models.Model):
> user = models.ForeignKey(User, blank=True, null=True, unique=True)
> first_name = models.CharField(max_length=30, blank=True)
> last_name = models.CharField(max_length=30, blank=True)
> gender = models.CharField(max_length=1, choices=GENDER_CHOICES, 
> blank=True)
> birth_date = models.DateField(auto_now_add=True)
> street_address = models.CharField(max_length=75, blank=True)
> city = models.CharField(max_length=30, blank=True)
> zip_code = models.IntegerField(max_length=7, blank=True, null=True)
> country = models.CharField(max_length=30, blank=True)
> mobile = models.CharField(max_length=15, blank=True)
> home_phone = models.CharField(max_length=15, blank=True)
> primary_email = models.EmailField(max_length=60, blank=True)
> secondary_email = models.EmailField(max_length=60, blank=True)
> institution_name = 
> models.CharField(max_length=100,blank=True,null=True)
> institution_website = 
> models.CharField(max_length=100,blank=True,null=True)
>
>
> # Field to be added
>
> It will be displayed in html like this
>
> Insitutue hour of operation :   Monday  9.00 - 17.00 (Monday will be 
> hardcoded,Time will be filled by user)
>   Tuesday 9.00 - 17.00 
> (Monday will be hardcoded,Time will be filled by user)
>
>and so on
>
> # Note the weekdays like monday,  tuesday they are all hardcoded as 
> requirement but i don't want that to be hardcoded. 
> Also i am using a django forms  to display this.
>
>
> How can i design this form field as well in models or What should be the 
> type of this field both in models and forms such that weekdays remain 
> dynamic(i can simply generate them from loop) and the user can fill the 
> time  and when he hits submit it will get saved.
>
>
> Thanks in advance.
>
>
>
> -- 
> Regards
> Nikhil Verma
> +91-958-273-3156
>
>

-- 
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/-/N2ArPbWtQmYJ.
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: settings and constants on a reusable app

2012-06-29 Thread Thomas Rega

Am 28.06.12 17:30, schrieb Marc Aymerich:

Hi,
I'm developing a reusable application and I'm having troubles with
constant values on settings.

Imagine that the reusable application comes with the following settings.py

# MY_APP/settings.py
from django.conf import settings
MY_CONSTANT = 'C1'
MY_OTHER_CONSTANT =  'C2'
MY_SETTING = getattr(settings, 'MY_SETTING', CONSTANT)


But for your project you want to override the default value of
MY_SETTING by MY_OTHER_CONSTANT. So you edit your project settings.py
and adds these two lines:

# Project settings.py

from MY_APP.settings import settings as my_app_settings
MY_SETTING = my_app_settings.MY_OTHER_SETTING


But this is going to fail because of the import order.

Is there any consistent way to handle this situation?

Thanks!

Hi,

what about the idea to overwrite these values via a 'local_settings.py' 
file?


An example can be found here: 
https://bitbucket.org/chris1610/satchmo/src/1255b19295c7/satchmo/projects/skeleton/settings.py


Good luck,
TR



--

Python Software Development - http://www.pyt3ch.com



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



How to run a django app in a subdirectory alias

2012-06-29 Thread Sven Grunewaldt
Hi,

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

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

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

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

Thanks,
Sven

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

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

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



Re: settings and constants on a reusable app

2012-06-29 Thread Marc Aymerich
On Fri, Jun 29, 2012 at 11:08 AM, Thomas Rega  wrote:
> Am 28.06.12 17:30, schrieb Marc Aymerich:
>
>> Hi,
>> I'm developing a reusable application and I'm having troubles with
>> constant values on settings.
>>
>> Imagine that the reusable application comes with the following settings.py
>>
>> # MY_APP/settings.py
>> from django.conf import settings
>> MY_CONSTANT = 'C1'
>> MY_OTHER_CONSTANT =  'C2'
>> MY_SETTING = getattr(settings, 'MY_SETTING', CONSTANT)
>>
>>
>> But for your project you want to override the default value of
>> MY_SETTING by MY_OTHER_CONSTANT. So you edit your project settings.py
>> and adds these two lines:
>>
>> # Project settings.py
>> 
>> from MY_APP.settings import settings as my_app_settings
>> MY_SETTING = my_app_settings.MY_OTHER_SETTING
>>
>>
>> But this is going to fail because of the import order.
>>
>> Is there any consistent way to handle this situation?
>>
>> Thanks!
>
> Hi,
>
> what about the idea to overwrite these values via a 'local_settings.py'
> file?
>
> An example can be found here:
> https://bitbucket.org/chris1610/satchmo/src/1255b19295c7/satchmo/projects/skeleton/settings.py

Hi thomas, thanks :)

Yeah, actually I'm using a local_settings.py file, but at the end it
will be the same as using settings.py since local_settings.py is
imported by settings.py. :(


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



Django CMS 2.3 Released!

2012-06-29 Thread Jonas Obrist
Today I am very excited that we just released Django CMS 2.3, with Django
1.4 support.

You can read the release notes at Django at http://bit.ly/django-cms-23.

Best regards,

Jonas 'ojii' Obrist

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



Re: how to manage range of hours in models and forms in django1.4

2012-06-29 Thread Nikhil Verma
Thanks for the help guys.

On Fri, Jun 29, 2012 at 11:37 AM, Sunny Nanda  wrote:

> One way to store such information can be like this:
> Create a model "Day". This will hold entries for each day i.e. from Monday
> till Sunday
> In the UserProfile model, create a ManyToMany relation to the above
> defined Day model through an intermediate table (say WorkingHours) which
> can hold the "from" and "to" time.
>
> Partial example below:
>
> class UserProfile(models.Model):
>> working_hours = models.ManyToManyField("Day", through="WorkingHours")
>>
>> class WorkingHours(models.Model)
>> profile = models.ForeignKey("UserProfile")
>> day = models.ForeignKey("Day")
>> from_time = models.**TimeField()
>> to_time = models.**TimeField()
>>
>
> While creating the forms, take input from the user for the WorkingHours
> model. This way, the days of work will not be hardcoded, and user can
> select mutiple choices.
>
> Regards,
> Sandeep
>
>
>
> On Friday, June 29, 2012 10:16:47 AM UTC+5:30, Nikhil Verma wrote:
>>
>>
>> Hi
>>
>> I am developing an event app which has users who publish events , other
>> users also.
>> Now users have their profile info for which i have made a very common
>> UserProfile Model with all the necessary details in it.
>>
>> I have a requirement where in UserProfile model i need to display a field
>> institue_hours_of_operation( no. of hours that an institute works)
>>
>>
>> class UserProfile(models.Model):
>> user = models.ForeignKey(User, blank=True, null=True, unique=True)
>> first_name = models.CharField(max_length=**30, blank=True)
>> last_name = models.CharField(max_length=**30, blank=True)
>> gender = models.CharField(max_length=1, choices=GENDER_CHOICES,
>> blank=True)
>> birth_date = models.DateField(auto_now_add=**True)
>> street_address = models.CharField(max_length=**75, blank=True)
>> city = models.CharField(max_length=**30, blank=True)
>> zip_code = models.IntegerField(max_**length=7, blank=True, null=True)
>> country = models.CharField(max_length=**30, blank=True)
>> mobile = models.CharField(max_length=**15, blank=True)
>> home_phone = models.CharField(max_length=**15, blank=True)
>> primary_email = models.EmailField(max_length=**60, blank=True)
>> secondary_email = models.EmailField(max_length=**60, blank=True)
>> institution_name = models.CharField(max_length=**
>> 100,blank=True,null=True)
>> institution_website = models.CharField(max_length=**
>> 100,blank=True,null=True)
>>
>>
>> # Field to be added
>>
>> It will be displayed in html like this
>>
>> Insitutue hour of operation :   Monday  9.00 - 17.00 (Monday will be
>> hardcoded,Time will be filled by user)
>>   **Tuesday 9.00 - 17.00
>> (Monday will be hardcoded,Time will be filled by user)
>>
>>   ** and so on
>>
>> # Note the weekdays like monday,  tuesday they are all hardcoded as
>> requirement but i don't want that to be hardcoded.
>> Also i am using a django forms  to display this.
>>
>>
>> How can i design this form field as well in models or What should be the
>> type of this field both in models and forms such that weekdays remain
>> dynamic(i can simply generate them from loop) and the user can fill the
>> time  and when he hits submit it will get saved.
>>
>>
>> Thanks in advance.
>>
>>
>>
>> --
>> Regards
>> Nikhil Verma
>> +91-958-273-3156
>>
>>  --
> 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/-/N2ArPbWtQmYJ.
>
> 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.
>



-- 
Regards
Nikhil Verma
+91-958-273-3156

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



Redirect question

2012-06-29 Thread ivanb
I'm still learning django so please forgive if I write anything silly.

On my site I'm having something like: on url mysite/list/ I have list of 
something. On it I have link that leads to another view if you want to add 
new element to it let's say: mysite/list/add_item/ 

On that url I have form with some information that needs to be written and 
a file upload in the form. On form submit it actually goes to new view 
mysite/list/adding/ and there the needed work is done.

After the work is done I want to go back to the first url and view 
 mentioned. Thing is I would also like it to show a message up there about 
status of what happened, so I can't use redirect, and if I put 
render_to_response it actually shows the proper view with the appropriate 
message but url is not the right one, it keeps the 
mysite/list/adding/ (that is logical behaviour and I understand it) but I 
want mysite/list/.

I'm asking for a way to achieve this, do some work and redirect to some 
previous view with some context added. Also I would like you to point out 
if I did something here that could have been done in better way so I can do 
it right and learn for the future.

Also, I know it could be done with setting some get parameters for the 
redirect but I would like to keep the url clean if possible.

If you know please advise.

Thanks

-- 
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/-/umS0hi9YrdgJ.
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: Redirect question

2012-06-29 Thread Daniel Roseman
On Friday, 29 June 2012 15:45:16 UTC+1, ivanb wrote:
>
> I'm still learning django so please forgive if I write anything silly.
>
> On my site I'm having something like: on url mysite/list/ I have list of 
> something. On it I have link that leads to another view if you want to add 
> new element to it let's say: mysite/list/add_item/ 
>
> On that url I have form with some information that needs to be written and 
> a file upload in the form. On form submit it actually goes to new view 
> mysite/list/adding/ and there the needed work is done.
>
> After the work is done I want to go back to the first url and view 
>  mentioned. Thing is I would also like it to show a message up there about 
> status of what happened, so I can't use redirect, and if I put 
> render_to_response it actually shows the proper view with the appropriate 
> message but url is not the right one, it keeps the 
> mysite/list/adding/ (that is logical behaviour and I understand it) but I 
> want mysite/list/.
>
> I'm asking for a way to achieve this, do some work and redirect to some 
> previous view with some context added. Also I would like you to point out 
> if I did something here that could have been done in better way so I can do 
> it right and learn for the future.
>
> Also, I know it could be done with setting some get parameters for the 
> redirect but I would like to keep the url clean if possible.
>
> If you know please advise.
>
> Thanks
>

Use the messages framework to add a message to the user when you process, 
and display it on the page you redirect to.
https://docs.djangoproject.com/en/1.4/ref/contrib/messages/
--
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/-/Xxcva4kZ7twJ.
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: Redirect question

2012-06-29 Thread Kurtis Mullins
>
> [...]

Also I would like you to point out if I did something here that could have
> been done in better way so I can do it right and learn for the future.


If you're using Class Based Views, you can use a mixin to achieve this.
Here's mine if you want to check it out:
http://stackoverflow.com/questions/5531258/example-of-django-class-based-deleteview/10903943#10903943(Scroll
Down to the Bottom)

This may be a bit advanced for you at the moment but it works really well
for me. You can ignore most all of the other code in that posting and just
focus on the MessageMixin. Also, see the documentation link posted by
Daniel Roseman. The messaging framework is the way to go for passing on a
"Success" or some type of a notification message.

-- 
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: have an object available in every templates

2012-06-29 Thread Bastian
Good point, thanks for your input.

On Friday, June 29, 2012 12:51:09 PM UTC+2, bruno desthuilliers wrote:
>
>
>
> On Thursday, June 28, 2012 5:53:46 PM UTC+2, Bastian wrote:
>>
>> Well, I was curious to see if it worked with a context processor so I 
>> tried and indeed it works. After all it's only returning an object or list 
>> of objects in a dictionary. Now I don't know which method is the most 
>> efficient.
>>
>
>
> The context_processor will be called for each and every RequestContext (so 
> for each and every view AND templatetag creating a RequestContext), so 
> better to avoid anything "intensive" here. 
>
> Also, it won't have access to the existing context - which may or not be a 
> problem, but for something "my favorite books" (which really means : "the 
> favorité books of request.user"), you can bet one day or another you will 
> want to show "the favorite books of _another_ user", and this is something 
> that won't work with a context processor.
>
> To make a long story short : use a custom template tag that will take the 
> user as an argument. 
>
> My 2 cents...
>
>  
>
>>
>> On Thursday, June 28, 2012 2:11:37 PM UTC+2, Bastian wrote:
>>>
>>> Hi,
>>>
>>> I don't know if this is possible or how to do it. I would like to write 
>>> a sort of context processor where I pass an object to the template. I have 
>>> always passed strings to these variables. Let's say I have a Book model and 
>>> in a view I list the latest books I've added to the database. In the 
>>> corresponding template I will then have an objects list with these objects. 
>>> But I also want to be able to call a variable containing another list of 
>>> objects, say my favorite books, without having to pass it explicitly from 
>>> the view and being able to call it from any template.
>>> Can I do it with context processors, or anything else actually?
>>>
>>> Thanks.
>>>
>>

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



am new to use forms in django..

2012-06-29 Thread rick
i dont knw where to make a form...right now i am making form in model.py 
,with the name Student_loginForm class..and when i make a template to 
run on servererror comes is

TypeError at /record_system/studentid 

'DeclarativeFieldsMetaclass' object is not iterable

thanks in advance.


-- 
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/-/D5nY9Bbda1kJ.
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: Affordable Django hosting solution in India/around?

2012-06-29 Thread Bjarni Rúnar Einarsson
On Tue, Jun 26, 2012 at 4:56 AM, Kartik Singhal  wrote:
>
> If nothing else works out our last option will be to host in college
> servers, but that involves additional headache being unreliable.

Out of curiosity, what is it that makes your college servers
unreliable?  Poor networks or power fluctuations...?

Until I saw this comment I was going to suggest you just host it
yourself on a static IP somewhere (or using PageKite to tunnel out if
you are stuck behind NAT), as it seems you should have very modest
bandwidth requirements.

-- 
Bjarni R. Einarsson
Founder, lead developer of PageKite.

Make localhost servers visible to the world: https://pagekite.net/

-- 
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: am new to use forms in django..

2012-06-29 Thread manish girdhar
On Sat, Jun 30, 2012 at 12:09 AM, rick  wrote:

> i dont knw where to make a form...right now i am making form in model.py
> ,with the name Student_loginForm class..and when i make a template to
> run on servererror comes is
>
> TypeError at /record_system/studentid
>
> 'DeclarativeFieldsMetaclass' object is not iterable
>
>



> is their any meta class made for forms?
>
>

> thanks in advance.
>
>
>  --
> 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/-/D5nY9Bbda1kJ.
> 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.



javascript in django template not executed when request is sent via ajax

2012-06-29 Thread Larry Martell
I have a django template that has some javascript/jQuery code in it
that defines some keyup event handers. If a user goes to the URL
directly the javascript is executed, and the event handers all work
fine. There is also a field that they can type in that triggers the
same URL request to be sent via ajax. When they do this, it seems that
the html is rendered, but the javascript is not executed. I discovered
this by noticing that the page was rendered, but none of the
javascript event handers were being called. I proved this by adding:



alert('here we are');


to the template, and the alert doesn't show when the request comes
from ajax. But if I go to the URL directly it does.

Is this a known issue? Is there some way I can get my javascript code
to run to install my event handlers when the request comes from ajax?

TIA!
-larry

-- 
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 CMS 2.3 Released!

2012-06-29 Thread Kurdy
Installed 2.3rc2 this afternoon. Happily surprised by new release.

Upgraded to django1.4 and cms2.3.
I'm only still struggling with django-filer. What would be the advise?
Is a new version of filer expected soon? 
Or is the development-version enough for production?

Thanks for all the nice work.

-- 
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/-/fwOTKjRFvzMJ.
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: Render time

2012-06-29 Thread Larry Martell
On Mon, Jun 25, 2012 at 9:04 PM, Andy McKay  wrote:
>> Now they want me to add to that how long
>> the browser takes to render the page after it gets the data.
>
> You can use the navigation timing API:
>
> https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
>
> We use this in conjuction with graphite and django-statsd to produce
> graphs of hour long our sites takes to render.
>
> http://blog.mozilla.org/webdev/2012/01/06/timing-amo-user-experience/
>
> And some more links:
>
> https://github.com/andymckay/django-statsd
> http://django-statsd.readthedocs.org/en/latest/#front-end-timing-integration
> http://graphite.wikidot.com/

Thanks Andy. Super cool, and pretty much just what I was looking for.
Seems to work fine in FF and Chrome, but in Safari I don't seem to
have access to the performance.timing data. Should that be there or do
I have do something to load or enable it?

-larry

-- 
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: Render time

2012-06-29 Thread John
Look at Boomerang:

http://lognormal.github.com/boomerang/doc/

John

On 25/06/12 12:34, Larry Martell wrote:
> This is not strictly a django question, but I'm hoping someone here
> has solved this and can help me. I have a client that has a django app
> that collects a bunch of server side statistics on the users
> activities - e.g. what reports they run, the number of rows returned,
> how long the query took, etc. Now they want me to add to that how long
> the browser takes to render the page after it gets the data. So I have
> 3 issues here:
>
> 1) How  can I even calculate that?
> 2) How I can return it back to the server?
> 3) Since the database table is updated with the other statistics
> before the data is sent to the browser, assuming I could calculate the
> render time and send it back, how could I find the row and update with
> that info?
>
> If anyone has already done something like this, or anyone has any
> advise on how I could do it (especially item #1), I'd really
> appreciate them sharing it with me.
>
> TIA!
> -larry
>


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



Re: javascript in django template not executed when request is sent via ajax

2012-06-29 Thread Jani Tiainen
It's known limitation of your ajax request and has nothing to do with
Django nor templates. Or well it might do.

Most of the javascript frameworks can extract script and inject it
correctly to current DOM. Since you mention jquery I guess that you're
using that for ajax queries so make sure that your $.ajax() has dataType
attribute to set as 'html'. It should (according to docs) parse script
parts correctly.

On Fri, Jun 29, 2012 at 11:45 PM, Larry Martell wrote:

> I have a django template that has some javascript/jQuery code in it
> that defines some keyup event handers. If a user goes to the URL
> directly the javascript is executed, and the event handers all work
> fine. There is also a field that they can type in that triggers the
> same URL request to be sent via ajax. When they do this, it seems that
> the html is rendered, but the javascript is not executed. I discovered
> this by noticing that the page was rendered, but none of the
> javascript event handers were being called. I proved this by adding:
>
>
>
>alert('here we are');
>
>
> to the template, and the alert doesn't show when the request comes
> from ajax. But if I go to the URL directly it does.
>
> Is this a known issue? Is there some way I can get my javascript code
> to run to install my event handlers when the request comes from ajax?
>
> TIA!
> -larry
>
> --
> 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.
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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



Re: javascript in django template not executed when request is sent via ajax

2012-06-29 Thread Jani Tiainen
I meant that if for some reason Django sends incorrect content type from a
view or something like that your javascript framework might guess
incorrectly your ajax request content type and not parse script tags.

On Sat, Jun 30, 2012 at 1:51 AM, Jani Tiainen  wrote:

> It's known limitation of your ajax request and has nothing to do with
> Django nor templates. Or well it might do.
>
> Most of the javascript frameworks can extract script and inject it
> correctly to current DOM. Since you mention jquery I guess that you're
> using that for ajax queries so make sure that your $.ajax() has dataType
> attribute to set as 'html'. It should (according to docs) parse script
> parts correctly.
>
>
> On Fri, Jun 29, 2012 at 11:45 PM, Larry Martell 
> wrote:
>
>> I have a django template that has some javascript/jQuery code in it
>> that defines some keyup event handers. If a user goes to the URL
>> directly the javascript is executed, and the event handers all work
>> fine. There is also a field that they can type in that triggers the
>> same URL request to be sent via ajax. When they do this, it seems that
>> the html is rendered, but the javascript is not executed. I discovered
>> this by noticing that the page was rendered, but none of the
>> javascript event handers were being called. I proved this by adding:
>>
>>
>>
>>alert('here we are');
>>
>>
>> to the template, and the alert doesn't show when the request comes
>> from ajax. But if I go to the URL directly it does.
>>
>> Is this a known issue? Is there some way I can get my javascript code
>> to run to install my event handlers when the request comes from ajax?
>>
>> TIA!
>> -larry
>>
>> --
>> 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.
>>
>>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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



Re: javascript in django template not executed when request is sent via ajax

2012-06-29 Thread Larry Martell
On Fri, Jun 29, 2012 at 4:51 PM, Jani Tiainen  wrote:
> It's known limitation of your ajax request and has nothing to do with Django
> nor templates. Or well it might do.

Not really sure what you mean here. Are you saying this is a known
problem, and I should not expect it to work?

> Most of the javascript frameworks can extract script and inject it correctly
> to current DOM. Since you mention jquery I guess that you're using that for
> ajax queries so make sure that your $.ajax() has dataType attribute to set
> as 'html'. It should (according to docs) parse script parts correctly.

Yes, it does. The request is sent like this:

$.ajax({
url: url,
data: $form.serialize(),
dataType: 'html',
success: function (html, textStatus) {
$report
.html($('#report', html).html())
.css({
opacity: 1.0
});
style_preview_table();
}

And I have verified that all the non javascript portions of the
template are executed, but none of the javascript ones are.



>
> On Fri, Jun 29, 2012 at 11:45 PM, Larry Martell 
> wrote:
>>
>> I have a django template that has some javascript/jQuery code in it
>> that defines some keyup event handers. If a user goes to the URL
>> directly the javascript is executed, and the event handers all work
>> fine. There is also a field that they can type in that triggers the
>> same URL request to be sent via ajax. When they do this, it seems that
>> the html is rendered, but the javascript is not executed. I discovered
>> this by noticing that the page was rendered, but none of the
>> javascript event handers were being called. I proved this by adding:
>>
>>
>>    
>>    alert('here we are');
>>    
>>
>> to the template, and the alert doesn't show when the request comes
>> from ajax. But if I go to the URL directly it does.
>>
>> Is this a known issue? Is there some way I can get my javascript code
>> to run to install my event handlers when the request comes from ajax?
>>
>> TIA!
>> -larry
>>
>> --
>> 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.
>>
>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>
> --
> 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: javascript in django template not executed when request is sent via ajax

2012-06-29 Thread Larry Martell
On Fri, Jun 29, 2012 at 4:54 PM, Jani Tiainen  wrote:
> I meant that if for some reason Django sends incorrect content type from a
> view or something like that your javascript framework might guess
> incorrectly your ajax request content type and not parse script tags.

Is there a way I can test to see if this is occurring?


>
>
> On Sat, Jun 30, 2012 at 1:51 AM, Jani Tiainen  wrote:
>>
>> It's known limitation of your ajax request and has nothing to do with
>> Django nor templates. Or well it might do.
>>
>> Most of the javascript frameworks can extract script and inject it
>> correctly to current DOM. Since you mention jquery I guess that you're using
>> that for ajax queries so make sure that your $.ajax() has dataType attribute
>> to set as 'html'. It should (according to docs) parse script parts
>> correctly.
>>
>>
>> On Fri, Jun 29, 2012 at 11:45 PM, Larry Martell 
>> wrote:
>>>
>>> I have a django template that has some javascript/jQuery code in it
>>> that defines some keyup event handers. If a user goes to the URL
>>> directly the javascript is executed, and the event handers all work
>>> fine. There is also a field that they can type in that triggers the
>>> same URL request to be sent via ajax. When they do this, it seems that
>>> the html is rendered, but the javascript is not executed. I discovered
>>> this by noticing that the page was rendered, but none of the
>>> javascript event handers were being called. I proved this by adding:
>>>
>>>
>>>    
>>>    alert('here we are');
>>>    
>>>
>>> to the template, and the alert doesn't show when the request comes
>>> from ajax. But if I go to the URL directly it does.
>>>
>>> Is this a known issue? Is there some way I can get my javascript code
>>> to run to install my event handlers when the request comes from ajax?
>>>
>>> TIA!
>>> -larry
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> Jani Tiainen
>>
>> - Well planned is half done, and a half done has been sufficient before...
>>
>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>
> --
> 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.



advantages and disadvantages of Raw sql queries in django

2012-06-29 Thread vijay shanker
hi
i want to know pros and cons associated with running raw sql queries
over django's ORM .
googled it out but couldn find many useful links.

-- 
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: advantages and disadvantages of Raw sql queries in django

2012-06-29 Thread Mike Dewhirst
I firmly believe in using the ORM for everything until i am forced to use  
handwritten SQL.


The main reason is transparency of intentions when the source is examined by  
a non-DBA. 

I want my code to be maintainable by other people and provably correct. I  
suppose you can unit-test code with embedded SQL but it adds an extra layer  
of complexity.


I could also argue against custom SQL because it contains business logic and  
i prefer to keep that all in one place, ie., in models in python code.


So the bottom line for me is to avoid it where possible.  Once everything is  
profiled and the last remaining bottlenecks are significant and cannot be  
removed unless I use custom SQL, that's when I'll do it.


Haven't gotten there yet.

-Original message-
From: vijay shanker 
To: Django users 
Sent: Sat, 30 Jun 2012, 14:35:54 AEST
Subject: advantages and disadvantages of Raw sql queries in django

hi
i want to know pros and cons associated with running raw sql queries
over django's ORM .
googled it out but couldn find many useful links.

--
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: 'CSRF verification failed." from django.contrib.comments. can you help solve it? django 1.3

2012-06-29 Thread brycenesbitt


The "security_hash" field that you see is part of the comments app, and is 
> not the CSRF token. That needs to be output by a {% csrf_token %} tag (or 
> its equivalent). If it's working, you should see another hidden input 
> field, which looks like this:
>
> 
>  value="36d43c1652d5676d6d411950e077eeaa1cc1f799"/>
> 
>
> The comments app normally does that automatically -- it's part of 
> django/contrib/comments/templates/form.html -- Are you overriding the 
> comment form in your own app? If so, you need to include the call to {% 
> csrf_token %} yourself.
>

I am not overriding, at least not deliberately.

django/contrib/comments/templates/form.html has:
{% load comments i18n %}
{% csrf_token %}

I render my form with:
{% render_comment_form for entry %}

---
I should note it did work when I first added it to the application.  It 
broke after I added pybbm.  I've since removed pybbm (it is maintained and 
broken), but comments
started getting csrf errors.

-- 
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/-/pykynQInFVUJ.
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: 'CSRF verification failed." from django.contrib.comments. can you help solve it? django 1.3

2012-06-29 Thread brycenesbitt
On Thursday, June 28, 2012 10:43:58 AM UTC-7, jonas wrote:
>
> After the starting form tag add {% csrf_token %} 
>

I can't.
It is rendered for me by {% render_comment_form for entry %}

-- 
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/-/P_1zIG9fUC4J.
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: advantages and disadvantages of Raw sql queries in django

2012-06-29 Thread Jon Black
Also, using ORM means you're less likely to be tied to a specific
database...or in other words, your hand-crafted SQL is likely to be
specific to certain databases.

On 06/30/2012 08:33 AM, Mike Dewhirst wrote:
> I firmly believe in using the ORM for everything until i am forced to
> use handwritten SQL.
> 
> The main reason is transparency of intentions when the source is
> examined by a non-DBA.
> 
> I want my code to be maintainable by other people and provably correct.
> I suppose you can unit-test code with embedded SQL but it adds an extra
> layer of complexity.
> 
> I could also argue against custom SQL because it contains business logic
> and i prefer to keep that all in one place, ie., in models in python code.
> 
> So the bottom line for me is to avoid it where possible.  Once
> everything is profiled and the last remaining bottlenecks are
> significant and cannot be removed unless I use custom SQL, that's when
> I'll do it.
> 
> Haven't gotten there yet.
> 
> -Original message-
> 
> *From: *vijay shanker *
> To: *Django users *
> Sent: *Sat, 30 Jun 2012, 14:35:54 AEST*
> Subject: *advantages and disadvantages of Raw sql queries in django
> 
> hi
> i want to know pros and cons associated with running raw sql queries
> over django's ORM .
> googled it out but couldn find many useful links.
> 
> -- 
> 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.




signature.asc
Description: OpenPGP digital signature