Re: Tests not loading initial_data fixtures

2013-10-03 Thread Sam Lai
Ah, turns out all you have to do is specify -

fixtures = [ 'initial_data' ]

... in the TestCase and it'll load all the initial_data fixtures from
all apps. Still a bit odd that loading initial_data fixtures isn't the
default in tests though.

On 3 October 2013 16:49, Sam Lai  wrote:
> I'm trying to test a Django management command in app X that parses
> data files and inserts data into models that are located in apps Y and
> Z. Apps Y and Z have initial_data.json files in them. On running my
> test however, it seems that my initial_data fixtures are not being
> loaded.
>
> I could specify the initial_data fixtures manually (presumably I can
> do ../) using the 'fixtures' variable in my TestCase, but that isn't
> very DRY and becomes tedious when more apps are introduced with their
> own initial_data.
>
> I tracked this down to a change that Russell made 3 years ago
> (https://github.com/django/django/commit/b31a1b99261d05bf8a34495ee9faf4d6592b8b36).
> The commit message and content explains why *custom SQL* fixtures
> aren't loaded automatically during testing, but says nothing about why
> xml/yaml/json fixtures are no longer loaded either.
>
> All django-users threads that I can find on this refer to the
> situation prior to this change, and state that initial_data fixtures
> *were* loaded.
>
> What's the reason for the change? I thought initial_data is designed
> for data that should always be in the database, so this is a bit odd.
> Can't really find anything in the docs that mentions this either.
>
> Thanks,
>
> Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABxbXqVVkeMaXvnYco%2Bd8kbRFz9LJfpaR8c9kx085kHTtP4a9g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


uptodate Account_balance

2013-10-03 Thread MAurice
Hello everyone was requesting for help on this micro-finance software am 
developing, needed to make the account balance reflect updated  
amount/value on the database when deposits/withdraws are made on either the 
account or loan repayment 

*class Branch(models.Model):*
time_stamp =models.DateTimeField(default=datetime.datetime.now(), 
editable=False)
name =models.CharField(max_length=200) 
physical_location=models.CharField(max_length=200)
email=models.EmailField()

*class Account(models.Model):*
account_type=models.CharField(max_length=200, choices=ACCTYPE)
branch=models.ForeignKey('Branch')
first_name=models.CharField(max_length=200)
last_name   =models.CharField(max_length=200)
account_number =models.SlugField(unique=True)   
account_current_balance =models.FloatField(max_length=255,default=0)
*
class Account_holder(models.Model):*
id =models.IntegerField(primary_key=True,default=1)
account_id =models.ManyToManyField(Account)


*

class Loan(models.Model):*
id = models.AutoField(primary_key=True,default=1)
branch_cod=models.IntegerField(blank=True, null=True)
time_years=models.DecimalField(default=1.0, max_digits=10, 
decimal_places=4)
loan_number =models.SlugField(unique=True)
account_name=models.ForeignKey(Account)
loan_amount=models.DecimalField(default=0.0, max_digits=10, 
decimal_places=2)
interest_rate=models.DecimalField(default=0.0, max_digits=10, 
decimal_places=2)
interest_charged = models.DecimalField(default=0.0, max_digits=10, 
decimal_places=2, editable=False)
required_payement = models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2)
*
class statement(models.Model):*
account_id =models.ForeignKey(Account)
 date = models.DateTimeField(default=datetime.datetime.now(), 
editable=False)
 deposit = models.PositiveIntegerField(null=True, default=0)
 withdraw = models.PositiveIntegerField(null=True, default=0)
 description =models.TextField(max_length=200)
 current_balance = models.FloatField(max_length=200, editable=False)

def save(self, *args, **kwargs):
 self.current_balance =  self.account_id.average_balance + 
self.credit - self.debit
 self.average_balance = self.account_id.average_balance + 
self.credit - self.debit -self.minimum_balance
 super(statement,self).save(*args, **kwargs)
*
 class Savant_user(models.Model):*
  user =models.OneToOneField(User) 
  branch =models.ManyToManyField('Branch')
 
  

  def create_Dashboard_user_callback(sender, instance, **kwargs):
  Dashboard, new = Savant_user.objects.get_or_create(user=instance)
  post_save.connect(create_Dashboard_user_callback, User)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/585a5845-9111-492d-a0c9-10342ee2bfbc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: uptodate Account_balance

2013-10-03 Thread Leonardo Giordani
Maurice,

please remember not everyone on this ML knows finance and noone knows your
application but you.
Moreover, people on ML cannot spend hours trying to figure out what is your
problem: sometimes just solving the problem needs a lot of work, so make
things easy.

You posted your models, but I think you are implementing some views or at
least using them in some code.
Can you give some details about the procedure you are implementing and the
exact issue tou are facing?

Cheers,

Leo

Leonardo Giordani
Author of The Digital Cat 
My profile on About.me  - My GitHub
page- My Coderwall
profile 


2013/10/3 MAurice 

> Hello everyone was requesting for help on this micro-finance software am
> developing, needed to make the account balance reflect updated
> amount/value on the database when deposits/withdraws are made on either the
> account or loan repayment
>
> *class Branch(models.Model):*
> time_stamp =models.DateTimeField(default=datetime.datetime.now(),
> editable=False)
> name =models.CharField(max_length=200)
> physical_location=models.CharField(max_length=200)
> email=models.EmailField()
>
> *class Account(models.Model):*
> account_type=models.CharField(max_length=200, choices=ACCTYPE)
> branch=models.ForeignKey('Branch')
> first_name=models.CharField(max_length=200)
> last_name   =models.CharField(max_length=200)
> account_number =models.SlugField(unique=True)
> account_current_balance =models.FloatField(max_length=255,default=0)
> *
> class Account_holder(models.Model):*
> id =models.IntegerField(primary_key=True,default=1)
> account_id =models.ManyToManyField(Account)
>
>
> *
>
> class Loan(models.Model):*
> id = models.AutoField(primary_key=True,default=1)
> branch_cod=models.IntegerField(blank=True, null=True)
> time_years=models.DecimalField(default=1.0, max_digits=10,
> decimal_places=4)
> loan_number =models.SlugField(unique=True)
> account_name=models.ForeignKey(Account)
> loan_amount=models.DecimalField(default=0.0, max_digits=10,
> decimal_places=2)
> interest_rate=models.DecimalField(default=0.0, max_digits=10,
> decimal_places=2)
> interest_charged = models.DecimalField(default=0.0, max_digits=10,
> decimal_places=2, editable=False)
> required_payement = models.DecimalField(default=1.0, max_digits=10,
> decimal_places=2)
> *
> class statement(models.Model):*
> account_id =models.ForeignKey(Account)
>  date = models.DateTimeField(default=datetime.datetime.now(),
> editable=False)
>  deposit = models.PositiveIntegerField(null=True, default=0)
>  withdraw = models.PositiveIntegerField(null=True, default=0)
>  description =models.TextField(max_length=200)
>  current_balance = models.FloatField(max_length=200, editable=False)
>
> def save(self, *args, **kwargs):
>  self.current_balance =  self.account_id.average_balance +
> self.credit - self.debit
>  self.average_balance = self.account_id.average_balance +
> self.credit - self.debit -self.minimum_balance
>  super(statement,self).save(*args, **kwargs)
> *
>  class Savant_user(models.Model):*
>   user =models.OneToOneField(User)
>   branch =models.ManyToManyField('Branch')
>
>
>
>   def create_Dashboard_user_callback(sender, instance, **kwargs):
>   Dashboard, new = Savant_user.objects.get_or_create(user=instance)
>   post_save.connect(create_Dashboard_user_callback, User)
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/585a5845-9111-492d-a0c9-10342ee2bfbc%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEhE%2BOnGAFK4v-WUPbmLzzK-Ju8EqKpAtLc6SbffScwKV0DCVA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


