Re: How do I get Django to ignore javascript code because its throwing an exception

2014-07-30 Thread Camilo Torres
Hello, you can use 'verbatim':
https://docs.djangoproject.com/en/1.6/ref/templates/builtins/#verbatim

On Wednesday, July 30, 2014 6:59:05 PM UTC-4:30, G Z wrote:
>
> so im using the following java script
>
> var cpuChart = document.getElementById('cpu').getContext('2d');
> new Chart(cpuChart).Line(cpuData,{
> bezierCurve: false,
> datasetFill : false,
> legendTemplate : "-legend\"><% 
> for (var i=0; i style=\"background-color:<%=datasets[i].lineColor%>\"><%if(datasets[i].label){%><%=datasets[i].label%><%}%><%}%>"
> 
> });
>
> django will see the % signs and think it is block content as it says below 
> i copy and pasted the error, how i get django to ignore a section of my 
> code and not parse the tags for that section.
>
>
> Request Method:POSTRequest URL:http://127.0.0.1:8000/vmstats/Django 
> Version:1.6.5Exception Type:TemplateSyntaxErrorException Value:
>
> Invalid block tag: '>
> Exception 
> Location:/usr/local/lib/python2.7/dist-packages/django/template/base.py 
> in invalid_block_tag, line 332Python Executable:/usr/bin/pythonPython 
> Version:2.7.5Python Path:
>
> ['/home/grant/workspace/Django Projects/trunk/holon',
>  '/usr/lib/python2.7',
>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>  '/usr/lib/python2.7/lib-tk',
>  '/usr/lib/python2.7/lib-old',
>  '/usr/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages/PILcompat',
>  '/usr/lib/python2.7/dist-packages/gtk-2.0',
>  '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-client',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
>
> Server time:Wed, 30 Jul 2014 23:27:32 +
> Error during template rendering
>
> In template /home/grant/workspace/Django 
> Projects/trunk/holon/portal/templates/vmstats.html, error at line *162*
> Invalid block tag: '> document.getElementById('iops').getContext('2d'); 153 new 
> Chart(iopsChart).Line(iopsData,{ 154 bezierCurve: false, 155 datasetFill 
> : false, 156 }); 157 158 var cpuChart = 
> document.getElementById('cpu').getContext('2d'); 159 new 
> Chart(cpuChart).Line(cpuData,{ 160 bezierCurve: false, 161 datasetFill : 
> false, 162 legendTemplate : " class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; 
> i style=\"background-color:<%=datasets[i].lineColor%>\"><%if(datasets[i].label){%><%=datasets[i].label%><%}%><%}%>"
>  
> 163 164 }); 165 }
>

-- 
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/35781377-7220-4559-a417-45d23417fa55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: update a field of a related table on form save

2014-07-30 Thread Brad Rice
Thank you both for those suggestions. I got Tundebazby's to work as it was 
closest to what I was doing. I'll have to study the post_save some more.

On Wednesday, July 30, 2014 2:33:57 AM UTC-4, Tundebabzy wrote:
>
> Hi Brad, my response is inline
>
> On 30 Jul 2014 02:26, "Brad Rice"  wrote:
> >
> > I have three tables. The first one is application which has a flag for 
> if an app has been submitted as well as created date and modified date. The 
> other two tables relate to the application table. I have two forms that get 
> update those tables. What I want to do is update the application modified 
> date from the save on the other forms.
> >
> > I have this in the Application model
> > modified= models.DateTimeField(auto_now_add=True)
> >
> > but since it is the other tables I am saving to, I'm not sure how to 
> update that field whenever the other two tables update.
> >
> > My view for one of the forms looks like this:
> >
> > class AnswersUpdate(UpdateView):
> > model = Answers
> > form_class = AnswersForm
> > slug_field = 'created_by'
> > template_name = 'requestform/applicant_form.html'
> >
> > @method_decorator(login_required(login_url='/accounts/login/'))
> > def dispatch(self, *args, **kwargs):
> > return super(AnswersUpdate, self).dispatch(*args, **kwargs)
> >
> > def get_object(self, queryset=None):
> > return Answers.objects.get(created_by=self.request.user)
> >
> > def form_valid(self, form):
> > obj = form.save(commit=False)
> > obj.created_by = self.request.user
> > obj.save()
> > a = Application.objects.get(created_by=self.request.user)
> >## how do I save to the Application here?
>
> #if its a new record, something like 
> application =  Application.objects.create(...)
>
> #if you are updating a record, something like...
> application = Application.objects.get(...) # can throw exception
> application.field_name = something
> application.save ()
>
> > return HttpResponseRedirect(reverse('requestform:app_check', 
> kwargs={'app_id': obj.id}))
> >
> > Any help would be appreciated.
> >
> > --
> > 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/2a2b6f24-b4c2-4575-9a52-85a892256c79%40googlegroups.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>

-- 
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/99b2a53f-5388-4b90-8313-7e7c29f9ce60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: running script in django database

2014-07-30 Thread alghafli

Jirka, aRkadeFR,
Thank you very much. I was able to create the command successfully.

Regards,
Mohammad

On الأربعاء 30 تـمـوز 2014 22:41, aRkadeFR wrote:

Agree with Jirka,

I'm just adding the link:
https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/

On 30/07/14 07:53, jirka.vejra...@gmail.com wrote:

Hi Mohammad,

   this can be easily achieved using a custom management command - check the 
Django documentation.

   HTH

 Jirka
  
-Original Message-

From: alghafli 
Sender: django-users@googlegroups.com
Date: Wed, 30 Jul 2014 07:02:59
To: 
Reply-To: django-users@googlegroups.com
Subject: running script in django database

Hello,
I made a library application using django 1.6. currently I only need to
populate the database. at the beginning, it is easier to write the
information in a csv file and import it using a script.

the script is running fine if I use manage.py shell and import the
necessary file and call the necessary function. however, I want to make
the script run from the system commandline rather than from the python
interpreter since it is easier to pass arguments to it. I could not find
a way in the manage.py documentation page.

Is it possible?

thank you,
Mohammad

--
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/53D86E73.9060806%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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/417657233-1406705276-cardhu_decombobulator_blackberry.rim.net-1073591500-%40b4.c3.bise7.blackberry.
For more options, visit https://groups.google.com/d/optout.


--
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/53D98587.3030602%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to call a function when a project starts.

2014-07-30 Thread Mike Dewhirst

On 31/07/2014 5:57 AM, Chen Xu wrote:

Hi Everyone:
I would like to call a function when my project starts, basically I want
to call a do_something() when I run python manage.py runserver. However,
when I put it into settings.py, it gets called twice, but I only want it
to execute once.

Is there a good way to do it.


Maybe you could turn do_something() a singleton so it only executes once?

http://stackoverflow.com/questions/6760685/creating-a-singleton-in-python






Thanks


--
âš¡ Chen Xu âš¡

--
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/CACac-qbTXbMGmYU%3D5R618rbt7pT%3DgTL%3DWAxhCR-prmuLbz-VKw%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.


--
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/53D97FE6.3000301%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


How do I get Django to ignore javascript code because its throwing an exception

2014-07-30 Thread G Z
so im using the following java script

var cpuChart = document.getElementById('cpu').getContext('2d');
new Chart(cpuChart).Line(cpuData,{
bezierCurve: false,
datasetFill : false,
legendTemplate : "-legend\"><% 
for (var i=0; i\"><%if(datasets[i].label){%><%=datasets[i].label%><%}%><%}%>"

});

django will see the % signs and think it is block content as it says below 
i copy and pasted the error, how i get django to ignore a section of my 
code and not parse the tags for that section.


Request Method:POSTRequest URL:http://127.0.0.1:8000/vmstats/Django Version:
1.6.5Exception Type:TemplateSyntaxErrorException Value:

Invalid block tag: '><% for (var i=0; 
i\"><%if(datasets[i].label){%><%=datasets[i].label%><%}%><%}%>"
 
163 164 }); 165 }

-- 
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/74a6c57b-a810-4ea4-b5fb-c2961f097fbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to call a function when a project starts.

2014-07-30 Thread Chen Xu
I am running 1.6.2


On Wed, Jul 30, 2014 at 4:02 PM, aRkadeFR  wrote:

> Which version of Django are you running?
>
> On 30/07/14 15:46, Chen Xu wrote:
> > Hi Everyone:
> > I would like to call a function when my project starts, basically I want
> to
> > call a do_something() when I run python manage.py runserver. However,
> when
> > I put it into settings.py, it gets called twice, but I only want it to
> > execute once.
> >
> > Is there a good way to do it.
> >
> > Thanks
> >
> >
> > --
> > ⚡ Chen Xu ⚡
> >
> > --
> > 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/CACac-qbTXbMGmYU%3D5R618rbt7pT%3DgTL%3DWAxhCR-prmuLbz-VKw%40mail.gmail.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> 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/20140730200231.GD2235%40rkade-thinkpad
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
⚡ Chen Xu ⚡

