Thursday, July 31, 2014

Re: Changing website version written in python+django

THX
Z


2014. augusztus 1., péntek 7:12:38 UTC+2 időpontban Lachlan Musicman a következőt írta:
You can copy the files on top of the old files and then restart the
web server, which will bump the wsgi or fastcgi, which should be
sufficient.

cheers
L.

On 1 August 2014 15:06, Zoltán Turcsányi <zun...@gmail.com> wrote:
> Hi Everyone,
>
>
> I have a website written in python+django and I deployed it to
> pythonanywhere.com. It's okay, works well, but I want to deploy new
> versions. How should I do that?
> Just copy the new files with rsync? Or change the full django project
> directory?
> I would be really grateful if you wrote it step by step.
>
>
> Thanks,
> Zoli
>
> --
> 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/cb3e728b-433a-4e47-974b-b8e6a40eb07c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
You have to be really clever to come up with a genuinely dangerous
thought. I am disheartened that people can be clever enough to do that
and not clever enough to do the obvious thing and KEEP THEIR IDIOT
MOUTHS SHUT about it, because it is much more important to sound
intelligent when talking to your friends.
This post was STUPID.
-----------------------------------------------------------------------------------------------------------
The Most Terrifying Thought Experiment of All Time
http://www.slate.com/articles/technology/bitwise/2014/07/roko_s_basilisk_the_most_terrifying_thought_experiment_of_all_time.html

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/36e6ed5a-2023-4296-a617-7a0a53511e21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: building a xenserver web client

Openstack is huge. I'll prefer a lightweight solution, maybe just HTML/CSS (if there is already a good Soap client for JS). But this should be compatible to most of the API features provided by xen.

Am Donnerstag, 31. Juli 2014 17:39:53 UTC+2 schrieb cmawe...@gmail.com:
You mentioned "full featured". Check out https://github.com/openstack/horizon if you haven't.

On Thursday, July 31, 2014 9:55:43 AM UTC-4, ma...@tubeards.com wrote:
Hi,

is anyone interested in co-building a full featured web client for xenserver instances?
Since version 6.2 the update procedures are really a pain which is one of my reasons to think about an (maintained) opensource client.

Ideas are welcome.
Cheers

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8214660c-6a6a-4b78-b21c-afa51a959090%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Redirect with string?

Hi all,

I have a thermal line printer (a Zebra LP2824 fwiw) and I've
discovered/worked out that I can print with it by just sending a text,
a la:

cat filename | nc <ipaddress> <portnumber>

I tried this in my view:

return redirect("<ipaddress>", "string")

but it's printing out the HttpResponse object.

How would I send a string to the IP in question from a view?

cheers
L.


--
You have to be really clever to come up with a genuinely dangerous
thought. I am disheartened that people can be clever enough to do that
and not clever enough to do the obvious thing and KEEP THEIR IDIOT
MOUTHS SHUT about it, because it is much more important to sound
intelligent when talking to your friends.
This post was STUPID.
-----------------------------------------------------------------------------------------------------------
The Most Terrifying Thought Experiment of All Time
http://www.slate.com/articles/technology/bitwise/2014/07/roko_s_basilisk_the_most_terrifying_thought_experiment_of_all_time.html

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

Re: Changing website version written in python+django

You can copy the files on top of the old files and then restart the
web server, which will bump the wsgi or fastcgi, which should be
sufficient.

cheers
L.

On 1 August 2014 15:06, Zoltán Turcsányi <zunius@gmail.com> wrote:
> Hi Everyone,
>
>
> I have a website written in python+django and I deployed it to
> pythonanywhere.com. It's okay, works well, but I want to deploy new
> versions. How should I do that?
> Just copy the new files with rsync? Or change the full django project
> directory?
> I would be really grateful if you wrote it step by step.
>
>
> Thanks,
> Zoli
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cb3e728b-433a-4e47-974b-b8e6a40eb07c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
You have to be really clever to come up with a genuinely dangerous
thought. I am disheartened that people can be clever enough to do that
and not clever enough to do the obvious thing and KEEP THEIR IDIOT
MOUTHS SHUT about it, because it is much more important to sound
intelligent when talking to your friends.
This post was STUPID.
-----------------------------------------------------------------------------------------------------------
The Most Terrifying Thought Experiment of All Time
http://www.slate.com/articles/technology/bitwise/2014/07/roko_s_basilisk_the_most_terrifying_thought_experiment_of_all_time.html

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

Changing website version written in python+django

Hi Everyone,


I have a website written in python+django and I deployed it to pythonanywhere.com. It's okay, works well, but I want to deploy new versions. How should I do that?
Just copy the new files with rsync? Or change the full django project directory?
I would be really grateful if you wrote it step by step.


Thanks,
Zoli

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cb3e728b-433a-4e47-974b-b8e6a40eb07c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: invalid attribute