gyguptodate Account_balance

2013-10-03 Thread MAurice
Hello everyone was requesting for help on this micro-finance software am 
developing, needed to make the account balance reflect updated  
amount/value on the database when deposits/withdraws are made on either the 
account or loan repayment 

*class Branch(models.Model):*
time_stamp =models.DateTimeField(default=datetime.datetime.now(), 
editable=False)
name =models.CharField(max_length=200) 
physical_location=models.CharField(max_length=200)
email=models.EmailField()

*class Account(models.Model):*
account_type=models.CharField(max_length=200, choices=ACCTYPE)
branch=models.ForeignKey('Branch')
first_name=models.CharField(max_length=200)
last_name   =models.CharField(max_length=200)
account_number =models.SlugField(unique=True)   
account_current_balance =models.FloatField(max_length=255,default=0)
*
class Account_holder(models.Model):*
id =models.IntegerField(primary_key=True,default=1)
account_id =models.ManyToManyField(Account)


*

class Loan(models.Model):*
id = models.AutoField(primary_key=True,default=1)
branch_cod=models.IntegerField(blank=True, null=True)
time_years=models.DecimalField(default=1.0, max_digits=10, 
decimal_places=4)
loan_number =models.SlugField(unique=True)
account_name=models.ForeignKey(Account)
loan_amount=models.DecimalField(default=0.0, max_digits=10, 
decimal_places=2)
interest_rate=models.DecimalField(default=0.0, max_digits=10, 
decimal_places=2)
interest_charged = models.DecimalField(default=0.0, max_digits=10, 
decimal_places=2, editable=False)
required_payement = models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2)
*
class statement(models.Model):*
account_id =models.ForeignKey(Account)
 date = models.DateTimeField(default=datetime.datetime.now(), 
editable=False)
 deposit = models.PositiveIntegerField(null=True, default=0)
 withdraw = models.PositiveIntegerField(null=True, default=0)
 description =models.TextField(max_length=200)
 current_balance = models.FloatField(max_length=200, editable=False)

def save(self, *args, **kwargs):
 self.current_balance =  self.account_id.average_balance + 
self.credit - self.debit
 self.average_balance = self.account_id.average_balance + 
self.credit - self.debit -self.minimum_balance
 super(statement,self).save(*args, **kwargs)
*
 class Savant_user(models.Model):*
  user =models.OneToOneField(User) 
  branch =models.ManyToManyField('Branch')
 
  

  def create_Dashboard_user_callback(sender, instance, **kwargs):
  Dashboard, new = Savant_user.objects.get_or_create(user=instance)
  post_save.connect(create_Dashboard_user_callback, User)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bc56f702-6038-4855-8e90-809ecc67c7d5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best practice for server-generated downloads?

2013-10-03 Thread DJ-Tom

The report can't be reporduced later on - as the data is constantly 
changing, so I need to store the result. 

Storing the data on which the report is based is very complex and would be 
too expensive regarding storage space just for this purpose.

But I also have now found how to use StringIO and xlsxWriter here:

http://stackoverflow.com/questions/16393242/xlsxwriter-object-save-as-http-response-to-create-download-in-django

So most likely I will do it like in this sample, plus saving the report for 
later retrieval and always serving through httpresponse, so I don't need to 
expose the actual storage location via the web server.

Am Mittwoch, 2. Oktober 2013 09:36:10 UTC+2 schrieb Russell Keith-Magee:
>
>
> Well, if you need archival, there are two alternatives:
>
> 1. Write the file to disk at the same time it is being generated. There's 
> no reason you have to serve the file from where it was generated -- 
> generate it, write it, and serve it.
>
> 2. Make sure the report will always be generated the same way. An analog 
> here -- if you request a page from a web server, it probably isn't saved on 
> disk like that (unless it's a genuinely static page) -- the server knows 
> how to reproduce the same page every time you request a specific URL. Make 
> the reports the same -- if you request /report/September-2013, you generate 
> the same report every time. 
>
> The second approach depends on whether you have well time-bucketed data, 
> but it's certainly possible to do.
>
>>
>> I don't see how I could use the xlsxwriter object in the way it is 
>> described here https://docs.djangoproject.**com/en/1.5/howto/outputting-*
>> *pdf/  - 
>> how could I pass the httpresponse object to xlsxWriter?
>> (Maybe I have not yet found how this might work - but it is not what I 
>> need anyways...)
>>
>
> I haven't used xlsxwriter myself, but the key part of the PDF example is 
> that StringIO is an object that adheres to the python File API, but doesn't 
> actually involve a file. So, you open a StringIO object, "write" to it, 
> then dump the contents as the HTTP response. 
>
> So - whatever API endpoint on xlsxwriter lets you pass in a file object -- 
> pass in a StringIO instance instead.
>
> Yours,
> Russ Magee %-)
>
>
>
> Thomas
>>
>> Am Mittwoch, 2. Oktober 2013 02:11:21 UTC+2 schrieb Russell Keith-Magee:
>>
>>>
>>> On Tue, Oct 1, 2013 at 9:49 PM, DJ-Tom  wrote:
>>>
 Hi,

 I need to create database report downloads in Excel format (via 
 xlsxwriter) and I'm wondering if there is any standard or best practice as 
 to where those downloads should be located.

 Especially helpful would be if there was a portable way of managing the 
 file system location and web request url in a way so that I don't have to 
 change settings between the development and production server.

 Is this -> 
 https://docs.djangoproject.**com/en/1.5/topics/files/the
  way to go?

 If they're sever generated, why do they need to hit the file system at 
>>> all? 
>>>
>>> The following example in the docs:
>>>
>>> https://docs.djangoproject.**com/en/1.5/howto/outputting-**pdf/
>>>  
>>> shows how you can stream a report directly to the end user. The example 
>>> uses reportlab to produce a PDF, but the same approach will work for a tool 
>>> writing to a different format.
>>>
>>> Yours,
>>> Russ Magee %-)
>>>  
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/93413618-01d4-4fc0-a4d0-94fa67efe371%40googlegroups.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fb0eaa54-83ab-4b68-bfbb-0702f09162ee%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best practice for server-generated downloads?

2013-10-03 Thread DJ-Tom
I have now created a test view that basically does what I want:

def reporting_new(request):

output = StringIO.StringIO()

book = Workbook(output)
sheet = book.add_worksheet('test')
sheet.write(0, 0, 'Hello, world!')
book.close()

