Re: Dynamic Base Template

2014-07-17 Thread cmawebsite
You could make a custom assignment_tag like: {% get_datasets_for_user user 
as dataset %}

https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#assignment-tags

-- 
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/d9e97496-b001-4857-b126-0bbd4abf13c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


idea: deploy static files on github pages CDN

2014-07-17 Thread cmawebsite
I had an idea today that I wanted to share, if anyone finds it helpful or 
has feedback.

./manage.py collectstatic
cd $STATIC_ROOT
rm -rf .git/  # optionally don't keep history
git init .
git add .
git commit -m"static files"
git push -f g...@github.com:username/yourrepo master:gh-pages

then set STATIC_URL = '//username.github.io/yourrepo/'

It works just fine, even on private repositories.

-- 
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/d1abc065-3658-4528-a3da-b835bfc8a440%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Errors Using Pip In Powershell to Download Django

2014-07-17 Thread cmawebsite

>
> Yesterday I tried to get the 1.7rc1 and got the error 'file contains no 
> section headers'. I assumed this was because it was a tarball, and after 
> looking around gave up for the night.
> Tonight I decided to just get 1.6.5. But to my surprise, I got the same 
> error. I have no control over putting section headers in these files. What 
> do I do now? Thanks. 
>

Yes, you could try zip:
https://github.com/django/django/zipball/1.7c1
or, even newer:
https://github.com/django/django/zipball/stable/1.7.x 

-- 
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/e7957593-d44e-426d-99d1-cae2ef1aaed5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2014-07-31 Thread cmawebsite
I think if you put it in urls.py it should run (once) just before the first 
request.

On Thursday, July 31, 2014 10:30:08 AM UTC-4, ke1g wrote:
>
> It runs twice because runserver uses two processes: the real server, and; 
> the monitoring process that restarts the other when you change a source 
> file. You could fool around with undocumented internals to figure out which 
> a given import is running in.  Or you could use a modifies runserver 
> command. Or you could modify manage.py. Or you could, if your O/S supports 
> it, open a file for exclusive use and the one that can't knows that it is 
> the server process.
>

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


Re: building a xenserver web client

2014-07-31 Thread cmawebsite
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+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/c0320237-3d9d-4801-ac20-a3ec673f40f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: image upload

2014-07-31 Thread cmawebsite
Are you using   ?

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")
>
>
> 
> 
>
>  {{ blogs.title }} - Date Published: {{blogs.pub_date}} 
>   {{ blogs.content|safe}} Tags: {{ blogs.photo }} 
>   Reported By: {{blogs.reporter}} 
>  
> 
> 
> Return back to Main Page
> News
> 
>  
> 
> {% 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+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/a39e3250-7ded-4d1a-8a48-7b026d4a81b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: hanging django/postgres idle connections

2014-07-31 Thread cmawebsite
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+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/4855c62e-c322-45d0-bc93-da79957fd7f2%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??

2014-07-31 Thread cmawebsite
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+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/5c439b95-7dd1-46bd-a356-b1074af79c7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why are DateTimeField auto_now and auto_now_add bad?

2014-07-31 Thread cmawebsite
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  > wrote:
>
>> Hi all,
>>
>> I've seen DateTimeField's auto_now and auto_now_add parameters often 
>> described as "buggy" or "error-prone". For example:
>> https://code.djangoproject.com/ticket/22995
>> https://groups.google.com/forum/#!topic/django-developers/TNYxwiXLTlI
>>
>> 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+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/0abd49f6-d55d-4b88-99ca-96560cdb501e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Screenshot pdf from AWS hosted django app

2014-07-31 Thread cmawebsite
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+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/7b9aff5d-de02-4cb5-8a2e-d8c65e0c3656%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Screenshot pdf from AWS hosted django app

2014-07-31 Thread cmawebsite
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+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/f3e0d3cd-64e2-4ad1-95c6-a00dd2b1656d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Queryset with filtering on reverse foreign key failing

2014-07-31 Thread cmawebsite
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+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/4bba252c-1690-4eab-b1e8-62cb674aa151%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2014-07-31 Thread cmawebsite
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+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/f5769995-3563-40f1-a9aa-8d5a9298cbed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django limit_choices_to - ForeignKey

2014-07-31 Thread cmawebsite
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+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/bdd0f989-c442-40fd-8d97-e6f282525ca9%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??

2014-07-31 Thread cmawebsite
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+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/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??

2014-07-31 Thread cmawebsite
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+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/6c360bd0-541d-4692-ba5d-c1c46b3c5c2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: invalid attribute

2014-07-31 Thread cmawebsite
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+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/917e4e0c-89fe-4c11-8fb4-a26a1f4c9550%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.