Do you have the full error message?


On Thursday, July 31, 2014 5:48:55 PM UTC-4, ngangsia akumbo wrote:
Got an invalid attribut error

class Product(models.Model):
    name = models.CharField(max_length=255, unique=True)
    slug = models.SlugField(max_length=255, unique=True,
            help_text="Each product has a unique name")
    brand = models.CharField(max_length=50)
    sku = models.CharField(max_length=50)
    price = models.DecimalField(max_length=9, decimal_places=3)
    old_price = models.DecimalField(max_length=9, decimal_places=3, blank=True, default=0.00)
    image = models.CharField(max_length=50)
    is_active = models.BooleanField(default=True)
    is_bestseller = models.BooleanField(default=False)
    is_featured = models.BooleanField(default=False)
    quantity = models.IntegerField()
    description = models.TextField()
    meta_keywords = models.CharField('Meta Keywords', max_length=300)
    meta_description = models.CharField("Meta Description", max_length=255)
       
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    category = models.ManyToManyField(Category)


    class Meta:
        db_table = 'products'
        ordering = ['-created_at']

        def __unicode(self):
            return self.name


        @models.permalink
        def get_absolute_url(self):
            return ('catalog_product', (), { 'product_slug': self.slug })

       
        def sale_price(self):
            if self.old_price > self.price:
                return self.price
            else:
                return None

       
   

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/917e4e0c-89fe-4c11-8fb4-a26a1f4c9550%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anyone got Django working on Google App Engine? Seems there are inconsistent, incomplete and conflicting docs. Any advice appreciated....SOS

Is this the latest greatest docs for Django on Google AppEngine?

        http://django-nonrel.org/

There seems to be another page high on a search:
  
        http://www.allbuttonspressed.com/projects/djangoappengine#installation

With the first doc I was able to get a toy Django app running with the local devserver but that
page has scanty instructions for getting models and uploading to Google beyond that!?!?

e.g.

(1) In various places it says to do "manage.py deploy" in order to deploy your app.
     The problem is that "deploy" isn't a normal Django switch for manage.py.
      The docs insinuate you need to somehow use djangoappengine but there
        is no mention of how to magically tweak manage.py with djangoappengine
           so that the "deploy" switch appears suddenly.

(2) It isn't clear how to create models and use them.  I was getting errors
      about me not having permission to do this.

Any help greatly appreciated.

Sincerely,

Chris 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e9b6687b-3703-4ae4-9af7-fd46726a27c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

On 1/08/2014 3:37 AM, G Z wrote:
> doesn't work because then my charts dont appear when i enclose the
> script tag.

Can you put the js into a file and use the template to include it?