# construct response
output.seek(0)
response = HttpResponse(output.read(), 
mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
response['Content-Disposition'] = "attachment; filename=test.xlsx"

return response

I could now use output:getvalue() to write it to disk - but how do I 
redirect the browser to the next page after the download?

Thomas


Am Mittwoch, 2. Oktober 2013 12:34:11 UTC+2 schrieb JirkaV:
>
> Hi Thomas, 
>
>  I'm doing exactly this - allowing users to download (graphically simple) 
> XLSx files from my web app, it also needs to be available for download 
> weeks later. 
>
>   As Russell pointed out, you don't need to store data on this if you have 
> a way of getting the same set of data later, you can always regenerate the 
> same Excel file. You don't even need to use StringIO for that.
>
>  I'm using the save_virtual_notebook() in openpyxl package to generate the 
> Excel file straight from database upon each (infrequent) request.
>
>   HTH
>
> Jirka
>
>
> On Wed, Oct 2, 2013 at 9:36 AM, Russell Keith-Magee <
> rus...@keith-magee.com > wrote:
>
>>
>> On Wed, Oct 2, 2013 at 2:33 PM, DJ-Tom > >wrote:
>>
>>> Hi,
>>>
>>> this is quite easy to answer - those reports need to be archived - users 
>>> must be able to download them days or weeks later.
>>>
>>> So I will create a record in a database for each report that is created 
>>> so users can access it later - maybe this can be seen as "uploading" a file 
>>> to the server that acts as a document repository, with the only difference 
>>> that the file is not uploaded, but produced by the server.
>>>
>>
>> Well, if you need archival, there are two alternatives:
>>
>> 1. Write the file to disk at the same time it is being generated. There's 
>> no reason you have to serve the file from where it was generated -- 
>> generate it, write it, and serve it.
>>
>> 2. Make sure the report will always be generated the same way. An analog 
>> here -- if you request a page from a web server, it probably isn't saved on 
>> disk like that (unless it's a genuinely static page) -- the server knows 
>> how to reproduce the same page every time you request a specific URL. Make 
>> the reports the same -- if you request /report/September-2013, you generate 
>> the same report every time. 
>>
>> The second approach depends on whether you have well time-bucketed data, 
>> but it's certainly possible to do.
>>
>>>
>>> I don't see how I could use the xlsxwriter object in the way it is 
>>> described here https://docs.djangoproject.**com/en/1.5/howto/outputting-
>>> **pdf/  - 
>>> how could I pass the httpresponse object to xlsxWriter?
>>> (Maybe I have not yet found how this might work - but it is not what I 
>>> need anyways...)
>>>
>>
>> I haven't used xlsxwriter myself, but the key part of the PDF example is 
>> that StringIO is an object that adheres to the python File API, but doesn't 
>> actually involve a file. So, you open a StringIO object, "write" to it, 
>> then dump the contents as the HTTP response. 
>>
>> So - whatever API endpoint on xlsxwriter lets you pass in a file object 
>> -- pass in a StringIO instance instead.
>>
>> Yours,
>> Russ Magee %-)
>>
>>
>>
>> Thomas
>>>
>>> Am Mittwoch, 2. Oktober 2013 02:11:21 UTC+2 schrieb Russell Keith-Magee:
>>>

 On Tue, Oct 1, 2013 at 9:49 PM, DJ-Tom  wrote:

> Hi,
>
> I need to create database report downloads in Excel format (via 
> xlsxwriter) and I'm wondering if there is any standard or best practice 
> as 
> to where those downloads should be located.
>
> Especially helpful would be if there was a portable way of managing 
> the file system location and web request url in a way so that I don't 
> have 
> to change settings between the development and production server.
>
> Is this -> 
> https://docs.djangoproject.**com/en/1.5/topics/files/the
>  way to go?
>
> If they're sever generated, why do they need to hit the file system at 
 all? 

 The following example in the docs:

 https://docs.djangoproject.**com/en/1.5/howto/outputting-**pdf/
  
 shows how you can stream a report directly to the end user. The example 
 uses reportlab to produce a PDF, but the same approach will work for a 
 tool 
 writing to a different format.

 Yours,
 Russ Magee %-)
  

>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this gr

Re: Best practice for server-generated downloads?

2013-10-03 Thread John McNamara
Hi,

Here is an example of using XlsxWriter from SimpleHTTPServer or Django. It 
probably doesn't do 100% of what you are looking for but it may help anyway.

https://xlsxwriter.readthedocs.org/en/latest/example_http_server.html

John

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1ad20701-8c36-49d0-8949-5e22e95b460b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Beginner to Django

2013-10-03 Thread Manimaran R
hai everyone!!

im a beginner to django,dont have prior knownledge about django!!

Help me step by step,rit frm installation!

for ur ref im using windows 7! dont have any open source,so help me with 
windows process


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7172a783-667d-4dfc-b96f-e819fe5d60ff%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Simple Captcha - Manually displaying the Captcha field in a template

2013-10-03 Thread Alexander Tyapkov

>
> Hi Mark,
>
 Interesting if you finally have found some solution or not?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b003558-4ac9-40ab-bda2-c5e977739cb6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


archival patterns/mixins?

2013-10-03 Thread Tim Chase
I've been trying to reduce some code in a new project, and I have a
number of objects where I have the main class, and an archival
version of the same class, something like

  def Thing(Model):
last_updated = DateTimeField(...)
who_updated = ForeignKey(User)
field1 = ...
field2 = ...
...

  def ThingArchive(Model):
# pseudo-type declaration
original_id = Thing.id.__class__ # whether Int or Guid

last_updated = DateTimeField(...)
who_updated = ForeignKey(User)
field1 = ...
field2 = ...
...

such that every time Thing is updated+saved, the previous copy's
information gets archived in ThingArchive, storing the original
Thing.id as original_id (the id might be an integer or a GUID
depending on the table).

For one class, this isn't a particularly big deal, but I've got a
number of these class-pairs and the code duplication is starting to
get out of hand.  Is there a pattern I should be using to abstract
this archiving logic?

Thanks,

-tkc



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20131003074539.7c9da54b%40bigbox.christie.dr.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Beginner to Django

2013-10-03 Thread Mario Gudelj
Hey champ!

Watch this video on installation on windaz
www.youtube.com/watch?v=rIVwVOpwpsA

Then tackle this tutorial
https://docs.djangoproject.com/en/dev/intro/tutorial01/


On 3 October 2013 20:20, Manimaran R  wrote:

> hai everyone!!
>
> im a beginner to django,dont have prior knownledge about django!!
>
> Help me step by step,rit frm installation!
>
> for ur ref im using windows 7! dont have any open source,so help me with
> windows process
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7172a783-667d-4dfc-b96f-e819fe5d60ff%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHqTbjm731%3DzkdBoOYqf4Sk8PwLk%2BRDwL446Vbr75oEevfUigQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


how start work in django after installation in ubuntu

2013-10-03 Thread jasvir sandhu


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52759c02-31f1-4c94-a856-18375626d94d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Have browsers broken post-redirect-get? best practice now?

2013-10-03 Thread graeme
I disagree that breaking the back button is always bad. For example suppose 
you have a series of forms (i.e. a "wizard"):

Page 1) fill in form. On POST creates a new Model() and saves it to the 
database
2) do stuff to the object (e.g. add inlines, whatever).
3) whatever comes next

At stop two, user clicks back. They then post the form again, and get 
another object. On the other hand the page in step 2 can provide a back 
button on the page that takes the user back to edit what they entered on 
page 1. Which is more useful? I would say the latter - and users may not 
then understand that the browser back button and page back button do 
different things.