-- 
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/CACac-qaxCtB-5R67fJpoo0xjhGzHw91PrS4qGb_aiUxiOmQF%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to call a function when a project starts.

2014-07-30 Thread aRkadeFR
Which version of Django are you running?

On 30/07/14 15:46, Chen Xu wrote:
> Hi Everyone:
> I would like to call a function when my project starts, basically I want to
> call a do_something() when I run python manage.py runserver. However, when
> I put it into settings.py, it gets called twice, but I only want it to
> execute once.
> 
> Is there a good way to do it.
> 
> Thanks
> 
> 
> -- 
> ⚡ Chen Xu ⚡
> 
> -- 
> 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/CACac-qbTXbMGmYU%3D5R618rbt7pT%3DgTL%3DWAxhCR-prmuLbz-VKw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/20140730200231.GD2235%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


How to call a function when a project starts.

2014-07-30 Thread Chen Xu
Hi Everyone:
I would like to call a function when my project starts, basically I want to
call a do_something() when I run python manage.py runserver. However, when
I put it into settings.py, it gets called twice, but I only want it to
execute once.

Is there a good way to do it.

Thanks


-- 
⚡ Chen Xu ⚡

-- 
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/CACac-qbTXbMGmYU%3D5R618rbt7pT%3DgTL%3DWAxhCR-prmuLbz-VKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: running script in django database

2014-07-30 Thread aRkadeFR
Agree with Jirka,

I'm just adding the link:
https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/

On 30/07/14 07:53, jirka.vejra...@gmail.com wrote:
> 
> Hi Mohammad,
> 
>   this can be easily achieved using a custom management command - check the 
> Django documentation.
> 
>   HTH
> 
> Jirka
>  
> -Original Message-
> From: alghafli 
> Sender: django-users@googlegroups.com
> Date: Wed, 30 Jul 2014 07:02:59 
> To: 
> Reply-To: django-users@googlegroups.com
> Subject: running script in django database
> 
> Hello,
> I made a library application using django 1.6. currently I only need to 
> populate the database. at the beginning, it is easier to write the 
> information in a csv file and import it using a script.
> 
> the script is running fine if I use manage.py shell and import the 
> necessary file and call the necessary function. however, I want to make 
> the script run from the system commandline rather than from the python 
> interpreter since it is easier to pass arguments to it. I could not find 
> a way in the manage.py documentation page.
> 
> Is it possible?
> 
> thank you,
> Mohammad
> 
> -- 
> 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/53D86E73.9060806%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> 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/417657233-1406705276-cardhu_decombobulator_blackberry.rim.net-1073591500-%40b4.c3.bise7.blackberry.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/20140730194130.GC2235%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 - What are you most excited about?

2014-07-30 Thread aRkadeFR
Definitely the schema migration :)

I enjoy lots the App Loading and the Check framework too.

On 29/07/14 18:12, Ryan Blunden wrote:
> Hi everyone,
> 
> I'm giving a lightening talk at the San Francisco Django meetup tomorrow 
> night about some of the awesome new features in Django 1.7.
> 
> I wanted to highlight not just what *I think* are the best new features, 
> but what members of the community are most excited about.
> 
> Would be great to hear from the Django core contributors too.
> 
> Thanks also Django Devs for getting RC 2 up in time for my talk, brilliant 
> timing there!
> 
> -- 
> 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/afb4376a-853d-46df-8db3-e37e5740d91b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/20140730193920.GB2235%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Re: simultaneously submit three forms on the same page

2014-07-30 Thread aRkadeFR
Excellent.

Thanks for the share.

How backward compatible is it?

On 29/07/14 17:51, Santiago Lamora wrote:
> 2014-07-29 16:50 GMT+02:00 John :
> 
> > How can one submit 3 forms simultaneously?? Even ajax, is on by one!
> >
> >
> Quotting
> https://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms
> > You can put several Django forms inside one  tag. To give each Form 
> > its
> own namespace, use the prefix keyword argument:
> 
> -- 
> 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/CAEaW5xwy2cimDTTv%3DAUyfEeDrcK6xTtDfQ4AC1jXD-u%3DDNMU9A%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/20140730193332.GA2235%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Get latest timestamp+value from each group

2014-07-30 Thread Joshua Lyon
I have a basic Django application which uses sqlite as a backend on low-end 
hardware (eg. Raspberry Pi). I have the RPi collecting sensor data and 
logging it. I am trying to get the last process value, timestamp, and 
associated sensor name in an efficient way, but can't seem to figure it out 
with the Django ORM.

*models.py*
class Device(models.Model):
name = models.CharField(max_length=30)


class Log(models.Model):
timestamp = models.IntegerField()
value = models.FloatField()

device = models.ForeignKey(Device)


class Meta:
unique_together = ("timestamp", "device")

The following works, but is inefficient as it requires multiple SQL calls 
(one to start and then one for each device):
devices = Device.objects.all()

series = []
for device in devices:
log = Log.objects.filter(mapping_id=device.id).latest("timestamp")
series.append({"name": device.name,
   "timestamp": log.timestamp,
   "value": log.value})


I have searched around and it seems the annotate() method might be able to 
help, but I can't seem to figure out how to get the associated value along 
with the max timestamp:
Log.objects.values("device__name").annotate(timestamp=Max("timestamp"))  # 
missing log value!
  # or
Device.objects.annotate(timestamp=Max("log__timestamp"))  # missing log 
value!


-- 
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/63483849-8057-431c-aa5b-3560ea17fdf9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Flup vs Guicorn vs uWsgi on Nginx

2014-07-30 Thread Roberto De Ioris

> Hi Folks,
>   We are in our initial deployment stage, and have decided to deploy
> django(1.6.X) on Nginx, and trying to decide which WSGI server to use.
>   I am positive all have something to offer and may not be fair just to
> throw out "which one to use", but I was hoping to get some guidance on the
> following items

Unfortunately no-one can give you a satisfing answer, because lot of
things come into play. I will focus on uWSGI and gunicorn as flup is
basically a dead project (afaik)

>
> 0. Handle high concurrent requests

both uWSGI and gunicorn support multiprocessing. As you are using django i
will not suggest you using async approaches (like gevent) even if both
support them.

uWSGI has strong multithreading support too, and gunicorn is working on it
(probably should be ready in the next release). If you are app is not
cpu-bound, multiple threads are a good solution in python (i bet you will
find tons of posts regarding the infamous GIL, but you can ignore them, as
the GIL is released during I/O operations)

In both threads and multiprocessing, do not choose their number using
silly math (like cpu * 2). Start with a low-number (like 4) and constantly
monitor your app to see if you need to raise or decrease them. New-relic
could be a great toy for it.

> 1. Performance / less transnational overhead,

this is nothing related to WSGI servers, your app will be the bottleneck.
Always.

> 2. Compatible with django/Nginx, in a sense easy configuration

both have now pretty decent documentation for newbies, but gunicorn is way
simpler from an architectural point of view, so probably you will find
easier to start with it.
On the other side uWSGI is more sysadmin-oriented so it has dozens of
features for app monitoring and to manage and detect critical conditions.

> 3. Large number of users

with mod_wsgi they are the three most used servers, so i would not waste
time on this point. There is a lot of documentation about all of them. And
remember you can proxy an apache+mod_wsgi in embedded mode behind nginx
too. Lot of users prefer this approach.

Apache can be a good application server.

(disclaimer: i am the uWSGI lead developer)

-- 
Roberto De Ioris
http://unbit.it

-- 
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/eef4aa58de830c3e68a4a0eeaf7bc66f.squirrel%40manage.unbit.it.
For more options, visit https://groups.google.com/d/optout.


Re: Access to custom fields in view?

2014-07-30 Thread Ryan Blunden
I would use the @property decorator.

class template(models.Model):
... 
 
@property
def responsive(self):

try:
responsive = templates_propiedad.objects.get(propiedad="features", 
valor="responsive", plantilla=self)
salida = "1"
except:
salida = "0"
return salida

@property
def engine(self):
try:
engine = 
templates_propiedad.objects.get(propiedad="prestashop-compatibility", 
plantilla=self)
salida = engine.valor
except:
salida = "0"
return salida

On Wednesday, July 30, 2014 at 11:02 AM, Miguel Angel Yáñez Camacho wrote:

> Hi all from spain and sorry for my bad english ;)
>  
> Hi a have in this model 2 custom fields: "responsive" and "engine"
>  
> class template(models.Model):
> state = models.IntegerField()  # estado del template 1= activo, 0= 
> inactivo
> tid = models.IntegerField(primary_key=True)
> price = models.IntegerField()  # precio unidad
> priceexc = models.IntegerField()  # precio exclusivo
> inserted_date = models.DateTimeField(null=True, blank=True)
> update_date = models.DateTimeField(null=True, blank=True)
> live_preview_url = models.CharField(max_length=1000, null=True, 
> blank=True)
> tipo = models.ForeignKey(tipo)
> keywords = models.CharField(max_length=9000, null=True, blank=True)
> screen_preview_s = models.CharField(max_length=1000, null=True, 
> blank=True)
> screen_preview_l = models.CharField(max_length=1000, null=True, 
> blank=True)
> origen = models.ForeignKey(origen)
> url_compra = models.CharField(max_length=1000, null=True, blank=True)
> promocionada = models.BooleanField(default=False)
> portada = models.BooleanField(default=False)
>  
> def __unicode__(self):
> return self.live_preview_url
>  
> def _get_responsive(self):
>  
> try:
> responsive = 
> templates_propiedad.objects.get(propiedad="features", valor="responsive", 
> plantilla=self)
> salida = "1"
> except:
> salida = "0"
> return salida
> responsive = property(_get_responsive)
>  
> def _get_engine(self):
> try:
> engine = 
> templates_propiedad.objects.get(propiedad="prestashop-compatibility", 
> plantilla=self)
> salida = engine.valor
> except:
> salida = "0"
> return salida
>  
> engine = property(_get_engine)
> in my view in this code i can access to a regular field but i CANT access to 
> custom fields, give me error
> plantillas_db = 
> templates_keyword.objects.select_related('plantilla').filter(keyword=bd_keywordsfinal,
>  plantilla__state='1', 
> plantilla__promocionada=False).distinct().order_by('-plantilla__inserted_date')
>  
> s = set(plantillas_db)
> for i in s:
> print(i.id)
> print(i.responsive)
> print(i.engine)
> How can i access to this fields?
> thanks
>  
> Miguel
> --  
> 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 
> (mailto:django-users+unsubscr...@googlegroups.com).
> To post to this group, send email to django-users@googlegroups.com 
> (mailto: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/6177a2f8-f2d7-4b88-bc83-fc2d9bccf284%40googlegroups.com
>  
> (https://groups.google.com/d/msgid/django-users/6177a2f8-f2d7-4b88-bc83-fc2d9bccf284%40googlegroups.com?utm_medium=email_source=footer).
> For more options, visit https://groups.google.com/d/optout.

-- 
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/5ABC7736D24A460AB3DCD6207E103EE4%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Access to custom fields in view?

2014-07-30 Thread Miguel Angel Yáñez Camacho
Hi all from spain and sorry for my bad english ;)

Hi a have in this model 2 custom fields: "responsive" and "engine"

class template(models.Model):
state = models.IntegerField()  # estado del template 1= activo, 0= 
inactivo
tid = models.IntegerField(primary_key=True)
price = models.IntegerField()  # precio unidad
priceexc = models.IntegerField()  # precio exclusivo
inserted_date = models.DateTimeField(null=True, blank=True)
update_date = models.DateTimeField(null=True, blank=True)
live_preview_url = models.CharField(max_length=1000, null=True, blank=
True)
tipo = models.ForeignKey(tipo)
keywords = models.CharField(max_length=9000, null=True, blank=True)
screen_preview_s = models.CharField(max_length=1000, null=True, blank=
True)
screen_preview_l = models.CharField(max_length=1000, null=True, blank=
True)
origen = models.ForeignKey(origen)
url_compra = models.CharField(max_length=1000, null=True, blank=True)
promocionada = models.BooleanField(default=False)
portada = models.BooleanField(default=False)

def __unicode__(self):
return self.live_preview_url

def _get_responsive(self):

try:
responsive = templates_propiedad.objects.get(propiedad=
"features", valor="responsive", plantilla=self)
salida = "1"
except:
salida = "0"
return salida
responsive = property(_get_responsive)

def _get_engine(self):
try:
engine = templates_propiedad.objects.get(propiedad=
"prestashop-compatibility", plantilla=self)
salida = engine.valor
except:
salida = "0"
return salida

engine = property(_get_engine)

in my view in this code i can access to a regular field but i CANT access 
to custom fields, give me error
plantillas_db = templates_keyword.objects.select_related(
'plantilla').filter(keyword=bd_keywordsfinal, plantilla__state='1', 
plantilla__promocionada=False).distinct().order_by(
'-plantilla__inserted_date')

s = set(plantillas_db)
for i in s:
print(i.id)
print(i.responsive)
print(i.engine)

How can i access to this fields?
thanks

Miguel

-- 
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/6177a2f8-f2d7-4b88-bc83-fc2d9bccf284%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Flup vs Guicorn vs uWsgi on Nginx

2014-07-30 Thread Estifanos Gebrehiwot
Hi Folks,
  We are in our initial deployment stage, and have decided to deploy 
django(1.6.X) on Nginx, and trying to decide which WSGI server to use.
  I am positive all have something to offer and may not be fair just to 
throw out "which one to use", but I was hoping to get some guidance on the 
following items

0. Handle high concurrent requests
1. Performance / less transnational overhead,
2. Compatible with django/Nginx, in a sense easy configuration
3. Large number of users

Or any other measurement you think is important to consider.

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/ee75c0a3-d02a-4742-b152-a89b705692ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 - What are you most excited about?

2014-07-30 Thread Ryan Blunden
Thanks Marc and Russ for your replies, greatly appreciated.

Here are my favorites:

App Loading
Applications can run code at startup, before Django does anything else, with 
the ready() method of their configuration.
Apps now don’t need a models.py to be a valid app.
Applications can be given a verbose_name for the admin.
autodiscover() no longer needed, Django calls this automatically.


System check framework
./manage.py check. Many times, validate would pass but the app would crash once 
started. I’ve noticed this to be much more robust.


Admin
You can now implement site_header, site_title, and index_title attributes on a 
custom AdminSite in order to easily change the admin site’s page title and 
header text. No more needing to override templates!
@register decorator to register a ModelAdmin.
ModelAdmin.list_display_links = None to disable links on the change list page 
grid.


Auth
django.contrib.auth.views.password_reset() takes an optional 
html_email_template_name parameter used to send a multipart HTML email for 
password resets.


Email
send_mail() now accepts an html_message parameter for sending a multipart 
text/plain and text/html email.


Managers
Better Managers by subleasing QuerySet and using query set.as_manager()


Templates
The new truncatechars_html filter truncates a string to be no longer than the 
specified number of characters, taking HTML into account.  


Requests and responses
The new JsonResponse subclass  






On Wednesday, July 30, 2014 at 9:41 AM, Ryan Blunden wrote:

> Hi Carlos,
>  
> I’ve read all the release notes and already have my short list of what I 
> think the best features are. But this will be heavily skewed towards the 
> types of Django apps I create and how I use Django.
>  
> I wanted to know what the Django community thought were the best new features.
>  
> Speaking of which, which is your favorite new feature?  
>  
> On Tuesday, July 29, 2014 at 7:08 PM, carlos wrote:
>  
> > Hi maybe you need read the release note Django 1.7 about the new features
> > https://docs.djangoproject.com/en/dev/releases/1.7/
> >  
> > Cheers :)
> >  
> >  
> > On Tue, Jul 29, 2014 at 7:31 PM, Ryan Blunden  > (mailto:ryan.blun...@gmail.com)> wrote:
> > > Hi everyone,
> > >  
> > > I'm giving a lightening talk at the San Francisco Django meetup tomorrow 
> > > night about some of the awesome new features in Django 1.7.  
> > >  
> > > I wanted to highlight not just what I think are the best new features, 
> > > but what members of the community are most excited about.
> > >  
> > > Would be great to hear from the Django core contributors too.  
> > >  
> > > Thanks also Django Devs for getting RC 2 up in time for my talk, 
> > > brilliant timing there!  
> > >  
> > > --  
> > > 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 
> > > (mailto:django-users+unsubscr...@googlegroups.com).
> > > To post to this group, send email to django-users@googlegroups.com 
> > > (mailto: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/afb4376a-853d-46df-8db3-e37e5740d91b%40googlegroups.com
> > >  
> > > (https://groups.google.com/d/msgid/django-users/afb4376a-853d-46df-8db3-e37e5740d91b%40googlegroups.com?utm_medium=email_source=footer).
> > > For more options, visit https://groups.google.com/d/optout.
> >  
> > --  
> > 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 
> > (mailto:django-users+unsubscr...@googlegroups.com).
> > To post to this group, send email to django-users@googlegroups.com 
> > (mailto: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/CAM-7rO1np13wV_vnuWSCmqeA9oaksdD1MnZFnQz7K2qpNP0yyQ%40mail.gmail.com
> >  
> > (https://groups.google.com/d/msgid/django-users/CAM-7rO1np13wV_vnuWSCmqeA9oaksdD1MnZFnQz7K2qpNP0yyQ%40mail.gmail.com?utm_medium=email_source=footer).
> > For more options, visit https://groups.google.com/d/optout.
>  

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

Re: Django 1.7 - What are you most excited about?

2014-07-30 Thread Ryan Blunden
Hi Carlos,

I’ve read all the release notes and already have my short list of what I think 
the best features are. But this will be heavily skewed towards the types of 
Django apps I create and how I use Django.

I wanted to know what the Django community thought were the best new features.

Speaking of which, which is your favorite new feature?  


On Tuesday, July 29, 2014 at 7:08 PM, carlos wrote:

> Hi maybe you need read the release note Django 1.7 about the new features
> https://docs.djangoproject.com/en/dev/releases/1.7/
>  
> Cheers :)
>  
>  
> On Tue, Jul 29, 2014 at 7:31 PM, Ryan Blunden  (mailto:ryan.blun...@gmail.com)> wrote:
> > Hi everyone,
> >  
> > I'm giving a lightening talk at the San Francisco Django meetup tomorrow 
> > night about some of the awesome new features in Django 1.7.  
> >  
> > I wanted to highlight not just what I think are the best new features, but 
> > what members of the community are most excited about.
> >  
> > Would be great to hear from the Django core contributors too.  
> >  
> > Thanks also Django Devs for getting RC 2 up in time for my talk, brilliant 
> > timing there!  
> >  
> > --  
> > 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 
> > (mailto:django-users+unsubscr...@googlegroups.com).
> > To post to this group, send email to django-users@googlegroups.com 
> > (mailto: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/afb4376a-853d-46df-8db3-e37e5740d91b%40googlegroups.com
> >  
> > (https://groups.google.com/d/msgid/django-users/afb4376a-853d-46df-8db3-e37e5740d91b%40googlegroups.com?utm_medium=email_source=footer).
> > For more options, visit https://groups.google.com/d/optout.
>  
> --  
> 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 
> (mailto:django-users+unsubscr...@googlegroups.com).
> To post to this group, send email to django-users@googlegroups.com 
> (mailto: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/CAM-7rO1np13wV_vnuWSCmqeA9oaksdD1MnZFnQz7K2qpNP0yyQ%40mail.gmail.com
>  
> (https://groups.google.com/d/msgid/django-users/CAM-7rO1np13wV_vnuWSCmqeA9oaksdD1MnZFnQz7K2qpNP0yyQ%40mail.gmail.com?utm_medium=email_source=footer).
> For more options, visit https://groups.google.com/d/optout.

-- 
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/91F231DB9F5B470BA3A6A9B99D49A7BB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Static Files not Loading

2014-07-30 Thread marc
Hi,

STATIC_PATH should be STATIC_ROOT.

Cheers

Am Mittwoch, 30. Juli 2014 17:10:17 UTC+2 schrieb Steven Williams:
>
> -BEGIN PGP SIGNED MESSAGE- 
> Hash: SHA1 
>
> Hi, 
>
> I just asked around on IRC and no one was able to help me. Also the 
> entries on StackOverflow are not that helpful in my situation either. 
>
> Right now I am unable to access my static content in my project. Going 
> to 127.0.0.1:8000/static/rango.jpg yields a 404 error message. This is 
> a development environment where I am just learning the framework using 
> Tango with Django. My system is running Fedora 20 with Django 1.6 
> installed. 
>
> This is my settings.py paste https://dpaste.de/pU40 
>
> Any help would be greatly appreciated. 
>
> - -- 
> Steven Williams 
> My PGP Key 
> http://pgp.mit.edu/pks/lookup?op=get=0xCACA6C74669A54FA 
> -BEGIN PGP SIGNATURE- 
> Version: GnuPG v1 
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ 
>
> iQIcBAEBAgAGBQJT2QqDAAoJEMrKbHRmmlT63vUP/RQ7jyVgXLc0EYoJKE84Tfg4 
> 84IqEaXHgT709J2ChZYpQjRLpsm/7IYbJt/JDXQzW4+E67AMOwqjHyPzlLWUaaD2 
> auqbCLmebeUXB8Et8r0k8eATU9cW+edmRrcoVi2ZmO/dXR+NqEZigGq4nPfFjUac 
> lFYpfYlxKmFT8vht/er3ftR5ADC4MLohG42W48NIyHe//tTijDFj5ZBV6Zb94Y3p 
> 46me03yXimSQVpdq7ZPMGe5zVo+TL/QoEpZlipGglo1+3WPzK37ZkW7YRv1l6tb/ 
> thBx2lRAWHoOpQdtOjklYZaXJtf/yKVF+E831N8BTuPKbQu3gHVms7nxB3fKu/hs 
> VJ1CH3aSslw1ndZLX2Ll4CVCjnk33QrAu+ruu+lexOsLDG/SLupLpakcAMhqW3BZ 
> yxWSl+s/RypL21VsNv6wQC2JT/DKZrCWxtL6/yOE6/OnvOtzh3f8YwtwiQGmAsT7 
> tjd5pU/Qh4mgv4P6aL5STpVws5RMgVVSV/p25RYYtDnLf47MrNZNv+0c4DUrrKSj 
> xlYeIwm0M8mGQR8nBg8NPCOhcRrrh79zjKMrB7cm6r9M+UBxZINyeG9NelsD7Zb/ 
> jaXtvbOqoHYVzbci81skpQPxtgf6c6wjrgwckVcWaXRFnXZWisFJH6sjjDAS5jW2 
> GW8Y3CmUlEiJR5RUG7gp 
> =fRvw 
> -END PGP SIGNATURE- 
>

-- 
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/9e08cc43-65e2-47cb-98ea-3b73dc490d0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Static Files not Loading

2014-07-30 Thread Steven Williams
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I just asked around on IRC and no one was able to help me. Also the
entries on StackOverflow are not that helpful in my situation either.

Right now I am unable to access my static content in my project. Going
to 127.0.0.1:8000/static/rango.jpg yields a 404 error message. This is
a development environment where I am just learning the framework using
Tango with Django. My system is running Fedora 20 with Django 1.6
installed.

This is my settings.py paste https://dpaste.de/pU40

Any help would be greatly appreciated.

- -- 
Steven Williams
My PGP Key
http://pgp.mit.edu/pks/lookup?op=get=0xCACA6C74669A54FA
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJT2QqDAAoJEMrKbHRmmlT63vUP/RQ7jyVgXLc0EYoJKE84Tfg4
84IqEaXHgT709J2ChZYpQjRLpsm/7IYbJt/JDXQzW4+E67AMOwqjHyPzlLWUaaD2
auqbCLmebeUXB8Et8r0k8eATU9cW+edmRrcoVi2ZmO/dXR+NqEZigGq4nPfFjUac
lFYpfYlxKmFT8vht/er3ftR5ADC4MLohG42W48NIyHe//tTijDFj5ZBV6Zb94Y3p
46me03yXimSQVpdq7ZPMGe5zVo+TL/QoEpZlipGglo1+3WPzK37ZkW7YRv1l6tb/
thBx2lRAWHoOpQdtOjklYZaXJtf/yKVF+E831N8BTuPKbQu3gHVms7nxB3fKu/hs
VJ1CH3aSslw1ndZLX2Ll4CVCjnk33QrAu+ruu+lexOsLDG/SLupLpakcAMhqW3BZ
yxWSl+s/RypL21VsNv6wQC2JT/DKZrCWxtL6/yOE6/OnvOtzh3f8YwtwiQGmAsT7
tjd5pU/Qh4mgv4P6aL5STpVws5RMgVVSV/p25RYYtDnLf47MrNZNv+0c4DUrrKSj
xlYeIwm0M8mGQR8nBg8NPCOhcRrrh79zjKMrB7cm6r9M+UBxZINyeG9NelsD7Zb/
jaXtvbOqoHYVzbci81skpQPxtgf6c6wjrgwckVcWaXRFnXZWisFJH6sjjDAS5jW2
GW8Y3CmUlEiJR5RUG7gp
=fRvw
-END PGP SIGNATURE-

-- 
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/53D90A83.7040801%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


hanging django/postgres idle connections

2014-07-30 Thread Jani Kajala
Hi,

I have a problem with leaking Postgres DB connections even if I 
have CONN_MAX_AGE=0. Every time I start the server and stop it by 
Ctrl+Break a DB connection is leaked.

When I check from Postgres there is bunch of "idle" connections with 
following content:
SELECT "django_migrations"."app", "django_migrations"."name" FROM 
"django_migrations"

I'm running Python on Windows 8 + virtualenv with following installs:
Django==1.7c1
future==0.12.4
psycopg2==2.5.3
python3-memcached==1.51
pytz==2014.4
six==1.7.3
sqlparse==0.1.11
virtualenv==1.11.6
xlwt-future==0.8.0

Postgres is running in Ubuntu 14.04 in latest Oracle VirtualBox on same 
Windows machine.

Any ideas?


Thanks,
Jani

-- 
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/ca9e4347-7e0c-4b34-8abc-625e6d600c4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: internationalization (i18n)

2014-07-30 Thread marc
Here's a list of locales in Django: 
https://github.com/django/django/tree/master/django/conf/locale

Am Mittwoch, 30. Juli 2014 14:47:03 UTC+2 schrieb ma...@tubeards.com:
>
> Hi,
>
> have a look at: http://www.i18nguy.com/unicode/language-identifiers.html
>
> The localization in django is based on region and language codes, some of 
> them are the same (like 'de') and some split (like 'en-us'). For 'mr' 
> you'll need to add the area code of india iirc.
>
> Cheers
>
> Am Mittwoch, 30. Juli 2014 14:31:37 UTC+2 schrieb Supriya Sawant:
>>
>>
>> Hello,
>>
>>   I am using internationalization feature in djnago framework.
>>
>>   In my setting.py I have following languages set:
>>
>> LANGUAGES = (
>> ('de', ugettext('German')),('en', ugettext('English')),('mr', 
>> ugettext('Marathi')),('mwr', ugettext('Marwari')),('mun', ugettext\
>> ('Munda')),('ne', ugettext('Nepali')),('ori', ugettext('Oriya')),('pi', 
>> ugettext('Pali')),('pa', ugettext('Panjabi')),('raj', ugette\
>> xt('Rajasthani')),('sa', ugettext('Sanskrit')),('sat', 
>> ugettext('Santali')),('sd', ugettext('Sindhi')),('ta', 
>> ugettext('Tamil')),('t\
>> e', ugettext('Telugu')),('ur', ugettext('Urdu')),('as', 
>> ugettext('Assamese')),('awa', ugettext('Awadhi')),('ber', 
>> ugettext('Bengali'\
>> )),('bho', ugettext('Bhojpuri')),('bh', ugettext('Bihari')),('bra', 
>> ugettext('Braj')),('gon', ugettext('Gondi')),('dra', ugettext('D\
>> ravidian')),('gu', ugettext('Gujarati')),('en', 
>> ugettext('English')),('him', ugettext('Himachali')),('hi', 
>> ugettext('Hindi')),('kn',\
>>  ugettext('Kannada')),('ks', ugettext('Kashmiri')),('kha', 
>> ugettext('Khasi')),('kok', ugettext('konkani')),('kru', ugettext('Kurukh'\
>> )),('lah', ugettext('Lahnda')),('lus', ugettext('Lushai')),('mag', 
>> ugettext('Magahi')),('mai', ugettext('Maithili')),('mi', ugettext\
>> ('Malayalam')),('mni', ugettext('Manipuri')),('fr', 
>> ugettext('French')),('ja', ugettext('Japanese')),('da', 
>> ugettext('Danish')),('es\
>> ', ugettext('Spanish')),('it', ugettext('Italian')),('ru', 
>> ugettext('Russian')),
>>
>> I  have created th po file .
>>
>> but while runserver I am getting following error:
>>
>> raise KeyError("Unknown language code %s." % lang_code)
>> KeyError: u'Unknown language code mr.'
>>
>> what would be the reason.
>>
>

-- 
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/20a3ac7f-3976-4e1a-b2a9-8377440794b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: internationalization (i18n)

2014-07-30 Thread marc
Hi,

have a look at: http://www.i18nguy.com/unicode/language-identifiers.html

The localization in django is based on region and language codes, some of 
them are the same (like 'de') and some split (like 'en-us'). For 'mr' 
you'll need to add the area code of india iirc.

Cheers

Am Mittwoch, 30. Juli 2014 14:31:37 UTC+2 schrieb Supriya Sawant:
>
>
> Hello,
>
>   I am using internationalization feature in djnago framework.
>
>   In my setting.py I have following languages set:
>
> LANGUAGES = (
> ('de', ugettext('German')),('en', ugettext('English')),('mr', 
> ugettext('Marathi')),('mwr', ugettext('Marwari')),('mun', ugettext\
> ('Munda')),('ne', ugettext('Nepali')),('ori', ugettext('Oriya')),('pi', 
> ugettext('Pali')),('pa', ugettext('Panjabi')),('raj', ugette\
> xt('Rajasthani')),('sa', ugettext('Sanskrit')),('sat', 
> ugettext('Santali')),('sd', ugettext('Sindhi')),('ta', 
> ugettext('Tamil')),('t\
> e', ugettext('Telugu')),('ur', ugettext('Urdu')),('as', 
> ugettext('Assamese')),('awa', ugettext('Awadhi')),('ber', 
> ugettext('Bengali'\
> )),('bho', ugettext('Bhojpuri')),('bh', ugettext('Bihari')),('bra', 
> ugettext('Braj')),('gon', ugettext('Gondi')),('dra', ugettext('D\
> ravidian')),('gu', ugettext('Gujarati')),('en', 
> ugettext('English')),('him', ugettext('Himachali')),('hi', 
> ugettext('Hindi')),('kn',\
>  ugettext('Kannada')),('ks', ugettext('Kashmiri')),('kha', 
> ugettext('Khasi')),('kok', ugettext('konkani')),('kru', ugettext('Kurukh'\
> )),('lah', ugettext('Lahnda')),('lus', ugettext('Lushai')),('mag', 
> ugettext('Magahi')),('mai', ugettext('Maithili')),('mi', ugettext\
> ('Malayalam')),('mni', ugettext('Manipuri')),('fr', 
> ugettext('French')),('ja', ugettext('Japanese')),('da', 
> ugettext('Danish')),('es\
> ', ugettext('Spanish')),('it', ugettext('Italian')),('ru', 
> ugettext('Russian')),
>
> I  have created th po file .
>
> but while runserver I am getting following error:
>
> raise KeyError("Unknown language code %s." % lang_code)
> KeyError: u'Unknown language code mr.'
>
> what would be the reason.
>

-- 
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/56de9898-9119-45fc-8abe-dd2f0ed91bfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to ride submit_line.html

2014-07-30 Thread Akshay Mukadam
Its not working

-- 
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/9543b28b-8fb7-4721-bb61-db667a6ab915%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


internationalization (i18n)

2014-07-30 Thread Supriya Sawant

Hello,

  I am using internationalization feature in djnago framework.
   
  In my setting.py I have following languages set:

LANGUAGES = (
('de', ugettext('German')),('en', ugettext('English')),('mr', 
ugettext('Marathi')),('mwr', ugettext('Marwari')),('mun', ugettext\
('Munda')),('ne', ugettext('Nepali')),('ori', ugettext('Oriya')),('pi', 
ugettext('Pali')),('pa', ugettext('Panjabi')),('raj', ugette\
xt('Rajasthani')),('sa', ugettext('Sanskrit')),('sat', 
ugettext('Santali')),('sd', ugettext('Sindhi')),('ta', 
ugettext('Tamil')),('t\
e', ugettext('Telugu')),('ur', ugettext('Urdu')),('as', 
ugettext('Assamese')),('awa', ugettext('Awadhi')),('ber', 
ugettext('Bengali'\
)),('bho', ugettext('Bhojpuri')),('bh', ugettext('Bihari')),('bra', 
ugettext('Braj')),('gon', ugettext('Gondi')),('dra', ugettext('D\
ravidian')),('gu', ugettext('Gujarati')),('en', 
ugettext('English')),('him', ugettext('Himachali')),('hi', 
ugettext('Hindi')),('kn',\
 ugettext('Kannada')),('ks', ugettext('Kashmiri')),('kha', 
ugettext('Khasi')),('kok', ugettext('konkani')),('kru', ugettext('Kurukh'\
)),('lah', ugettext('Lahnda')),('lus', ugettext('Lushai')),('mag', 
ugettext('Magahi')),('mai', ugettext('Maithili')),('mi', ugettext\
('Malayalam')),('mni', ugettext('Manipuri')),('fr', 
ugettext('French')),('ja', ugettext('Japanese')),('da', 
ugettext('Danish')),('es\
', ugettext('Spanish')),('it', ugettext('Italian')),('ru', 
ugettext('Russian')),

I  have created th po file .

but while runserver I am getting following error:

raise KeyError("Unknown language code %s." % lang_code)
KeyError: u'Unknown language code mr.'

what would be the reason.

-- 
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/aa7ef0b3-4702-4d41-aa24-04fffa7bfba5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to ride submit_line.html

2014-07-30 Thread marc
Hi,

have a look there: 
http://stackoverflow.com/questions/8442724/django-admin-disable-editing-and-remove-save-butttons-for-a-specific-model

Guess it is the right way to go.

Cheers

Am Mittwoch, 30. Juli 2014 13:32:18 UTC+2 schrieb Akshay Mukadam:
>
> How can we override the submit_line.html to disable the save buttons in 
> django admin site
>
> I have tried in following ways:
> 1-> Using Javascript
> 2->
> https://github.com/django/django/blob/master/django/contrib/admin/templatetags/admin_modify.py#L23
>  
> by overriding these link
>
> But I want to change it using change_view method
> how can I achieve that 
>
> Thank you 
> For Help
>

-- 
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/c12e72bb-5e59-48d7-827d-f65e4fe4fc4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: (ModelForm) confusion

2014-07-30 Thread marc
Hi,

you are calling 'is_valid' in your view, which should be an method call:

a_valid = aform.is_valid*()*
m_valid = mform.is_valid*()*
p_valid = pform.is_valid*()*


There where a few hooks in your view, for example: you check for 
'is_valid()' but there is no code to execute after. I've changed it a bit:

http://pastie.org/9431548

Am Mittwoch, 30. Juli 2014 08:59:15 UTC+2 schrieb Kamal Kaur:
>
> Greetings! 
>
> What I have done: 
> There are four tables, from which I have generated ModelForms. Getting 
> the WorkerDetails from one side, adding the salary and attendance 
> things from the other side as the view says. If there is at least one 
> row added in WorkerDetail table, then it directly asks to add the 
> salary and attendance things. Everything is being added perfectly but 
> I have to add that "ForeignKey" thing in every form. 
>
> Aim: 
> To design a page like this: 
> http://tinypic.com/r/feor5h/8 
>
> Query: 
> What I need to do to display forms like this and get the foreign key 
> attribute directly from the displayed list? Is what I have done right? 
> Is there some better approach to get this desired layout? 
>
> Required code: 
> models.py: http://pastie.org/9430952 
> forms.py : http://pastie.org/9430955 
> views.py : http://pastie.org/9430962 
>
>
>
> -- 
> Kamaljeet Kaur 
> I'm not what I'm compared to others, I'm what I'm compared to my 
> yesterday. 
>

-- 
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/83469e1b-9824-426e-8141-97465ef47202%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to create migration with Error - One or more models did not validate:

2014-07-30 Thread Subodh Nijsure
duh! Thank you so much... Sometimes when you are on short-sleep you
make silly mistakes!!

-Subodh

On Wed, Jul 30, 2014 at 4:54 AM,   wrote:
> Hi,
>
> you've added a relation to the AssetPollingConfig model which is not
> defined.
>
> Cheers
>
> Am Mittwoch, 30. Juli 2014 13:34:52 UTC+2 schrieb Subodh Nijsure:
>>
>> Hello,
>>
>> I have following model definition and when I try to create a migration
>> using command,  'python manage.py schemamigration asset_mgmt
>> --initial' I am getting following error:
>>
>> CommandError: One or more models did not validate:
>> asset_mgmt.alarmtable: 'polling_config' has a relation with model
>> AssetPollingConfig, which has either not been installed or is
>> abstract.
>>
>> I have other classes that extend the TimeStampedModel and I don't see
>> this error, can someone point me towards reason I am getting this
>> error?
>>
>>
>> class TimeStampedModel(models.Model):
>> created = models.DateTimeField(auto_now_add=True)
>> modified = models.DateTimeField(auto_now=True)
>> class Meta:
>> abstract = True
>>
>> class AssetPollingInfo(TimeStampedModel):
>> id = models.AutoField(primary_key=True)
>> alarm_text = models.CharField(max_length=800,blank=True,null=True)
>> asset_id = models.ForeignKey('AssetInfo')
>> thresholds = models.ForeignKey('ThresholdInfo')
>> dispatch = models.ForeignKey('AlarmDispatchInfo')
>> class Meta:
>> ordering = ['-id']
>> def __unicode__(self):
>> return str(self.id)
>>
>> class AlarmTable(TimeStampedModel):
>> id = models.AutoField(primary_key=True)
>> polling_config = models.ForeignKey('AssetPollingConfig')
>> alarm_text = models.CharField(max_length=800,blank=False,null=False)
>> event_type = models.SmallIntegerField(blank=False,null=False)
>> trigger_point = models.IntegerField(blank=True,null=True)
>> class Meta:
>> ordering = ['-id']
>> def __unicode__(self):
>> return str(self.id)
>>
>>
>> -Subodh
>
> --
> 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/5a541fa1-208f-40ce-92f7-89546872d8d5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/CALr9Q3YF1GrUt0DkumY80LijjPFdBzTb0RyQhjsaRUTdfU1AoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to create migration with Error - One or more models did not validate:

2014-07-30 Thread marc
Hi,

you've added a relation to the AssetPollingConfig model which is not 
defined. 

Cheers

Am Mittwoch, 30. Juli 2014 13:34:52 UTC+2 schrieb Subodh Nijsure:
>
> Hello, 
>
> I have following model definition and when I try to create a migration 
> using command,  'python manage.py schemamigration asset_mgmt 
> --initial' I am getting following error: 
>
> CommandError: One or more models did not validate: 
> asset_mgmt.alarmtable: 'polling_config' has a relation with model 
> AssetPollingConfig, which has either not been installed or is 
> abstract. 
>
> I have other classes that extend the TimeStampedModel and I don't see 
> this error, can someone point me towards reason I am getting this 
> error? 
>
>
> class TimeStampedModel(models.Model): 
> created = models.DateTimeField(auto_now_add=True) 
> modified = models.DateTimeField(auto_now=True) 
> class Meta: 
> abstract = True 
>
> class AssetPollingInfo(TimeStampedModel): 
> id = models.AutoField(primary_key=True) 
> alarm_text = models.CharField(max_length=800,blank=True,null=True) 
> asset_id = models.ForeignKey('AssetInfo') 
> thresholds = models.ForeignKey('ThresholdInfo') 
> dispatch = models.ForeignKey('AlarmDispatchInfo') 
> class Meta: 
> ordering = ['-id'] 
> def __unicode__(self): 
> return str(self.id) 
>
> class AlarmTable(TimeStampedModel): 
> id = models.AutoField(primary_key=True) 
> polling_config = models.ForeignKey('AssetPollingConfig') 
> alarm_text = models.CharField(max_length=800,blank=False,null=False) 
> event_type = models.SmallIntegerField(blank=False,null=False) 
> trigger_point = models.IntegerField(blank=True,null=True) 
> class Meta: 
> ordering = ['-id'] 
> def __unicode__(self): 
> return str(self.id) 
>
>
> -Subodh 
>

-- 
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/5a541fa1-208f-40ce-92f7-89546872d8d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: (ModelForm) confusion

2014-07-30 Thread Satinderpal Singh
On Wed, Jul 30, 2014 at 12:25 PM, Kamal Kaur  wrote:
> Greetings!
>
> What I have done:
> There are four tables, from which I have generated ModelForms. Getting
> the WorkerDetails from one side, adding the salary and attendance
> things from the other side as the view says. If there is at least one
> row added in WorkerDetail table, then it directly asks to add the
> salary and attendance things. Everything is being added perfectly but
> I have to add that "ForeignKey" thing in every form.

The thing i understand is, you wish is that the system should ask to
add the other details like monthly attendance and advance on the same
page when a new worker is added, if it don't have that values.
Am i right?

>
> Aim:
> To design a page like this:
> http://tinypic.com/r/feor5h/8
>
You require the validators in the template / form.py file, to validate
the data at the run time.

> Query:
> What I need to do to display forms like this and get the foreign key
> attribute directly from the displayed list? Is what I have done right?
> Is there some better approach to get this desired layout?
>
> Required code:
> models.py: http://pastie.org/9430952
> forms.py: http://pastie.org/9430955

Page doesn't exist :(

> views.py: http://pastie.org/9430962


-- 
Satinderpal Singh
http://satindergoraya91.blogspot.in/

-- 
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/CA%2BiK19JDoU5znYnz13AVwm0Swoc6y4R-t64QAaE0eiMBEC%3D5SA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Unable to create migration with Error - One or more models did not validate:

2014-07-30 Thread Subodh Nijsure
Hello,

I have following model definition and when I try to create a migration
using command,  'python manage.py schemamigration asset_mgmt
--initial' I am getting following error:

CommandError: One or more models did not validate:
asset_mgmt.alarmtable: 'polling_config' has a relation with model
AssetPollingConfig, which has either not been installed or is
abstract.

I have other classes that extend the TimeStampedModel and I don't see
this error, can someone point me towards reason I am getting this
error?


class TimeStampedModel(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
class Meta:
abstract = True

class AssetPollingInfo(TimeStampedModel):
id = models.AutoField(primary_key=True)
alarm_text = models.CharField(max_length=800,blank=True,null=True)
asset_id = models.ForeignKey('AssetInfo')
thresholds = models.ForeignKey('ThresholdInfo')
dispatch = models.ForeignKey('AlarmDispatchInfo')
class Meta:
ordering = ['-id']
def __unicode__(self):
return str(self.id)

class AlarmTable(TimeStampedModel):
id = models.AutoField(primary_key=True)
polling_config = models.ForeignKey('AssetPollingConfig')
alarm_text = models.CharField(max_length=800,blank=False,null=False)
event_type = models.SmallIntegerField(blank=False,null=False)
trigger_point = models.IntegerField(blank=True,null=True)
class Meta:
ordering = ['-id']
def __unicode__(self):
return str(self.id)


-Subodh

-- 
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/CALr9Q3YPGPTbBBXD%2Bi4F0XZ4FRTiSVYpQ2M%2Bt2fjbsG--%3D%2ButA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


how to ride submit_line.html

2014-07-30 Thread Akshay Mukadam
How can we override the submit_line.html to disable the save buttons in 
django admin site

I have tried in following ways:
1-> Using Javascript
2->https://github.com/django/django/blob/master/django/contrib/admin/templatetags/admin_modify.py#L23
 
by overriding these link

But I want to change it using change_view method
how can I achieve that 

Thank you 
For Help

-- 
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/6d7fc41b-0777-46ce-8e8e-0706ae58c870%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: simultaneously submit three forms on the same page

2014-07-30 Thread Tom Evans
Please stop replying directly to me - I am subscribed to the list,
this is how we started talking, I do not need an additional copy in my
inbox.

On Wed, Jul 30, 2014 at 10:29 AM, Devin Cky  wrote:
>
>
>
>  I tried it .. but it is only the first form (   {{ emet_form.as_p }})
> that is saved..
>
>
>   {%
> csrf_token %}
> {{ emet_form.as_p }}
> {{ des_form.as_p }}
> {{ fich_form.as_p }}
>
>  
>

So, why is it only the first form that is saved? What happens in your
view that causes only the first form to be saved?

Add debug logging and find out.

Cheers

Tom

-- 
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/CAFHbX1KBmf0LJ7QATfBBOpK0aSN-hzn4VqN4vz%2BZR6WFBfiG7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: update a field of a related table on form save

2014-07-30 Thread marc
Hi Brad,

i would register a 'post_save' signal 
(https://docs.djangoproject.com/en/dev/ref/signals/#post-save) on the first 
model and then, just hit the save method on the Application model, this 
will automaticly update the time.

Cheers,
Marc

Am Mittwoch, 30. Juli 2014 03:26:21 UTC+2 schrieb Brad Rice:
>
> I have three tables. The first one is application which has a flag for if 
> an app has been submitted as well as created date and modified date. The 
> other two tables relate to the application table. I have two forms that get 
> update those tables. What I want to do is update the application modified 
> date from the save on the other forms.
>
> I have this in the Application model
> modified= models.DateTimeField(auto_now_add=True)
>
> but since it is the other tables I am saving to, I'm not sure how to 
> update that field whenever the other two tables update.
>
> My view for one of the forms looks like this:
>
> class AnswersUpdate(UpdateView):
> model = Answers
> form_class = AnswersForm
> slug_field = 'created_by'
> template_name = 'requestform/applicant_form.html'
>
> @method_decorator(login_required(login_url='/accounts/login/'))
> def dispatch(self, *args, **kwargs):
> return super(AnswersUpdate, self).dispatch(*args, **kwargs)
>
> def get_object(self, queryset=None):
> return Answers.objects.get(created_by=self.request.user)
>
> def form_valid(self, form):
> obj = form.save(commit=False)
> obj.created_by = self.request.user
> obj.save()
> a = Application.objects.get(created_by=self.request.user)
>## how do I save to the Application here?
> return HttpResponseRedirect(reverse('requestform:app_check', 
> kwargs={'app_id': obj.id}))
>
> Any help would be appreciated.
>
>

-- 
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/08d28a7e-7e95-4b3e-9117-b8573c2bba45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django package to convert Less to CSS

2014-07-30 Thread marc
Hi,

are you using a virtualenv? Your lessc installation seems to point to a 
ruby one. (/Library/Ruby/Gems/2.0.0/gems/

less-2.4.0/bin/lessc) 

Be shure to have the correct path, try `which lessc` to see where it points 
to.


Cheers

Marc


Am Mittwoch, 30. Juli 2014 04:08:47 UTC+2 schrieb Chen Xu:
>
> I tried this, but I got errors like:
>
> /Library/Ruby/Gems/2.0.0/gems/less-2.4.0/bin/lessc:100:in `read': No such 
> file or directory - 
> /Users/xuchen81/Desktop/hw-kkworld/assets/less/kk-less/_global.css 
> (Errno::ENOENT)
>
> from /Library/Ruby/Gems/2.0.0/gems/less-2.4.0/bin/lessc:100:in ` (required)>'
>
> from /usr/bin/lessc:23:in `load'
>
> from /usr/bin/lessc:23:in `'
>
> Where I think  "/_global.css" is supposed to be generated. However, it 
> says no such file.
>
>
> Thanks
>
>
> On Tue, Jul 29, 2014 at 9:12 PM, carlos  
> wrote:
>
>> https://pypi.python.org/pypi/lesscss
>>
>> Cheers
>>
>>
>> On Tue, Jul 29, 2014 at 3:27 PM, Chen Xu > > wrote:
>>
>>> Hi, Everyone
>>> I am wondering is there a good django package that can convert less file 
>>> into css file?
>>>
>>>
>>> Thanks
>>>
>>>
>>> -- 
>>> ⚡ Chen Xu ⚡ 
>>>
>>> -- 
>>> 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/CACac-qbgdcFCkQHUfcV1hh2GNbkZ95j6tjfJ0f%2B1BXExgomRhw%40mail.gmail.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  -- 
>> 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/CAM-7rO1vTyuSdh%3DxvpD1nBPuEUJpdUxupLPQCMbb6F3p6mP8rw%40mail.gmail.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> ⚡ Chen Xu ⚡ 
>

-- 
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/96766eeb-0082-4e49-82f6-9abe6f605a3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 - What are you most excited about?

2014-07-30 Thread marc
Hi,

aggree in all points Russel, these features are also my favourite ones.


   - html email support in different places and the password reset mail 
   template makes life much easier. 

Greetings, Marc

Am Mittwoch, 30. Juli 2014 06:54:21 UTC+2 schrieb Russell Keith-Magee:
>
> Hi Ryan,
>
> On Wed, Jul 30, 2014 at 9:31 AM, Ryan Blunden  > wrote:
>
>> Hi everyone,
>>
>> I'm giving a lightening talk at the San Francisco Django meetup tomorrow 
>> night about some of the awesome new features in Django 1.7.
>>
>> I wanted to highlight not just what *I think* are the best new features, 
>> but what members of the community are most excited about.
>>
>> Would be great to hear from the Django core contributors too.
>>
>  
> Well, the release notes pretty much highlight the things that the core 
> team think are big news. For me, the biggest of those are:
>
>  * Schema migration - obviously
>
>  * App loading - because we finally have somewhere to put signal 
> registrations.
>
>  * The new checks framework - because it's a big internal cleanup, and 
> opens lots of possibilities for the future
>
>  * Converting custom query sets into managers - because this is repetitive 
> work that we've been doing since 0.96
>
>  * Custom managers on reverse relations - because it's an obvious thing to 
> want once you have custom managers.
>
> 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+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/60d1bc1c-b8a8-4dff-b69a-119b33838fc5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: simultaneously submit three forms on the same page

2014-07-30 Thread Devin Cky



 I tried it .. but it is only the first form (   {{ emet_form.as_p }})  
that 
is saved..


  {% 
csrf_token %}
{{ emet_form.as_p }}
{{ des_form.as_p }}
{{ fich_form.as_p }}  

 





On Wednesday, July 30, 2014 9:19:11 AM UTC, Tom Evans wrote:
>
> On Wed, Jul 30, 2014 at 10:04 AM, Devin Cky  > wrote: 
> > 
> > 
> > 
> > 
> > thank you very much .. how is the template for such a view ... I've put 
> each form in a form tag like that 
>
> Only one  can be submitted at a time, so if you want all three 
> Forms to be submitted at the same time, they must all be inside one 
> . 
>
> Cheers 
>
> Tom 
>

-- 
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/ec7666ef-5476-4a86-ba5d-b87199a5ee45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: simultaneously submit three forms on the same page

2014-07-30 Thread Tom Evans
On Wed, Jul 30, 2014 at 10:04 AM, Devin Cky  wrote:
>
>
>
>
> thank you very much .. how is the template for such a view ... I've put each 
> form in a form tag like that

Only one  can be submitted at a time, so if you want all three
Forms to be submitted at the same time, they must all be inside one
.

Cheers

Tom

-- 
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/CAFHbX1J%3D5te88sG%3DMiBgbGgkLpzbCJu0-soZkV%2BQN8NXC-xNdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: simultaneously submit three forms on the same page

2014-07-30 Thread Devin Cky



thank you very much .. how is the template for such a view ... I've put each 
form in a form tag like that


   
 
EMETTEUR
  {% csrf_token %}
{{ emet_form.as_p }}
  
   
   


 
DESTINATAIRE
  {% csrf_token %}
{{ des_form.as_p }}
  
   
   

   

FICHIER
  {% csrf_token %}
{{ fich_form.as_p }}
  
   
   

  
  {% csrf_token %}
   
   
   














On Tuesday, July 29, 2014 7:34:16 PM UTC, C. Kirby wrote:
>
>
>
> They are not getting validated, or validation is failing?
> Also, it looks like you are using model forms. You can get rid of all the 
> for,.cleaned_data.get lines and just use:
>
> if emet_form.is_valid() and des_form.is_valid() and fich_form.is_valid(): 
>   emet = emet_form.save()
>   des = des_form.save()
>   fich = fich_form.save()
>
>
> On Tuesday, July 29, 2014 10:53:59 AM UTC-5, Devin Cky wrote:
>>
>>
>>
>> On Tuesday, July 29, 2014 1:48:00 PM UTC, Tom Evans wrote:
>>>
>>> On Tue, Jul 29, 2014 at 12:31 PM, Devin Cky  wrote: 
>>> > hi i am a beginner in django and I have a problem .. how can I 
>>> validate 3 
>>> > forms on the same page simultaneously ..please help me 
>>> > 
>>>
>>> If they are different types of forms, you cannot use a formset. 
>>>
>>> In that case, just test whether all forms are valid. If they are all 
>>> valid, save/process the forms. If not, re-render the page with the 
>>> bound forms and display the errors. 
>>>
>>> Eg 
>>>
>>> def myview(request): 
>>>   if request.method == 'POST': 
>>> form_a = FormA(request.POST) 
>>> form_b = FormB(request.POST) 
>>> form_c = FormC(request.POST) 
>>> if form_a.is_valid() and form_b.is_valid() and form_c.is_valid(): 
>>>   form_a.save() 
>>>    
>>>   return HttpResponseRedirect(...) 
>>>   else: 
>>> form_a = FormA() 
>>> form_b = FormB() 
>>> form_c = FormC() 
>>>   return render(...) 
>>>
>>> Cheers 
>>>
>>> Tom 
>>>
>>
>>
>>
>>
>>
>> ---thank you TOM--- 
>>   when I submit my forms .. no field is validated
>>
>>
>> ...view.
>>
>>
>>
>> def enregistrer(request):
>> if request.method == 'POST': 
>> emet_form = EmetteurForm(request.POST, prefix = "emet")
>> des_form = DestinataireForm(request.POST, prefix = "des")
>> fich_form = FichierForm(request.POST, prefix = "fich")
>> if emet_form.is_valid() and des_form.is_valid() and 
>> fich_form.is_valid(): 
>> civilite = emet_form.cleaned_data.get('civilite')
>> nom = emet_form.cleaned_data.get('nom')
>> prenom = emet_form.cleaned_data.get('prenom')
>> 
>> cni = emet_form.cleaned_data.get('cni')
>> mail = emet_form.cleaned_data.get('mail')
>> telephone = 
>> emet_form.cleaned_data.get('telephone')
>> pays = emet_form.cleaned_data.get('pays')
>> ville = emet_form.cleaned_data.get('ville')
>> quartier = emet_form.cleaned_data.get('quartier')
>> emet = emet_form.save()
>> nom = des_form.cleaned_data.get('nom')
>> prenom = des_form.cleaned_data.get('prenom')
>> mail = des_form.cleaned_data.get('mail')  
>> telephone = des_form.cleaned_data.get('telephone')
>> des = des_form.save()
>> description_fichier = 
>> fich_form.cleaned_data.get('description_fichier')
>> date_enregistrement = 
>> fich_form.cleaned_data.get('date_enregistrement')
>> observation = 
>> fich_form.cleaned_data.get('observation')
>> montant_prestation = 
>> fich_form.cleaned_data.get('montant_prestation')
>> fich = fich_form.save()
>> else:
>> emet_form = EmetteurForm()
>> des_form = DestinataireForm()
>> fich_form = FichierForm() 
>> 
>> return 
>> render(request,'formulaire/information.html',locals())
>> //***please look ..if my view is good***//
>>
>

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

Re: running script in django database

2014-07-30 Thread jirka . vejrazka
Hi Mohammad,

  this can be easily achieved using a custom management command - check the 
Django documentation.

  HTH

Jirka
 
-Original Message-
From: alghafli 
Sender: django-users@googlegroups.com
Date: Wed, 30 Jul 2014 07:02:59 
To: 
Reply-To: django-users@googlegroups.com
Subject: running script in django database

Hello,
I made a library application using django 1.6. currently I only need to 
populate the database. at the beginning, it is easier to write the 
information in a csv file and import it using a script.

the script is running fine if I use manage.py shell and import the 
necessary file and call the necessary function. however, I want to make 
the script run from the system commandline rather than from the python 
interpreter since it is easier to pass arguments to it. I could not find 
a way in the manage.py documentation page.

Is it possible?

thank you,
Mohammad

-- 
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/53D86E73.9060806%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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/417657233-1406705276-cardhu_decombobulator_blackberry.rim.net-1073591500-%40b4.c3.bise7.blackberry.
For more options, visit https://groups.google.com/d/optout.


(ModelForm) confusion

2014-07-30 Thread Kamal Kaur
Greetings!

What I have done:
There are four tables, from which I have generated ModelForms. Getting
the WorkerDetails from one side, adding the salary and attendance
things from the other side as the view says. If there is at least one
row added in WorkerDetail table, then it directly asks to add the
salary and attendance things. Everything is being added perfectly but
I have to add that "ForeignKey" thing in every form.

Aim:
To design a page like this:
http://tinypic.com/r/feor5h/8

Query:
What I need to do to display forms like this and get the foreign key
attribute directly from the displayed list? Is what I have done right?
Is there some better approach to get this desired layout?

Required code:
models.py: http://pastie.org/9430952
forms.py: http://pastie.org/9430955
views.py: http://pastie.org/9430962



-- 
Kamaljeet Kaur
I'm not what I'm compared to others, I'm what I'm compared to my yesterday.

-- 
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/CAP8Q%2Bxi-nCvRFJi2mP_YQvpanZMswEsdyLHzirV%2B%3DTtKX8N85w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: update a field of a related table on form save

2014-07-30 Thread Babatunde Akinyanmi
Hi Brad, my response is inline

On 30 Jul 2014 02:26, "Brad Rice"  wrote:
>
> I have three tables. The first one is application which has a flag for if
an app has been submitted as well as created date and modified date. The
other two tables relate to the application table. I have two forms that get
update those tables. What I want to do is update the application modified
date from the save on the other forms.
>
> I have this in the Application model
> modified= models.DateTimeField(auto_now_add=True)
>
> but since it is the other tables I am saving to, I'm not sure how to
update that field whenever the other two tables update.
>
> My view for one of the forms looks like this:
>
> class AnswersUpdate(UpdateView):
> model = Answers
> form_class = AnswersForm
> slug_field = 'created_by'
> template_name = 'requestform/applicant_form.html'
>
> @method_decorator(login_required(login_url='/accounts/login/'))
> def dispatch(self, *args, **kwargs):
> return super(AnswersUpdate, self).dispatch(*args, **kwargs)
>
> def get_object(self, queryset=None):
> return Answers.objects.get(created_by=self.request.user)
>
> def form_valid(self, form):
> obj = form.save(commit=False)
> obj.created_by = self.request.user
> obj.save()
> a = Application.objects.get(created_by=self.request.user)
>## how do I save to the Application here?

#if its a new record, something like 
application =  Application.objects.create(...)

#if you are updating a record, something like...
application = Application.objects.get(...) # can throw exception
application.field_name = something
application.save ()

> return HttpResponseRedirect(reverse('requestform:app_check',
kwargs={'app_id': obj.id}))
>
> Any help would be appreciated.
>
> --
> 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/2a2b6f24-b4c2-4575-9a52-85a892256c79%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/CA%2BWjgXPpbqjetNYMSsa61q-HPy9M9dvMQ-P7NES6J6w-qtCS8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: plz help me to learn django

2014-07-30 Thread memilanuk

On 07/29/2014 10:15 AM, François Schiettecatte wrote:

Two great resources:

https://www.djangoproject.com

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

http://www.djangobook.com/en/2.0/index.html


Not sure I'd recommend djangobook.com... from their own site:

"This book was originally published by Apress in 2009 and covered Django 
version 1.0. Since then it has languished and, in places, is extremely 
out of date."


And if you go over their github page... the last updates were about a 
year ago.  Doesn't really look like they're making any progress towards 
updating things.


One site that is reasonably current and very helpful, though:

http://www.tangowithdjango.com/

Written for django 1.5, so it could be a little fresher... but its still 
way more current/relevant than djangobook.com.


Just my point of view as another newbie looking at tutorials out there 
on the great world wild web ;)


YMMV,

Monte


--
Shiny!  Let's be bad guys.

Reach me @ memilanuk (at) gmail dot 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/53D88C1F.9070903%40gmail.com.
For more options, visit https://groups.google.com/d/optout.