>
> On Wednesday, July 30, 2014 7:44:48 PM UTC-6, Camilo Torres wrote:
>
> Hello, you can use 'verbatim':
> https://docs.djangoproject.com/en/1.6/ref/templates/builtins/#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 : "<ul
> class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0;
> i<datasets.length; i++){%><li><span
> style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
> });
>
> 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: POST
> Request URL: http://127.0.0.1:8000/vmstats/
> Django Version: 1.6.5
> Exception Type: TemplateSyntaxError
> Exception Value:
>
> Invalid block tag: '><li><span'
>
> Exception Location:
> /usr/local/lib/python2.7/dist-packages/django/template/base.py
> in invalid_block_tag, line 332
> Python Executable: /usr/bin/python
> Python Version: 2.7.5
> Python 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 +0000
>
>
> Error during template rendering
>
> In template |/home/grant/workspace/Django
> Projects/trunk/holon/portal/templates/vmstats.html|, error at
> line *162*
>
>
> Invalid block tag: '><li><span'
>
> 152 var iopsChart =
> 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 : "<ul
> class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0;
> i<datasets.length; i++){%><li><span
> style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
>
> 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+unsubscribe@googlegroups.com
> <mailto:django-users+unsubscribe@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/b5db3b20-bceb-4b72-bc83-d52adb948b8c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b5db3b20-bceb-4b72-bc83-d52adb948b8c%40googlegroups.com?utm_medium=email&utm_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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/53DAC7E4.1000101%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Re: Get latest timestamp+value from each group

I would also add that using the Max ID as the annotation field for the device (group) is what I am using in the interim, but it only works since currently my log IDs are automatically generated and each newly entered timestamp is younger than the previous. My concern is that I would like to extend the application to allow the possibility of backfilling data (entering old timestamps) in which case the Max IDs are no longer a good proxy for the Max timestamps.

devices = Device.objects.annotate(max_log_id=Max("log__id"))
logs
= Log.objects.filter(id__in=[device.max_log_id for device in devices])

Any thoughts or suggestions?

On Wednesday, July 30, 2014 2:11:49 PM UTC-5, Joshua Lyon wrote:
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/07f467fa-1d97-4bd3-a2a0-fe520ce01395%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

invalid attribute

Got an invalid attribut error

class Product(models.Model):
    name = models.CharField(max_length=255, unique=True)
    slug = models.SlugField(max_length=255, unique=True,
            help_text="Each product has a unique name")
    brand = models.CharField(max_length=50)
    sku = models.CharField(max_length=50)
    price = models.DecimalField(max_length=9, decimal_places=3)
    old_price = models.DecimalField(max_length=9, decimal_places=3, blank=True, default=0.00)
    image = models.CharField(max_length=50)
    is_active = models.BooleanField(default=True)
    is_bestseller = models.BooleanField(default=False)
    is_featured = models.BooleanField(default=False)
    quantity = models.IntegerField()
    description = models.TextField()
    meta_keywords = models.CharField('Meta Keywords', max_length=300)
    meta_description = models.CharField("Meta Description", max_length=255)
       
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    category = models.ManyToManyField(Category)


    class Meta:
        db_table = 'products'
        ordering = ['-created_at']

        def __unicode(self):
            return self.name


        @models.permalink
        def get_absolute_url(self):
            return ('catalog_product', (), { 'product_slug': self.slug })

       
        def sale_price(self):
            if self.old_price > self.price:
                return self.price
            else:
                return None

       
   

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

Re: image upload

no

On Thursday, July 31, 2014 4:43:15 PM UTC+1, cmawe...@gmail.com wrote:
Are you using <img src="{{ image.image.url }}" >  ?

On Thursday, July 31, 2014 7:20:19 AM UTC-4, ngangsia akumbo wrote:
i have a problem of displaying my image on my web page.

i have upload my pic in admin and when i display it it shows me the  this

media/Lighthouse_1.jpg

models.py

class Image(models.Model):
    title = models.CharField(max_length=60, blank=True, null=True)
    image = models.FileField(upload_to="images")


<div id="content">
<div id="content_plate">

<h2> {{ blogs.title }} - Date Published: {{blogs.pub_date}} </h2>
<p> {{ blogs.content|safe}} <br />Tags: {{ blogs.photo }}</p> 
<h2> Reported By: {{blogs.reporter}} </h2>
</div>
<div id='link_back'>
<ul>
<p>Return back to Main Page</p>
<li><a href="/blog/">News</a></li>
</ul>
 
</div>
{% endblock %}




MEDIA_ROOT = 'C:/Python27/Scripts/testproject/Django-1.4.3/django/bin/test0/images/'
MEDIA_URL = '/media/'

STATIC_ROOT = '' "
STATIC_URL = '/static/'







--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9889f679-b424-477c-a276-f44a2e395ce2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django Queryset with filtering on reverse foreign key failing

Could not resolve tblconfigagentgroupmembers.

I've resolved the issue now though. I moved the model to models.py from the models_auto.py file and was then getting some validation errors mostly missing id fields(just set primary keys on the generated models) and now it's working as expected.


On Fri, Aug 1, 2014 at 12:18 AM, <cmawebsite@gmail.com> wrote:
What does the FieldError say?

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/RtlHbhnTfro/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4bba252c-1690-4eab-b1e8-62cb674aa151%40googlegroups.com.

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



--
Anthony Hawkes
E-Mail: lifesillusion@gmail.com
Ph: 0400 372 260

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

Re: user object's is_authenticated() method ALWAYS return True even after they log out??

or for a specific user:

from django.contrib.sessions.models import Session

any(s.get_decoded().get('_auth_user_id') == user.id for s in Session.objects.all())


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

Re: user object's is_authenticated() method ALWAYS return True even after they log out??

something like this may work:

from django.contrib.auth.models import User
from django.contrib.sessions.models import Session

User.objects.filter(id__in=(s.get_decoded().get('_auth_user_id') for s in Session.objects.all()))







for s in Session.objects.all()
   

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/02b02949-22cc-4211-a679-862c228a7715%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: user object's is_authenticated() method ALWAYS return True even after they log out??

Is there a way to answer your question "is user x logged into the website right now" in Django code?

On Thursday, July 31, 2014 11:05:29 AM UTC-5, cmawe...@gmail.com wrote:
Right, the question isn't "is user x logged into the website right now", it actually only makes sense for for request.user. This will return all users in the database: logged_in_users = [user for user in User.objects.all() if user.is_authenticated()]

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/74b5580f-92b1-4d06-bc2e-c4747dba5357%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Data stats package and reporting help

I'm building a report builder for my Django app and could use a little advice.

My reports are fairly simple where I accumulate scores of data (easy enough) but then I want to alter the report totals by varying dimensions (date ranges / split dates/weeks/months / owners / other metadata etc.). Since I am working with Django Querysets, I have some options as to how I can query the data into one query set with joins where I can traverse the joins for my accumulating data. Or I can take multiple querysets and join them in my app manually which simplifies the queries somewhat (this optimization might come later when I load test the app). 

My data might look something like this:

Parent (with useful dimensional metadata) -> Child (with useful dimensional metadata) ->Child of child (accumulating data source, i.e. Counts to aggregate)

I see some stuff about Pandas, also Anaconda. I took a brief look at both and they definitely both sound more hardcore than I need, but then I don't feel like rolling my own axis/dimensional modelling logic if I can perhaps build a dataset and have the app do it for me. Which package is recommended for babby's first stat package that can meet my requirements? Ideally one that uses less resources as I plan to scale this app up quite a bit in production.

Also for whichever package recommended, where would I find some good basic tutorials on how to build my dataset and alter it for reporting purposes? I plan to build charts on the client-side front-end with HTML5/js/css.

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

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

doesn't work because then my charts dont appear when i enclose the script tag.

On Wednesday, July 30, 2014 7:44:48 PM UTC-6, Camilo Torres wrote:
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 : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
        
        });

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:POST
Request URL:http://127.0.0.1:8000/vmstats/
Django Version:1.6.5
Exception Type:TemplateSyntaxError
Exception Value:
Invalid block tag: '><li><span'
Exception Location:/usr/local/lib/python2.7/dist-packages/django/template/base.py in invalid_block_tag, line 332
Python Executable:/usr/bin/python
Python Version:2.7.5
Python 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 +0000