On Tuesday, October 1, 2013 8:33:41 PM UTC+5:30, antialiasis wrote:
>
> You should still be able to use the back button; it just shouldn't try to 
> post the data again if you do so. Are you getting a prompt about resending 
> post data, or are you just talking about being able to use the back button 
> at all? If the latter, that's exactly what should happen. Breaking the 
> user's back button is bad.
>
> On Tuesday, October 1, 2013 12:41:20 PM UTC, graeme wrote:
>>
>> The Django  docs (and a lot else) recommend redirecting after 
>> successfully processing a post request (if it changes data). i.e. post, the 
>> save stuff to the database, then redirect.
>>
>> Current browsers seem to allow this. I have tried Chromium 28 and 24 on 
>> Linux, I user return redirect(...) after the post, and I can still use the 
>> back button.
>>
>> Is it my configuration, or is it usual? What is the best practice if this 
>> is broken?
>>
>> In some cases I think tracking where the user is (in the session, or 
>> using the state of a particular object such as an order model), and 
>> redirecting any request for an earlier page in a sequence may be the way to 
>> go. Or is this a solved problem that I am too far behind the curve to know 
>> about?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cf0dd1f1-b004-4595-800f-1190ca9f4171%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django Pagination

2013-10-03 Thread Hélio Miranda
Hi guys.

I'm here with a problem that does not quite know how to solve.
I have this query:
result = json.dumps([a.get_json() for a in 
Player.objects.filter(name=namepost)])

But now I want to return the result with paging, and do not really know how 
to do ... I've been seeing in the documentation to use the Paginator.

But for example when I do this
p = Paginator(result, 2)
print p.count

Gives 1609 ... and the result of the query is 3 records.

Someone can help me?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b2cb773f-f8f4-43e9-ab02-0abd4e391171%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Tom Christie
Hi Hélio,

It looks like you're applying pagination to the rendered JSON string itself.
You want to be paginating the queryset itself.

queryset = Player.objects.filter(name=namepost)
paginator = Paginator(queryset, 20)
return json.dumps([item.to_dict() for item in paginator.object_list])

Hope that helps.

On Thursday, 3 October 2013 14:34:18 UTC+1, Hélio Miranda wrote:
>
> Hi guys.
>
> I'm here with a problem that does not quite know how to solve.
> I have this query:
> result = json.dumps([a.get_json() for a in 
> Player.objects.filter(name=namepost)])
>
> But now I want to return the result with paging, and do not really know 
> how to do ... I've been seeing in the documentation to use the Paginator.
>
> But for example when I do this
> p = Paginator(result, 2)
> print p.count
>
> Gives 1609 ... and the result of the query is 3 records.
>
> Someone can help me?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ee66f864-30c7-450d-806a-763f12313c89%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
I'm doing this:
*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 20)*
*return json.dumps([item.get_json() for item in paginator.object_list])*

And my Document is thus:
http://plnkr.co/edit/FHH2hZh26OiLMKTk2ToO

But it gives me the following error:

'str' object has no attribute 'status_code'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/29b801fe-644c-42b4-85aa-733de74c341a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
Already got it, I did so:
*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 1)*
*return HttpResponse(json.dumps([item.get_json() for item in 
paginator.object_list]) , content_type='application/json')*

But I return all the records ... I should not return only 2?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/883c9f30-980a-4d9b-b116-5b5b9da04b5d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
Already got it, I did so:
*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)*
*return HttpResponse(json.dumps([item.get_json() for item in 
paginator.object_list]) , content_type='application/json')*

But I return all the records ... I should not return only 2?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e7e37ad2-281c-41f4-a0b9-b333294fe1b8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Roberto López López
Better to say:

*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)
page = request.GET.get('page')
try:
players = paginator.page(page)
except PageNotAnInteger:
players = paginator.page(1)
except EmptyPage:
players = paginator.page(paginator.num_pages)
*
*return HttpResponse(json.dumps(players) ,
content_type='application/json')*


On 10/03/2013 04:07 PM, Hélio Miranda wrote:
> Already got it, I did so:
> *queryset = Player.objects.filter(name=namepost)*
> *paginator = Paginator(queryset, 2)*
> *return HttpResponse(json.dumps([item.get_json() for item in
> paginator.object_list]) , content_type='application/json')*
>
> But I return all the records ... I should not return only 2?
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7e37ad2-281c-41f4-a0b9-b333294fe1b8%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524D7BB6.1050502%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Roberto López López
Try this (I have not tried the code myself, but I think that it should
work):

*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)
page = request.GET.get('page')
try:
players = paginator.page(page)
except PageNotAnInteger:
players = paginator.page(1)
except EmptyPage:
players = paginator.page(paginator.num_pages)
*
*return HttpResponse(json.dumps([players]) ,
content_type='application/json')*



On 10/03/2013 04:07 PM, Hélio Miranda wrote:
> Already got it, I did so:
> *queryset = Player.objects.filter(name=namepost)*
> *paginator = Paginator(queryset, 2)*
> *return HttpResponse(json.dumps([item.get_json() for item in
> paginator.object_list]) , content_type='application/json')*
>
> But I return all the records ... I should not return only 2?
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7e37ad2-281c-41f4-a0b9-b333294fe1b8%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524D7B79.4090400%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: is it possible to make the |safe template filter conditional on content

2013-10-03 Thread Bill Freeman
You can certainly write a custom filter.  And if you do that, you can divvy
up your value into footnote links and other, and escape the other parts
yourself, returning the result as a safe string.


On Thu, Oct 3, 2013 at 2:55 AM, Mike Dewhirst  wrote:

> I made a custom template filter (ref_href) which converts numbered
> references (like [1], [2] etc) into footnote hyperlinks. It works but
> requires the |safe filter which is dangerous.
>
> To be actually safe I want to *only* use the |safe filter when the data
> contains a numbered reference. Which I cannot do if it is permanently in
> the template. In other words, I want to remove the |safe filter from the
> template and incorporate it into my custom filter which checks that we have
> an integer between the square brackets before doing its work.
>
> Just thinking about it now, I suppose I could put a conditional in the
> template ...
>
> {% if "[" in value %}
>   {{ value | ref_href | safe }}
> {% else %}
>   {{ value }}
> {% endif %}
>
> ... but that's a lot of typing over dozens of templates. And it isn't good
> enough.
>
> Thanks for any secrets
>
> Mike
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> django-users+unsubscribe@**googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/django-users
> .
> To view this discussion on the web visit https://groups.google.com/d/**
> msgid/django-users/524D14D9.**5090605%40dewhirst.com.au
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0uMUVFmHGY%3DYckq_e03ve1WhKG29ruCUWRU2zaVuFsN2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
doing so:
*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)*
*
*
*page = request.GET.get('page')*
*try:*
*players = paginator.page(page)*
*except PageNotAnInteger:*
*players = paginator.page(1)*
*except EmptyPage:*
*players = paginator.page(paginator.num_pages)*
*return HttpResponse(json.dumps(players) , 
content_type='application/json')*

Gives the following error:

 is not JSON serializable


Testing like this:*queryset = Player.objects.filter(name=namepost)
paginator = Paginator(queryset, 2)
  return HttpResponse(json.dumps([item.get_json() for item in 
paginator.page(1)]) , content_type='application/json')*

works, but I have to put the page number of manually

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c2ad980-05f2-408e-8049-96c5900fb4f9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Roberto López López
On 10/03/2013 04:13 PM, Roberto López López wrote:
> *return HttpResponse(json.dumps([players]) ,
> content_type='application/json')*
better without the square brackets

*return HttpResponse(json.dumps(players) ,
content_type='application/json')*

-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524D7F41.7070003%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
thus still giving the same error

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0a0a64c2-c573-4803-a192-fee936e0d65b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Group_by Django list

2013-10-03 Thread Daniel Gómez Rico


I have a django model:

class Person(models.Model):
 Modelo criado com referencia ao modelo remoto """

name = models.CharField(max_length=300)
age = models.PositiveIntegerField()
born = models.DateField()

I want to group all the people by birthday (group by born date). I'm trying 
to get a dictionary of dictionaries, like this:

{ 
02-17:[
{
   name:'Daniel',
   age:22
},
{
   name:'Pedro',
   age:23
},
  ],
05-24:[
{
   name:'Juan',
   age:44
}
  ]}

One option is:

query = Person.objects.all().query
query.group_by = ['born']
for item in QuerySet(query=query, model=Person):
print item

but it returns a list with all objects ordered by date... no grouped.

Can I do this by django ORM or with sql raw? I will have to do it by myself?

Thanks

http://stackoverflow.com/questions/19161671/group-by-django-list

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e1cf2673-f128-4cf7-81b3-37c3e5de0d90%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: uptodate Account_balance

2013-10-03 Thread MAurice
Am creating this project in that a client has an account in a micro-finance 
and can also Take Loans which loan is credited onto this very account.
The problem is am trying to find a way of having an Account_balance which 
will be changing when deposits and withdrawals are made to the account
and also when loan payments are made. These are supposed to be reflected on 
the account statement. am having issues with this account_balance being 
updated
Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/958a9c22-1da5-4551-9a60-960ca85c0be3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
Thanks for the help guys, I managed to solve, so I did:

* queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)*
*
*
*try: *
* page = int(request.POST.get('page','1')) *
*except ValueError: *
* page = 1 *
*try: *
*results = paginator.page(page) *
*except (EmptyPage, InvalidPage): *
*results = paginator.page(paginator.num_pages) *
*return HttpResponse(json.dumps([item.get_json() for item in 
results.object_list]) , content_type='application/json')*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b0e5b6c-6337-4ea5-8020-535377657b15%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: archival patterns/mixins?

2013-10-03 Thread Bill Freeman
Use one model with a field to indicate whether or not this is the archival
(backup?) version.  This could be your original_id field, which might be
better represented as a null-able foreign key field on self.  Update step:

delete any instances whose "original" is this field (the reverse
reference manager works for this)
save a copy of the current instance (with any changes you want, and a
null "original" field)
update the "original" field of the old copy to point to the new one.

This can be extended to more than one level of backup.


On Thu, Oct 3, 2013 at 8:45 AM, Tim Chase wrote:

> I've been trying to reduce some code in a new project, and I have a
> number of objects where I have the main class, and an archival
> version of the same class, something like
>
>   def Thing(Model):
> last_updated = DateTimeField(...)
> who_updated = ForeignKey(User)
> field1 = ...
> field2 = ...
> ...
>
>   def ThingArchive(Model):
> # pseudo-type declaration
> original_id = Thing.id.__class__ # whether Int or Guid
>
> last_updated = DateTimeField(...)
> who_updated = ForeignKey(User)
> field1 = ...
> field2 = ...
> ...
>
> such that every time Thing is updated+saved, the previous copy's
> information gets archived in ThingArchive, storing the original
> Thing.id as original_id (the id might be an integer or a GUID
> depending on the table).
>
> For one class, this isn't a particularly big deal, but I've got a
> number of these class-pairs and the code duplication is starting to
> get out of hand.  Is there a pattern I should be using to abstract
> this archiving logic?
>
> Thanks,
>
> -tkc
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20131003074539.7c9da54b%40bigbox.christie.dr
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0uvRYAgH2L8Yf3SeZFfWT5akB5a70255auB%2BkdLr5xShw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: how start work in django after installation in ubuntu

2013-10-03 Thread Nigel Legg
work through the tutorial.

Cheers, Nigel
07914 740972



On 3 October 2013 13:28, jasvir sandhu  wrote:

>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/52759c02-31f1-4c94-a856-18375626d94d%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADeX7vwC2SY2P%2BgXBDu6KHxkPEU5ABiLDwMs9G5A7nV96Xkh5g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django-cart. How to run method add_to_cart?

2013-10-03 Thread Ricardo Kamada
Hi Leonardo. managed to make the implementation of the cart. not used the
card but django django carton. There are the same but they are similar.
veleu for help. I'm passing the objects by post. Thanks for the help.
Em 02/10/2013 04:10, "Leonardo Giordani" 
escreveu:

> Hi Ricardo,
>
> well this is a question that needs a good explanation. I try to give you
> some hints about what you need to research about:
>
> a. You need to send data to the Django server through a POST view. This is
> a HTTP "verb", that is one of many different ways the browser has to
> communicate with your server. In particular, POST views in Django work just
> like standard views (i.e. GET views), but the request object has a POST
> attribute which encompasses the data sent by the browser.
>
> b. To create a POST HTTP request in your browser you need to create a
> form, and Django can help you with a very very rich API.
>
> So the general roadmap to achieve what you want is:
>
> 1. Set up a POST view that processes the incoming data
> 2. Link the POST view to an URL
> 3. Create an HTML template which shows a form to the user and sends data
> back to the server.
>
> The 3rd point is obviously needed only if you have to show the user a form
> to collect the input he or she enters. You can also call POST views
> directly, e.g. including some JS that performs the request, but this is an
> advanced topic.
>
> Start by looking at this video 
> tutorialand reading the docs on 
> Django
> Forms 
>
> I'd suggest you to also check the following resources to understand the
> previous two matters:
>
> http://www.w3schools.com/tags/ref_httpmethods.asp
> https://docs.djangoproject.com/en/dev/ref/request-response/
> http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
> https://docs.djangoproject.com/en/dev/ref/forms/api/
>
> Feel free to ask more if you need help.
>
> Cheers,
>
> Leo
>
>
> Leonardo Giordani
> Author of The Digital Cat 
> My profile on About.me  - My GitHub
> page  - My Coderwall 
> profile
>
>
> 2013/10/1 Ricardo Kamada 
>
>> you already helped me a lot =)
>> Leonardo looks just http://dpaste.com/1402408/
>> On line 20 I pass a value of fixed amount in the template.
>> How would get the amount in input dynamically?
>>
>> Abs
>> [] s
>>
>> Ricardo
>>
>>
>> 2013/10/1 Leonardo Giordani 
>>
>>>  Ricardo,
>>>
>>> I think the example on the django-cart site are somehow incorrect: since
>>> you are going to change the database you shall use a POST view and not a
>>> GET.
>>>
>>> However, putting apart HTTP verbs for a moment, let's look at how you
>>> call views from URLs. If you write something like the following in your
>>> views.py (or whatever file you mapped in your urls.py)
>>>
>>>
>>> from django.conf.urls import patterns, url
>>>
>>> from django.shortcuts import render_to_response
>>>
>>> def my_view(request, product_id, quantity):
>>> [do something with product_id and quantity]
>>> return render_to_response('template.html')
>>>
>>> urlpatterns = patterns('',
>>>url(r'^(?P\d+)/(?P\d+)/$',
>>>my_view
>>>)
>>>
>>> you can browse to http://yoursite/path/1234/56 and have the Python
>>> function my_view(product_id=1234, quantity=56) called.
>>>
>>> Try and implement something like the above code and see if it works.
>>>
>>> As for the django_cart: when you modify the DB always use POST views and
>>> not GET, then you are right, you have to return a template rendering in
>>> your add_to_cart() view.
>>>
>>> Let me know if it comes to life =)
>>>
>>> Cheers,
>>> Leo
>>>
>>>
>>>
>>> Leonardo Giordani
>>> Author of The Digital Cat 
>>> My profile on About.me  - My GitHub
>>> page  - My Coderwall 
>>> profile
>>>
>>>
>>> 2013/10/1 Ricardo Kamada 
>>>
  Leonardo Hi thanks for the reply but I still can not understand.
 I really need to pass the id and quantity parameters in the url? After
 all I'm recording the items in the correct session?
 I saw that the method has no return add_to_cart, as well as other
 methods remove_from_cart.
 In my template I am calling the method like this:
  >>> detalhe_produto.id1%}"> Buy  

 and URLs:
 url (r '^ products / buy / $', 'cart.views.add_to_cart', name =
 'add_to_cart')

 You say that to pass arguments id and quantity that url?

 Ricardo


 2013/10/1 Leonardo Giordani 

>  You have to implement an URL dispatcher that links an URL to your
> view.
> Read here and 
> feel free to ask again if something is still not clear.
>

Re: how start work in django after installation in ubuntu

2013-10-03 Thread Vibhu Rishi
First of all, i suggest you start working in django in a virtualenv. This
helps as you can have your own virtual env for installing additional django
modules. if you want to host and check it on the web, i suggest you
checkout this page :
https://devcenter.heroku.com/articles/getting-started-with-django

then i suggest that you do the tutorials on django website.

then i suggest you get a book on django and do the project in it to
understand how things work. e.g. this book
http://www.amazon.com/Beginning-Django-E-Commerce-Experts-Development/dp/1430225351/ref=sr_1_1?s=books&ie=UTF8&qid=1380819727&sr=1-1&keywords=django+ecommerce


then you start making your own projects.

Vibhu



On Thu, Oct 3, 2013 at 5:58 PM, jasvir sandhu wrote:

>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/52759c02-31f1-4c94-a856-18375626d94d%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPiONwkBe4Uhm4cYa6r0H64rXmCLcw90La_%2BNrJoWkHH%2BKmQAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: uptodate Account_balance

2013-10-03 Thread C. Kirby
Use signals:
 https://docs.djangoproject.com/en/dev/topics/signals/

post_save check the amount deposited or withdrawn and update the balance

On Thursday, October 3, 2013 9:42:48 AM UTC-5, MAurice wrote:
>
> Am creating this project in that a client has an account in a 
> micro-finance and can also Take Loans which loan is credited onto this very 
> account.
> The problem is am trying to find a way of having an Account_balance which 
> will be changing when deposits and withdrawals are made to the account
> and also when loan payments are made. These are supposed to be reflected 
> on the account statement. am having issues with this account_balance being 
> updated
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a13ccfd8-d34d-42a2-88ea-54d687e806b9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django App - Accessing Remote MySQL Database

2013-10-03 Thread Liam Griffin
I have a MySQL server with hundreds of dbs... is there a way to be able to 
connect to all these without breaking DRY principles?

On Friday, 2 August 2013 14:26:23 UTC+1, Christian Schmitt wrote:
>
> You could use django's inbuild ORM:
> https://docs.djangoproject.com/en/dev/topics/db/multi-db/
> And just copy the database.
>
> Am Freitag, 2. August 2013 02:50:35 UTC+2 schrieb Ji Park:
>>
>> Hello, I'm trying to make an app that can periodically access a remote 
>> mysql database.
>>
>> This app will query the remote database and copy some data to the local 
>> postgresql database.
>>
>> So far I know that celery can be used to schedule periodic tasks, but I'm 
>> not sure what to do about querying the remote mysql database server.
>>
>> Should I just use python's MySQLdb module, does anyone know any other 
>> python module that I can use to query mysql db?
>>
>> Would this even be a good way to access remote database server from a 
>> django app? I'll have to be running a function that is within tasks.py 
>> periodically (via celery-django), would there be any better way to access 
>> remote mysql server from a django app in this case?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/04375d45-95e9-4354-afef-3f6b9e03f38e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Custom Filter: Filter output based on a Python list

2013-10-03 Thread +Emmanuel
Thanks for the update and the code. Been trying to make sense of the code 
and trying to get it to work. This is my first project so I still have some 
challenges:


   - My model contains a field examperiod = models.CharField(max_length = 
   100) which I need to use to filter. How exactly do I apply that in 
   . I can't seem to get it to work.
   - The code you provided to be used in the template is a little difficult 
   for me to comprehend. Previously, I could use query.coursecode, 
   query.examcode, etc to populate the specific cells in the table. I can't 
   seem to figure out how to do that with the new piece of code.

Thanks for the help :)

On Wednesday, October 2, 2013 4:32:22 PM UTC+3, Leo wrote:
>
> Ok, now I get the point. I STRONGLY suggest to avoid performing big 
> computations while rendering templates, so I think it is better for you to 
> try something like
>
> def results_page(request):
> context = {}
> context.update(locals())
> context['periods'] = {}
> for period in ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']:
> context['periods'][period] = Results.objects.all().filter(\
>reg_number = 
> 'DBA/20020/82/DU').filter()
> return render_to_response('results.html', context, context_instance = 
> RequestContext(request))
>
> and in template
>
> {% for period,results in periods.items %}
> 
> [...]
> Here you can use {{period}}, which is in turn 'DECEMBER 2011', 'MAY 
> 2011', and so on, and
> {{result}} that encompasses the values extracted from the DB.
> [...]
> 
> {% endfor %}
>
> I included a filter() since I do not know the 
> models, so I do not know how you can filter out by examination period.
>
> Please note that I would not pass the whole locals() dict to the view, 
> but carefully select what I need in the template.
>
> Speaking about your filter
>
> @register.filter
> def periodofexamination(periodofexam):
> periodofexam = ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']
> for period in periodofexam:
> return period
>
> I think you misunderstood the filter role, which is, indeed, to filter, 
> things. Here, the input periodofexam variable is not filtered, but 
> overwritten. Furthermore, you use return in a for loop, so the result of 
> your filter is 'DECEMBER 2011' irrespective of the input value.
>
> Please check the above code, I wrote it directly in the mail composer, so 
> bugs are certainly lurking.
>
> Let me know if you succeed in solving the problem
>
> Leo
>
>
>
>
> Leonardo Giordani
> Author of The Digital Cat 
> My profile on About.me  - My GitHub 
> page  - My Coderwall 
> profile
>  
>
> 2013/10/2 +Emmanuel >
>
>> Here's the view:
>> def results_page(request):
>> queryset = Results.objects.all().filter(reg_number = 
>> 'DBA/20020/82/DU')
>> return render_to_response('results.html', locals(), context_instance 
>> = RequestContext(request))
>>
>> Please note that, so far, there's nothing wrong with the view. Using the 
>> custom filter at the output level is where the issue is.
>> What I want to do is something close to this (note the bold items):
>>
>> *{% for query in queryset|periodofexamination %}*
>> 
>> Course CodeCourse NameCourse 
>> WorkExamGradeGPAYearExam 
>> Period
>>
>> {{ 
>> query.coursecode}}{{query.coursename}}{{query.coursework}}{{query.exam}}{{query.exam|grade}}{{query.exam|gpa}}{{query.academicyear}}{{query.examperiod}}
>>
>> 
>> {% endfor %}
>> {% endblock %}
>>
>> On Wednesday, October 2, 2013 3:00:40 PM UTC+3, Leo wrote:
>>
>>> Can you perhaps paste the view you are using to render the template? So 
>>> I can try and help your with some code
>>>
>>> Leonardo Giordani
>>> Author of The Digital Cat 
>>> My profile on About.me  - My GitHub 
>>> page  - My Coderwall 
>>> profile
>>>  
>>>
>>> 2013/10/2 +Emmanuel 
>>>
  That's what I have been trying to do for quite sometime now! I can't 
 seem to get the code right.


 On Wednesday, October 2, 2013 2:13:25 PM UTC+3, Leo wrote:

> I'd cycle in the template through a list of exam periods, printing a 
> table for each cycle.
> You have to pass the list of exam periods in the context of your view.
>
> Try and let me know.
>
> Regards,
> Leo
>
>
> Leonardo Giordani
> Author of The Digital Cat 
> My profile on About.me  - My GitHub 
> page  - My Coderwall 
> profile
>  
>
> 2013/10/2 +Emmanuel 
>
>>  Am working on a Django project that retrieves a student's details 
>> from the database, filters them based on the

Django on Windows server 2008

2013-10-03 Thread Robert Jonathan Šimon
Have someone figure it how can someone deploy Django 1.5 with Python 3.3 on 
Windows Server 2008 R2? Because i search internet i think 4 months ago, and 
i didnt found anything working. So How can it be done?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/577348a0-3e88-4a7a-b795-b0ad95fbd9c3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Override model field attributes from a ModelForm?

2013-10-03 Thread Storn White
Hi,

My custom user model requires unique email addresses, which are the users' 
identifiers.

My user registration modelform works great.  If a user tries to register 
with an email that is already in the system, the form fails to validate and 
the 'unique' invalid message is displayed back to the user.

I am trying to create an authentication modelform based on the same user 
model.  When I try to authenticate a registered user, the email field 
throws the unique validation error.  How can I overwrite this property? 
 I've tried:

class MyUserModel(AbstractBaseUser):
"""
Custom User Model requires unique email address.
"""
# email field
email = models.EmailField(
unique=True,
error_messages={
'invalid': "You must enter a valid email address.",
'unique': "Your email address is already in our system!"
}
)

class MyAuthForm(forms.ModelForm):
"""
Form for authenticating users.
"""
def __init__(self, *args, **kwargs):
super(MyAuthForm, self).__init__(*args, **kwargs)
self.Meta.model.email.unique = True

I've tried a few variations on this with no luck.  Any ideas?

Thanks!
  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/32f415a0-99e2-461b-8dca-44c0ea98ce93%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Have browsers broken post-redirect-get? best practice now?

2013-10-03 Thread David Durham
I think when they hit the browsers back button, the form will have the
data they entered previously.  When they submit it, since it was
already submitted previously, you could just make it an edit action,
or do whatever is appropriate given that they are submitting the same
form again.  I think the functionality of the browser's back button is
universal and accepted and shouldn't be broken or reinvented.

-Dave

On Thu, Oct 3, 2013 at 8:15 AM, graeme  wrote:
> I disagree that breaking the back button is always bad. For example suppose
> you have a series of forms (i.e. a "wizard"):
>
> Page 1) fill in form. On POST creates a new Model() and saves it to the
> database
> 2) do stuff to the object (e.g. add inlines, whatever).
> 3) whatever comes next
>
> At stop two, user clicks back. They then post the form again, and get
> another object. On the other hand the page in step 2 can provide a back
> button on the page that takes the user back to edit what they entered on
> page 1. Which is more useful? I would say the latter - and users may not
> then understand that the browser back button and page back button do
> different things.
>
> On Tuesday, October 1, 2013 8:33:41 PM UTC+5:30, antialiasis wrote:
>>
>> You should still be able to use the back button; it just shouldn't try to
>> post the data again if you do so. Are you getting a prompt about resending
>> post data, or are you just talking about being able to use the back button
>> at all? If the latter, that's exactly what should happen. Breaking the
>> user's back button is bad.
>>
>> On Tuesday, October 1, 2013 12:41:20 PM UTC, graeme wrote:
>>>
>>> The Django  docs (and a lot else) recommend redirecting after
>>> successfully processing a post request (if it changes data). i.e. post, the
>>> save stuff to the database, then redirect.
>>>
>>> Current browsers seem to allow this. I have tried Chromium 28 and 24 on
>>> Linux, I user return redirect(...) after the post, and I can still use the
>>> back button.
>>>
>>> Is it my configuration, or is it usual? What is the best practice if this
>>> is broken?
>>>
>>> In some cases I think tracking where the user is (in the session, or
>>> using the state of a particular object such as an order model), and
>>> redirecting any request for an earlier page in a sequence may be the way to
>>> go. Or is this a solved problem that I am too far behind the curve to know
>>> about?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cf0dd1f1-b004-4595-800f-1190ca9f4171%40googlegroups.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADM6s_D_7R9Yix60h7ZMdMdRbs%2BX5T9%2BOHDhHGMrJ_B%3D4xVqZg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Simple Captcha - Manually displaying the Captcha field in a template

2013-10-03 Thread mmuk2
Hi Alexander,

Although I no longer use captcha on the form in question anymore, I recall 
that I did eventually get it working by adding something like the following 
in my html to generate the captcha component:

{{ signup_form.captcha.label 
}}
{{ signup_form.captcha }}{{ 
signup_form.captcha.errors }}

thanks,
Mark

On Tuesday, March 5, 2013 1:10:42 PM UTC+11, mmuk2 wrote:
>
> Hi,
>
> I'm currently trying to implement django simple captcha on my form. It's 
> quite straight forward to set up with the "out of the box" django form 
> functionality - just add a captcha field to the form in forms.py, and in 
> the template, use the built in django form template like this:
>
> {% form.as_ul %}
>
> And this dynamically generates the HTML for all my form fields including 
> the captcha field:
>
> Captcha:
>  src="/captcha/image/7114a37ed0f72ec3105510e0f5c73128a2f95649/">
>  value="7114a37ed0f72ec3105510e0f5c73128a2f95649" name="captcha_0">
> 
>
> My issue is that I can't use {% form.as_ul %} to display my form, because 
> each field requires customised css styling.
>
> So I'll need to replace the {% form.as_ul %} with the actual HTML code in 
> my template.
>
> This works fine, however, the captcha field value needs to be re-generated 
> each time, so I need to generate the captcha field value dynamically each 
> time the form is loaded.
>
> What is the best way to do this? I guess I'm looking for something similar 
> to the way the csrf token works, ie. the {% csrf_token %} tag, which 
> dynamically generates the csrf token. Is there an equivalient for simple 
> captcha, like {% captcha_value %} or something?
>
> thanks in advance,
> Mark
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cc653d53-e48f-4e2c-be4a-1706e242906d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: is it possible to make the |safe template filter conditional on content

2013-10-03 Thread Mike Dewhirst

On 4/10/2013 12:21am, Bill Freeman wrote:

You can certainly write a custom filter.  And if you do that, you can
divvy up your value into footnote links and other, and escape the other
parts yourself, returning the result as a safe string.


So you mean I detect any non-footnote html in the custom filter myself 
and convert it to Klingon but add my own html for footnotes and flag all 
such fields as safe?


Hadn't thought of that. Might investigate calling the Django safe filter 
from within the custom filter ...


Great idea, thanks

Mike




On Thu, Oct 3, 2013 at 2:55 AM, Mike Dewhirst mailto:mi...@dewhirst.com.au>> wrote:

I made a custom template filter (ref_href) which converts numbered
references (like [1], [2] etc) into footnote hyperlinks. It works
but requires the |safe filter which is dangerous.

To be actually safe I want to *only* use the |safe filter when the
data contains a numbered reference. Which I cannot do if it is
permanently in the template. In other words, I want to remove the
|safe filter from the template and incorporate it into my custom
filter which checks that we have an integer between the square
brackets before doing its work.

Just thinking about it now, I suppose I could put a conditional in
the template ...

{% if "[" in value %}
   {{ value | ref_href | safe }}
{% else %}
   {{ value }}
{% endif %}

... but that's a lot of typing over dozens of templates. And it
isn't good enough.

Thanks for any secrets

Mike

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users+unsubscribe@__googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at http://groups.google.com/__group/django-users
.
To view this discussion on the web visit

https://groups.google.com/d/__msgid/django-users/524D14D9.__5090605%40dewhirst.com.au

.
For more options, visit https://groups.google.com/__groups/opt_out
.


--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAB%2BAj0uMUVFmHGY%3DYckq_e03ve1WhKG29ruCUWRU2zaVuFsN2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524E0163.7010406%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Have browsers broken post-redirect-get? best practice now?

2013-10-03 Thread Darren Spruell
On Thu, Oct 3, 2013 at 6:15 AM, graeme  wrote:
> I disagree that breaking the back button is always bad. For example suppose
> you have a series of forms (i.e. a "wizard"):
>
> Page 1) fill in form. On POST creates a new Model() and saves it to the
> database
> 2) do stuff to the object (e.g. add inlines, whatever).
> 3) whatever comes next
>
> At stop two, user clicks back. They then post the form again, and get
> another object. On the other hand the page in step 2 can provide a back
> button on the page that takes the user back to edit what they entered on
> page 1. Which is more useful? I would say the latter - and users may not
> then understand that the browser back button and page back button do
> different things.

Django supports this form wizard behavior in a sane way through Form Wizards:

https://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/

In the case of form wizards, each step through the series of forms in
the wizard occurs from the same URL, and the API provides users a way
to traverse individual forms (steps) in the wizard in a controlled
way. If the client uses the browser back button, it drops them back
from the URL the form wizard is served from, not to a previous step in
the form.

DS




> On Tuesday, October 1, 2013 8:33:41 PM UTC+5:30, antialiasis wrote:
>>
>> You should still be able to use the back button; it just shouldn't try to
>> post the data again if you do so. Are you getting a prompt about resending
>> post data, or are you just talking about being able to use the back button
>> at all? If the latter, that's exactly what should happen. Breaking the
>> user's back button is bad.
>>
>> On Tuesday, October 1, 2013 12:41:20 PM UTC, graeme wrote:
>>>
>>> The Django  docs (and a lot else) recommend redirecting after
>>> successfully processing a post request (if it changes data). i.e. post, the
>>> save stuff to the database, then redirect.
>>>
>>> Current browsers seem to allow this. I have tried Chromium 28 and 24 on
>>> Linux, I user return redirect(...) after the post, and I can still use the
>>> back button.
>>>
>>> Is it my configuration, or is it usual? What is the best practice if this
>>> is broken?
>>>
>>> In some cases I think tracking where the user is (in the session, or
>>> using the state of a particular object such as an order model), and
>>> redirecting any request for an earlier page in a sequence may be the way to
>>> go. Or is this a solved problem that I am too far behind the curve to know
>>> about?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cf0dd1f1-b004-4595-800f-1190ca9f4171%40googlegroups.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Darren Spruell
phatbuck...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKVSOJXf58hvD1H6pu%2BMfo5fUMxKm-VDbncr7hSX7Xm14arP7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Disabling object persistence ?

2013-10-03 Thread Marc'h
Hello,

I'm battling with Django in order to try avoiding object persistence when 
initialising foreign key model attributes. The app I'm using Django for 
implements a facade for an already existing database. It's main purpose is 
to be used as a (read-only) ReST server returning objects built by 
aggregating attributes from the already existing database. The Django app 
itself has model classes (and associations) like any other Django app. 
Renderers and Serializers based on those supplied by the rest_framework 
modules have been written and tested. We started by configuring the Django 
app to use a SQLite file, as we're don't really care about object 
persistence. However, when building model instances (by 
extracting/aggregating data from the original non-Django managed database), 
we hit a severe perfomance bottleneck. Each time we initialize a model 
attribute which is a collection of related instances, all these are 
apparently persisted to the Django database.

For example, with a classical Order/Items association, we'd have :

01: orderattributes={...extract attributes from external database using 
> SQL...}
> 02: order=Order(**orderattributes)
> 03: orderitems=[]
> 04: for item in ...items belonging to order...
> 05:itemattributes={...extract attributes from external database using 
> SQL...}
> 06:item=Item(**itemattributes)
> 07:orderitems.append(item)
> 08: order.items_set=orderitems


When reaching line 8, it seems that every Item instance of the orderitems 
collection is persisted in the Django database, which considerably slows 
down the application.
I tried to use an in-memory SQLite database, but couldn't make it work, as 
the syntax for declaring a shared in-memory database (file::memory:...) is 
not handled correctly, yielding a file-based database instead.

Thus, I'd like to know if there is any means to by-pass the automatic 
persistence mechanism when using collection attributes which are 
foreign-key based.

Thanks for any pointers !


Marc'h







-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ba9a4637-26ac-4f59-923c-ff43d24be02a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: is it possible to make the |safe template filter conditional on content

2013-10-03 Thread Mike Dewhirst

On 4/10/2013 9:44am, Mike Dewhirst wrote:

On 4/10/2013 12:21am, Bill Freeman wrote:

You can certainly write a custom filter.  And if you do that, you can
divvy up your value into footnote links and other, and escape the other
parts yourself, returning the result as a safe string.


So you mean I detect any non-footnote html in the custom filter myself
and convert it to Klingon but add my own html for footnotes and flag all
such fields as safe?

Hadn't thought of that. Might investigate calling the Django safe filter
from within the custom filter ...

Great idea, thanks


And Django is fantastic too :)

All I need to do is ...

from django.utils.safestring import mark_safe

and return mark_safe(value_with_footnote_href) within my custom filter.

... which means I don't have to use the |safe filter and which makes me 
much happier.


Cheers

Mike






Mike




On Thu, Oct 3, 2013 at 2:55 AM, Mike Dewhirst mailto:mi...@dewhirst.com.au>> wrote:

I made a custom template filter (ref_href) which converts numbered
references (like [1], [2] etc) into footnote hyperlinks. It works
but requires the |safe filter which is dangerous.

To be actually safe I want to *only* use the |safe filter when the
data contains a numbered reference. Which I cannot do if it is
permanently in the template. In other words, I want to remove the
|safe filter from the template and incorporate it into my custom
filter which checks that we have an integer between the square
brackets before doing its work.

Just thinking about it now, I suppose I could put a conditional in
the template ...

{% if "[" in value %}
   {{ value | ref_href | safe }}
{% else %}
   {{ value }}
{% endif %}

... but that's a lot of typing over dozens of templates. And it
isn't good enough.

Thanks for any secrets

Mike

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users+unsubscribe@__googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at http://groups.google.com/__group/django-users
.
To view this discussion on the web visit

https://groups.google.com/d/__msgid/django-users/524D14D9.__5090605%40dewhirst.com.au


.

For more options, visit https://groups.google.com/__groups/opt_out
.


--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAB%2BAj0uMUVFmHGY%3DYckq_e03ve1WhKG29ruCUWRU2zaVuFsN2Q%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.




--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524E66AD.3070104%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.