Error during template rendering

In template /home/grant/workspace/Django Projects/trunk/holon/portal/templates/vmstats.html, error at line 162

Invalid block tag: '><li><span'

152 var iopsChart = 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 : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b5db3b20-bceb-4b72-bc83-d52adb948b8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Different choices values for a single field in inherited class

class Color(models.Model):
    red_or_white
= models.CharField(max_length=10, choices=[('red', 'Red'), ('white', 'White')])
    tone
= models.CharField(max_length=32)
 
class Wine(models.Model):
    name
= models.CharField(max_length=255)
    color
= models.ForeignKey(Color)    



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

Re: Django limit_choices_to - ForeignKey

If you are using the admin:

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_choice_field

Otherwise, you'll need to dynamically create that field or the entire form.

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

Re: Django Queryset with filtering on reverse foreign key failing

What does the FieldError say?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4bba252c-1690-4eab-b1e8-62cb674aa151%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Screenshot pdf from AWS hosted django app

And if local dev is an issue, you could try setting MEDIA_URL to your live site.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f3e0d3cd-64e2-4ad1-95c6-a00dd2b1656d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Screenshot pdf from AWS hosted django app

I just use commandline imagemagick instead of PythonMagic, if the python bindings are the issue getting imagemagick to work.

cmd = 'convert -density 300 -flatten -interlace line -quality 92 -colorspace sRGB -thumbnail'.split() + size + [default_storage.path(name) + '[0]', 'jpg:-']
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
assert not proc.returncode, stderr + stdout
default_storage.save(request.path[1:], ContentFile(stdout))

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

Re: Why are DateTimeField auto_now and auto_now_add bad?

It gets confusing if those fields are editable in the admin. I recommend setting editable=False on those fields.

On Sunday, July 27, 2014 6:47:33 PM UTC-4, Russell Keith-Magee wrote:

I'm not aware of a formally documented list anywhere. 

To the best my knowledge, the bug/downside that is referred to here is that the fields *won't* automatically update in *every* circumstance. You need to actually *save* the model to make the field update. Calls to update, save_base, etc won't invoke the "auto" part of the field logic, and the timestamp won't be adjusted.

Yours,
Russ Magee %-)


On Sun, Jul 27, 2014 at 10:29 PM, Mattias Linnap <lin...@gmail.com> wrote:
Hi all,

I've seen DateTimeField's auto_now and auto_now_add parameters often described as "buggy" or "error-prone". For example:

The ticket proposes to document these downsides or problems in more detail. But until that happens, is there a blog post or mailing list post somewhere that summarises the gotchas to watch out for with auto_now?

Thanks,

Mattias

--
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/9d61eca2-21c7-41ae-a921-a448d5f9f4f9%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0abd49f6-d55d-4b88-99ca-96560cdb501e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: user object's is_authenticated() method ALWAYS return True even after they log out??

Right, the question isn't "is user x logged into the website right now", it actually only makes sense for for request.user. This will return all users in the database: logged_in_users = [user for user in User.objects.all() if user.is_authenticated()]

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5c439b95-7dd1-46bd-a356-b1074af79c7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: hanging django/postgres idle connections

Does it work fine on django 1.6? It could be a regression.

On Wednesday, July 30, 2014 10:41:58 AM UTC-4, Jani Kajala wrote:
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4855c62e-c322-45d0-bc93-da79957fd7f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.