Re: How/where to call setlocale

2014-09-19 Thread James Hargreaves
Thanks again for your reply Ulrich. I finally figured out the problem :)

Towards the bottom of my settings.py I had mistakenly overwritten the
LANGUAGE_CODE as follows:

LANGUAGE_CODE = 'en'

Django must determine the locale internally based on the LANGUAGE_CODE
specified. Needless to say this line broke the locale lookup since *en* is
not a valid language code.

Once I removed the line above the locale was set correctly. In fact, I was
able to remove the manual setlocale(...) call from my wsgi.py file without
any issues.

Thanks again for your help, it is very much appreciated :)

Jay

On 18 September 2014 22:08, James Hargreaves 
wrote:

> Hi Ulrich et al,
>
> Thanks again for your help.
>
> I'm having issues with your solution. It works when making a literal call
> to locale but Django is not using the correct locale for some reason.
>
> I added this to my application.wsgi:
>
> import locale
>
> locale.setlocale(locale.LC_ALL, 'en_GB.utf-8')
>
> I added a context processor which outputs the following:
>
> def common(request=None):
> return {
> 'TODAY' : date.today(),
> 'LOCALE' : locale.getlocale(),
> 'LOCALE_DF' : locale.nl_langinfo(locale.D_FMT),
> }
>
> And I added the following to my template:
>
> {{ LOCALE }}
> {{ LOCALE_DF }}
> {{ TODAY|date:"SHORT_DATE_FORMAT" }}
>
> Which unexpectedly outputs this:
>
> ('en_GB', 'UTF-8')
> %d/%m/%y
> 09/18/2014
>
> I also tried adding the locale.setlocale(...) line to my settings.py
> instead but that had no effect either.
>
> Any ideas appreciated please.
>
> Thanks
> Jay
>
> On 17 September 2014 07:38, James Hargreaves 
> wrote:
>
>> Thanks Ulrich.
>>
>> No I think I've misread the documentation with regards it affecting the
>> whole environment rather than the program.
>>
>> I'll try your solution myself but it looks like it will work, thanks!
>>
>> Jay
>>
>>
>> On Tuesday, September 16, 2014, uvetter 
>> wrote:
>>
>>> Dear Jay,
>>>
>>> I just tried to following in my wsgi.py file:
>>>
>>>
>>> import os
>>> import sys
>>> import site
>>> import locale
>>>
>>> site.addsitedir('/mypath/lib/python3.3/site-packages')
>>>
>>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")
>>>
>>> os.environ['HTTPS'] = "on"
>>>
>>> sys.path.append('/mypath/test')
>>> sys.path.append('/mypath/test/test')
>>> sys.path.append('/mypath/test/app1')
>>> sys.path.append('/mypath/test/app2')
>>>
>>> activate_env=os.path.expanduser("/mypath/bin/activate_this.py")
>>> exec(open(activate_env).read())
>>>
>>> locale.setlocale(locale.LC_ALL, 'en_US.utf-8')
>>>
>>> from django.core.wsgi import get_wsgi_application
>>> application = get_wsgi_application()
>>>
>>>
>>>
>>> This sets the locale correctly for all calls to my Django application.
>>>
>>> I just realized that in your first post you mentioned that "this affects
>>> the entire environment". I just read through the locale module
>>> documentation, which states that "The C standard defines the locale as a
>>> program-wide property ". This means that there will be no system-wide
>>> changes when you call locale.setenv(). Or did I misunderstand you?
>>>
>>> Best wishes,
>>> Ulrich
>>>
>>> Am Dienstag, 16. September 2014 22:39:08 UTC+2 schrieb James Hargreaves:

 Thanks for your reply Ulrich.

 If I set the locale in WSGI would that persist for all connections? If
 so that sounds like the best option.

 Thanks
 Jay

 On Tuesday, September 16, 2014,  wrote:

> Hi,
> I ran into a similar problem yesterday while programming a web shop
> with Django (Version 1.6, Python version 3.3) where language switching
> should immediately have an effect on the way prices, etc. are displayed
> (doing so by a  in the
> template and redirecting back to the page where it was called). The locale
> is indeed not set this way and needs to be set explicitly. What I finally
> came up with as a first working solution as part of a function:
>
> def convert_my_price(_price)  # _price is a decimal.Decimal
> language = django.utils.translation.get_language()
> if language == 'en':
> locale.setlocale(locale.LC_ALL, 'en_US.utf-8') #
> 'en_GB.utf-8'  didn't work for me
> else:
> locale.setlocale(locale.LC_ALL, 'de_DE.utf-8')# this is
> the fallback
>
> _loc = locale.localeconv()
> .
> .  # process the Decimal
> .
> return my_price_as_a_string
>
> After doing so I have access to the locale details stored in the
> dictionairy _loc, like e.g. _loc['thousands_sep'], _loc['currency_symbol']
> in this function, but also everywhere else via locale.localeconv()
> This function however is currently called from within class based
> views, but also implemented as a template filter. Of course one should not
> set the locale every time when calling this funct

Re: Simple task. Get request.META values listed on a page via template

2014-09-19 Thread Tom Evans
On Mon, Sep 8, 2014 at 5:08 PM, Артём Мутерко  wrote:
> I need to list all values from request.META in Django using template.
>
> I've done it without template like this
> (code from my views.py)
>
> def display_meta(request):
>   values = request.META.items()
>   values.sort()
>   html = []
>   for k, v in values:
>   html.append(‘%s%s’ % (k, v))
>   return HttpResponse(‘%s’ % ‘\n’.join(html))
>
> For example I have template 'values.html', how can I do the same as above
> but using template and not hardcoding html in views.py?
>

Template:


{% for key, value in meta %}
{{ key }}{{ value }}
{% endfor %}


View:
def myview(request)
  return render(request, template_name, { 'meta': request.META.items() })

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


Re: How/where to call setlocale

2014-09-19 Thread uvetter
Dear Jay,
glad that it works now.
I got myself confused about terms such as language name and locale name. 
Setting the locale via locale.setlocale does indeed have no influence on 
the Django settings. I knew that but I misunderstood you. I set 
locale.setlocale in the example because I wanted to make use of locale 
details for correct currency display (i.e. the currency symbol, whether the 
currency symbol is displayed in front of the numbers or after them, etc.). 
I found than Django has some of the locale details implemented, e.g. the 
thousand separator, but not all of them to my best knowledge. 
To be honest: it is not really clear to me how Django distinguishes/defines 
locale and language. For the definition of a locale, at least when looking 
at locale.setlocale, the encoding is required additionally. 

Best wishes,
Ulrich



Am Freitag, 19. September 2014 09:54:21 UTC+2 schrieb James Hargreaves:
>
> Thanks again for your reply Ulrich. I finally figured out the problem :)
>
> Towards the bottom of my settings.py I had mistakenly overwritten the 
> LANGUAGE_CODE as follows:
>
> LANGUAGE_CODE = 'en'
>
> Django must determine the locale internally based on the LANGUAGE_CODE 
> specified. Needless to say this line broke the locale lookup since *en* 
> is not a valid language code.
>
> Once I removed the line above the locale was set correctly. In fact, I was 
> able to remove the manual setlocale(...) call from my wsgi.py file without 
> any issues.
>
> Thanks again for your help, it is very much appreciated :)
>
> Jay
>
> On 18 September 2014 22:08, James Hargreaves  > wrote:
>
>> Hi Ulrich et al,
>>
>> Thanks again for your help.
>>
>> I'm having issues with your solution. It works when making a literal call 
>> to locale but Django is not using the correct locale for some reason.
>>
>> I added this to my application.wsgi:
>>
>> import locale
>>
>> locale.setlocale(locale.LC_ALL, 'en_GB.utf-8')
>>
>> I added a context processor which outputs the following:
>>
>> def common(request=None):
>> return {
>> 'TODAY' : date.today(),
>> 'LOCALE' : locale.getlocale(),
>> 'LOCALE_DF' : locale.nl_langinfo(locale.D_FMT),
>> }
>>
>> And I added the following to my template:
>>
>> {{ LOCALE }}
>> {{ LOCALE_DF }}
>> {{ TODAY|date:"SHORT_DATE_FORMAT" }}
>>
>> Which unexpectedly outputs this:
>>
>> ('en_GB', 'UTF-8')
>> %d/%m/%y
>> 09/18/2014
>>
>> I also tried adding the locale.setlocale(...) line to my settings.py 
>> instead but that had no effect either.
>>
>> Any ideas appreciated please. 
>>
>> Thanks
>> Jay
>>
>> On 17 September 2014 07:38, James Hargreaves > > wrote:
>>
>>> Thanks Ulrich.
>>>
>>> No I think I've misread the documentation with regards it affecting the 
>>> whole environment rather than the program.
>>>
>>> I'll try your solution myself but it looks like it will work, thanks!
>>>
>>> Jay
>>>
>>>
>>> On Tuesday, September 16, 2014, uvetter >> > wrote:
>>>
 Dear Jay,

 I just tried to following in my wsgi.py file:


 import os
 import sys
 import site
 import locale

 site.addsitedir('/mypath/lib/python3.3/site-packages')

 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")

 os.environ['HTTPS'] = "on"

 sys.path.append('/mypath/test')
 sys.path.append('/mypath/test/test')
 sys.path.append('/mypath/test/app1')
 sys.path.append('/mypath/test/app2')

 activate_env=os.path.expanduser("/mypath/bin/activate_this.py")
 exec(open(activate_env).read())

 locale.setlocale(locale.LC_ALL, 'en_US.utf-8')

 from django.core.wsgi import get_wsgi_application
 application = get_wsgi_application()



 This sets the locale correctly for all calls to my Django application. 

 I just realized that in your first post you mentioned that "this 
 affects the entire environment". I just read through the locale module 
 documentation, which states that "The C standard defines the locale as a 
 program-wide property ". This means that there will be no system-wide 
 changes when you call locale.setenv(). Or did I misunderstand you?

 Best wishes,
 Ulrich 

 Am Dienstag, 16. September 2014 22:39:08 UTC+2 schrieb James Hargreaves:
>
> Thanks for your reply Ulrich.
>
> If I set the locale in WSGI would that persist for all connections? If 
> so that sounds like the best option.
>
> Thanks
> Jay
>
> On Tuesday, September 16, 2014,  wrote:
>
>> Hi, 
>> I ran into a similar problem yesterday while programming a web shop 
>> with Django (Version 1.6, Python version 3.3) where language switching 
>> should immediately have an effect on the way prices, etc. are displayed 
>> (doing so by a  in the 
>> template and redirecting back to the page where it was called). The 
>> locale 

Re: Can I use a calculated value for a key to a dictionary?

2014-09-19 Thread James Schneider
Instead of "for team in {{l}}{{d}}" you should be able to do "for team in
l.d" IIRC.

TBH I haven't tried it and I'm on my phone so I can't run a quick check.
This SO post also has some hints on running nested loops:
http://stackoverflow.com/questions/13870890/django-template-counter-in-nested-loops

-James


On Thursday, September 18, 2014, Joel Goldstick 
wrote:

> I have some embed loops which iterate over league and division.  I
> want to print the teams in each.  I obviously can't do what i tried in
> line 19.  Is there a way to calculate a key to a dictionary I want to
> iterate over?
>
> 14{% for l in leagues %}
> 15 {{l}}
> 16 {% for d in divisions %}
> 17 {{d}}
> 18 
> 19 {% for team in {{l}}{{d}} %}
> 20 {{team}} {{ team.wins }}-{{ team.losses
> }} 
> 21 {% endfor %}
>
> Here is my context:
>
> {u'ALW': [,  1975>, , ,
> , ],
> u'ALE': [, ,
> , ,  Milwaukee Brewers 1975>, ], u'NLE': [ Pittsburgh Pirates 1975>, ,  New York Mets 1975>, ,  Cubs 1975>, ], u'NLW': [ Reds 1975>, ,  Giants 1975>, ,  1975>, ]}
> {'leagues': [u'AL', u'NL'], u'NLE': [,
> , ,  St. Louis Cardinals 1975>, ,  Expos 1975>], u'NLW': [,  Angeles Dodgers 1975>, ,  Diego Padres 1975>, ,  1975>], 'year': u'1975', u'ALW': [,
> , ,  Minnesota Twins 1975>, ,  California Angels 1975>], u'ALE': [,  Baltimore Orioles 1975>, ,  Cleveland Indians 1975>, ,  Detroit Tigers 1975>], 'divisions': [u'E', u'W']}
>
> --
> Joel Goldstick
> http://joelgoldstick.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/CAPM-O%2ByfS1BfDCEKYbJOwctjtd8JkJ04OS71iv4dVtVRQf8KRA%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/CA%2Be%2BciV2AysQkXhmhzt1yXa-afxCR1QGRB2icXdVPXT4CZ6N2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can I use a calculated value for a key to a dictionary?

2014-09-19 Thread James Schneider
Scratch that, I misread what you were trying to do, but became clear when I
looked at your context a bit closer. You want to concatenate two strings
and use that as the variable lookup.

You can probably do that using a combination of the {% with %} tag and the
'add' filter (which works on strings too), something like this:

{% with div=l|add:d %}

https://docs.djangoproject.com/en/1.7/ref/templates/builtins/#with

That's a L next to a pipe (|), in the event it isn't clear due to your
variable name in the outer loop.

You may also need to build your context slightly different, and put the
leagues you are trying to access within their own dict rather than at the
top level of the context since you don't know what they will be named. Then
you can put the following under the {% with %} tag:

{% for team in league_dict.div %}

Again, haven't tested so YMMV.

-James

On Friday, September 19, 2014, James mSchneider 
wrote:

> Instead of "for team in {{l}}{{d}}" you should be able to do "for team in
> l.d" IIRC.
>
> TBH I haven't tried it and I'm on my phone so I can't run a quick check.
> This SO post also has some hints on running nested loops:
>
> http://stackoverflow.com/questions/13870890/django-template-counter-in-nested-loops
>
> -James
>
>
> On Thursday, September 18, 2014, Joel Goldstick  > wrote:
>
>> I have some embed loops which iterate over league and division.  I
>> want to print the teams in each.  I obviously can't do what i tried in
>> line 19.  Is there a way to calculate a key to a dictionary I want to
>> iterate over?
>>
>> 14{% for l in leagues %}
>> 15 {{l}}
>> 16 {% for d in divisions %}
>> 17 {{d}}
>> 18 
>> 19 {% for team in {{l}}{{d}} %}
>> 20 {{team}} {{ team.wins }}-{{ team.losses
>> }} 
>> 21 {% endfor %}
>>
>> Here is my context:
>>
>> {u'ALW': [, > 1975>, , ,
>> , ],
>> u'ALE': [, ,
>> , , > Milwaukee Brewers 1975>, ], u'NLE': [> Pittsburgh Pirates 1975>, , > New York Mets 1975>, , > Cubs 1975>, ], u'NLW': [> Reds 1975>, , > Giants 1975>, , > 1975>, ]}
>> {'leagues': [u'AL', u'NL'], u'NLE': [,
>> , , > St. Louis Cardinals 1975>, , > Expos 1975>], u'NLW': [, > Angeles Dodgers 1975>, , > Diego Padres 1975>, , > 1975>], 'year': u'1975', u'ALW': [,
>> , , > Minnesota Twins 1975>, , > California Angels 1975>], u'ALE': [, > Baltimore Orioles 1975>, , > Cleveland Indians 1975>, , > Detroit Tigers 1975>], 'divisions': [u'E', u'W']}
>>
>> --
>> Joel Goldstick
>> http://joelgoldstick.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/CAPM-O%2ByfS1BfDCEKYbJOwctjtd8JkJ04OS71iv4dVtVRQf8KRA%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/CA%2Be%2BciXujKONyjxV_vfysRv2NCmfq4r6ug6s992AwqknYQmR%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Retrieving recurring events using Django queries

2014-09-19 Thread Stodge
I have the following to model a calendar entry (recurring event). I need 
the ability to retrieve all events from the database between a start and 
end date. This has to include one off events and also recurring "virtual" 
events that occur because of an event in the database. Do you think this is 
possible using Django queries? Or do I need to retrieve the objects from 
the DB and then calculate the recurring events in the range in plain python 
using something like dateutil? I've been racking my brains but I can't seem 
to work out how to do it. Any suggestions appreciated.

class CalendarEntry(models.Model):

REPEAT_CHOICES = (
('NONE',_('None')),
('DAILY',_('Daily')),
('WEEKDAY',  _('Every weekday')),
('WEEKLY',   _('Weekly')),
('BIWEEKLY', _('Fortnightly')),
('MONTHLY',  _('Monthly')),
('YEARLY',   _('Yearly')),
)

# Mappings between content and an event entry.
content_type= models.ForeignKey(ContentType, verbose_name='content 
type')
object_id   = models.PositiveIntegerField()
content_object  = generic.GenericForeignKey('content_type', 'object_id')
field   = models.CharField(max_length=64)

# Basic event information.
start_date = TimestampGMT(blank=True, null=True)
end_date = TimestampGMT(blank=True, null=True)

# Recurrence information.
all_day = models.BooleanField()
repeat = models.CharField(max_length=15, choices=REPEAT_CHOICES, 
default='NEVER')
end_repeat = models.DateTimeField(_("end repeat"), null=True, 
blank=True)





-- 
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/293df7ca-1192-49e2-8d94-d133bb1d5057%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Retrieving recurring events using Django queries

2014-09-19 Thread Sanjay Bhangar
hey Stodge,

Interesting question :)

My guess is there are probably a number of approaches one can take. Of
course, processing all your entries in python "on the fly" would
probably get to be quite an intensive operation.

One possible idea maybe to create a "cache" table of sorts where you
pre-calculate and store all possible dates for a CalendarEntry.

Something like:

class EventDate(models.Model):
date = models.DateField(..)
calendarentry = models.ForeignKey(CalendarEntry)

Then, in the post_save of CalendarEntry, you write some code to
calculate all possible dates for the event and populate the EventDate
table. The problem is:
  a> If the CalendarEntry does not have an end_date, you obviously
cannot calculate all dates until the end of eternity - you would have
to come up with a reasonable "end date" beyond which queries are not
possible and only populate EventDate until that point (perhaps
updating it for the future with a cron job or some such .. )
  b> Generating the EventDates and the associated database INSERTs
could get quite intensive, especially, for say, a daily event for the
next 5 years, etc. If that gets to be a problem, you may need to do
this out of the request-response cycle, using for eg. django-celery.

Once you have that table, of course, querying would be something like
CalendarEntry.objects.filter(eventdate__date=date) , etc..

This is likely not the most elegant solution - not sure if there's a
better way to do it, or some efficient way to do the query directly in
the database without the overhead of maintaining this 'cache' table.

Would love to hear if anyone has an elegant solution to this - else
what I've outlined above should work, though it doesn't feel 100%
right, especially the part about needing some arbitrary cut-off date
to prevent an infinite generation of EventDate entries ..

Please do share what you land up coming up with.

All the best.
-Sanjay

On Fri, Sep 19, 2014 at 6:13 PM, Stodge  wrote:
> I have the following to model a calendar entry (recurring event). I need the
> ability to retrieve all events from the database between a start and end
> date. This has to include one off events and also recurring "virtual" events
> that occur because of an event in the database. Do you think this is
> possible using Django queries? Or do I need to retrieve the objects from the
> DB and then calculate the recurring events in the range in plain python
> using something like dateutil? I've been racking my brains but I can't seem
> to work out how to do it. Any suggestions appreciated.
>
> class CalendarEntry(models.Model):
>
> REPEAT_CHOICES = (
> ('NONE',_('None')),
> ('DAILY',_('Daily')),
> ('WEEKDAY',  _('Every weekday')),
> ('WEEKLY',   _('Weekly')),
> ('BIWEEKLY', _('Fortnightly')),
> ('MONTHLY',  _('Monthly')),
> ('YEARLY',   _('Yearly')),
> )
>
> # Mappings between content and an event entry.
> content_type= models.ForeignKey(ContentType, verbose_name='content
> type')
> object_id   = models.PositiveIntegerField()
> content_object  = generic.GenericForeignKey('content_type', 'object_id')
> field   = models.CharField(max_length=64)
>
> # Basic event information.
> start_date = TimestampGMT(blank=True, null=True)
> end_date = TimestampGMT(blank=True, null=True)
>
> # Recurrence information.
> all_day = models.BooleanField()
> repeat = models.CharField(max_length=15, choices=REPEAT_CHOICES,
> default='NEVER')
> end_repeat = models.DateTimeField(_("end repeat"), null=True,
> blank=True)
>
>
>
>
>
> --
> 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/293df7ca-1192-49e2-8d94-d133bb1d5057%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/CAG3W7ZGzvqtbYk_8_aHiZseq%2B1eg5tTcRxm%3DvR3j8ZSURjqAEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can I use a calculated value for a key to a dictionary?

2014-09-19 Thread Tom Evans
On Fri, Sep 19, 2014 at 11:13 AM, James Schneider
 wrote:
> Scratch that, I misread what you were trying to do, but became clear when I
> looked at your context a bit closer. You want to concatenate two strings and
> use that as the variable lookup.
>
> You can probably do that using a combination of the {% with %} tag and the
> 'add' filter (which works on strings too), something like this:
>
> {% with div=l|add:d %}
>
> https://docs.djangoproject.com/en/1.7/ref/templates/builtins/#with
>
> That's a L next to a pipe (|), in the event it isn't clear due to your
> variable name in the outer loop.
>
> You may also need to build your context slightly different, and put the
> leagues you are trying to access within their own dict rather than at the
> top level of the context since you don't know what they will be named. Then
> you can put the following under the {% with %} tag:
>
> {% for team in league_dict.div %}

This will not work, Django will not interpolate "div" to the value of
the "div" variable, it will look for an attribute (etc.) explicitly
called "div" on "league_dict".

It is easily doable by adding an additional template tag, usually
called something like dict_get. If you STFW, you will probably find an
implementation of it, probably from me...

https://groups.google.com/forum/#!topic/django-users/b0t9leTQyBA

It is not included in Django for ideological reasons - it is
considered better form to prepare your data correctly in the view than
manipulate it in the template.

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


Custom change_form.html

2014-09-19 Thread Salvatore DI DIO
Hello,

*To follow my preceding question, on customize admin view, (*Helton Alves 
gave me a nice response).
I am wondering how to filter a list in change_form.html  admin  form, 
according to a partuculiar user ?

Thank you for your help

Regards




-- 
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/3e916af0-17f8-4642-b226-aca71a08b289%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Retrieving recurring events using Django queries

2014-09-19 Thread Derek Rodger
Take a look at:
https://github.com/llazzaro/django-scheduler

also available on PyPI:
pypi.python.org/pypi/django-scheduler/

It's very similar to what you have done so far. It handles virtual events 
('occurrences') by generating them on the fly for a requested date range. 
Individual occurrences can be saved if needed (ie, someone adds a note, or 
changes the start/end time of a particular occurrence).


On Friday, 19 September 2014 06:01:48 UTC-7, Sanjay Bhangar wrote:
>
> hey Stodge, 
>
> Interesting question :) 
>
> My guess is there are probably a number of approaches one can take. Of 
> course, processing all your entries in python "on the fly" would 
> probably get to be quite an intensive operation. 
>
> One possible idea maybe to create a "cache" table of sorts where you 
> pre-calculate and store all possible dates for a CalendarEntry. 
>
> Something like: 
>
> class EventDate(models.Model): 
> date = models.DateField(..) 
> calendarentry = models.ForeignKey(CalendarEntry) 
>
> Then, in the post_save of CalendarEntry, you write some code to 
> calculate all possible dates for the event and populate the EventDate 
> table. The problem is: 
>   a> If the CalendarEntry does not have an end_date, you obviously 
> cannot calculate all dates until the end of eternity - you would have 
> to come up with a reasonable "end date" beyond which queries are not 
> possible and only populate EventDate until that point (perhaps 
> updating it for the future with a cron job or some such .. ) 
>   b> Generating the EventDates and the associated database INSERTs 
> could get quite intensive, especially, for say, a daily event for the 
> next 5 years, etc. If that gets to be a problem, you may need to do 
> this out of the request-response cycle, using for eg. django-celery. 
>
> Once you have that table, of course, querying would be something like 
> CalendarEntry.objects.filter(eventdate__date=date) , etc.. 
>
> This is likely not the most elegant solution - not sure if there's a 
> better way to do it, or some efficient way to do the query directly in 
> the database without the overhead of maintaining this 'cache' table. 
>
> Would love to hear if anyone has an elegant solution to this - else 
> what I've outlined above should work, though it doesn't feel 100% 
> right, especially the part about needing some arbitrary cut-off date 
> to prevent an infinite generation of EventDate entries .. 
>
> Please do share what you land up coming up with. 
>
> All the best. 
> -Sanjay 
>
> On Fri, Sep 19, 2014 at 6:13 PM, Stodge > 
> wrote: 
> > I have the following to model a calendar entry (recurring event). I need 
> the 
> > ability to retrieve all events from the database between a start and end 
> > date. This has to include one off events and also recurring "virtual" 
> events 
> > that occur because of an event in the database. Do you think this is 
> > possible using Django queries? Or do I need to retrieve the objects from 
> the 
> > DB and then calculate the recurring events in the range in plain python 
> > using something like dateutil? I've been racking my brains but I can't 
> seem 
> > to work out how to do it. Any suggestions appreciated. 
> > 
> > class CalendarEntry(models.Model): 
> > 
> > REPEAT_CHOICES = ( 
> > ('NONE',_('None')), 
> > ('DAILY',_('Daily')), 
> > ('WEEKDAY',  _('Every weekday')), 
> > ('WEEKLY',   _('Weekly')), 
> > ('BIWEEKLY', _('Fortnightly')), 
> > ('MONTHLY',  _('Monthly')), 
> > ('YEARLY',   _('Yearly')), 
> > ) 
> > 
> > # Mappings between content and an event entry. 
> > content_type= models.ForeignKey(ContentType, 
> verbose_name='content 
> > type') 
> > object_id   = models.PositiveIntegerField() 
> > content_object  = generic.GenericForeignKey('content_type', 
> 'object_id') 
> > field   = models.CharField(max_length=64) 
> > 
> > # Basic event information. 
> > start_date = TimestampGMT(blank=True, null=True) 
> > end_date = TimestampGMT(blank=True, null=True) 
> > 
> > # Recurrence information. 
> > all_day = models.BooleanField() 
> > repeat = models.CharField(max_length=15, choices=REPEAT_CHOICES, 
> > default='NEVER') 
> > end_repeat = models.DateTimeField(_("end repeat"), null=True, 
> > blank=True) 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > 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/293df7ca-1192-49e2-8d94-d133bb1d5057%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/

Re: Possible bug introduced in Django 1.7 admin/docs?

2014-09-19 Thread Christopher Welborn
On 09/18/2014 10:50 PM, James Bennett wrote:
> Are you using any third-party libraries which were installed as eggs?
> 

Sorry, but was that supposed to be a hint to say "Don't use eggs"? I can
see why it may fail looking for '__file__', but I don't understand
why that is acceptable. Surely there should be some graceful error
handling in the case that '__file__' is not available, instead of a
hard 500 internal server error.

Like if a third-party extension errors while looking for tags and
filters, the extension would be skipped instead of halting.

This is what made me think it was a bug. I don't want to file one if
it's not though, so could someone enlighten me please? I am being
sincere. Maybe I could even offer a patch for it.

-- 
\¯\  /¯/\
 \ \/¯¯\/ / / Christopher Welborn (cj)
  \__/\__/ /  cjwelborn at live·com
   \__/\__/   http://welbornprod.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/lvhrv9%247v8%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.


Possible Bug - PositiveSmallIntegerField Enables Saving Negative Values

2014-09-19 Thread Sy K.
I have generated a very simple test project using a fresh copy Django 1.7.0 
with a model that has a PositiveSmallIntegerField, it is attached to this 
post. The ORM is not preventing instances being created with that field's 
value set to -1

>>> django.VERSION

(1, 7, 0, 'final', 0)

$ python manage.py shell

Python 2.7.8 (default, Aug 24 2014, 21:26:19) 

[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

(InteractiveConsole)

>>> from snapple.models import Snapple

>>> x = Snapple.objects.create(x=-1)  # x ought to be a 
PositiveSmallIntegerField

>>> x.x

-1

>>> 

-- 
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/569c70c9-b283-4e89-9f46-ed8fc397798b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
from django.db import models

# Create your models here.

class Snapple(models.Model):

x = models.PositiveSmallIntegerField()


Can not understand how to change auth.templates

2014-09-19 Thread Артём Мутерко
I want to redirect user after logout to another page, not account/logout. 
Hoe can I do this?
I've red documentation, but can't understand where to find next_page 
variable

-- 
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/12b8f446-3beb-4283-9761-2b552f929915%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sitemaps - multiple locations per object

2014-09-19 Thread Collin Anderson
Something like this might work:

class MySitemap(sitemaps.Sitemap):
def items(self):
urls = []
for obj in Store.objects.all():
urls.append((obj, ''))
urls.append((obj, 'about'))
urls.append((obj, 'contact'))
return urls

def location(self, info):
return '/store/%s/%s/' % info[0], info[1]




-- 
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/1ec8449c-5893-468f-982f-1f25454fc1e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Struggling with One to One relationships

2014-09-19 Thread Collin Anderson
Yes, this seems to be the usual problem with inheritance.

You need to do something scary like 
workshop_job.__dict__.update(job.__dict__) so that your workshop_job object 
will actually have all of the info from the job, like date_opened.

-- 
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/6fbb336e-bd13-4e94-bbfd-88c7bbe4be32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Simple task. Get request.META values listed on a page via template

2014-09-19 Thread Collin Anderson
You can't get it sorted (you would need a template filter for that), but:

{% for k, v in request.META.items %}{{ k }}{{ v }}{% 
endfor %}

-- 
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/8fbf855f-96f1-4762-a4a5-336d290d32b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.6 Nginx with static files outside project folder

2014-09-19 Thread Collin Anderson
so if you go to http://myproject.de:8001/static/some-file-in-myproject.css 
it works fine, but if you go 
to http://myproject.de:8001/static/admin/js/jquery.js you get a 404 Not 
Found?

Are the files you're looking for actually in webapps/sonar3/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/279a5916-14ed-4136-bc59-1fe54782235c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unicode problems in admin interface

2014-09-19 Thread Collin Anderson
Are you uploading a file using apache? It could be the /etc/apache2/envvars 
issue.

Are you ever using string formatting like "something %s something" % 
something ? If so, use unicode_literals or change that to a unicode string: 
u"something %s something" % something

-- 
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/f2c7c2e5-9d58-4e31-a015-45eb38b0bbba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: new to django data modeling for an application

2014-09-19 Thread Collin Anderson
class Dish(models.Model):
resturant = models.ForeignKey(Resturant)
name = models.CharField(max_length=255)

-- 
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/32716cac-3458-4756-9f95-7595c022bcb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 1.7: inlines not deleted when save_formset is overridden

2014-09-19 Thread Collin Anderson
Wow. It took a lot of digging, but your situation is documented in 
https://docs.djangoproject.com/en/1.7/topics/forms/formsets/#django.forms.formsets.BaseFormSet.can_delete

another thing that might also work in your case:

def save_formset(self, request, form, formset, change):
for form in formset.forms:
form.instance.user = request.user
formset.save()

-- 
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/5bcd9722-2132-4e5a-a4e4-4ced092748c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin doesn't show all entities

2014-09-19 Thread Collin Anderson
This happened to me once when using django.contrib.comments. It turned out 
there was an exception happening in the template rendering that was getting 
silenced.

-- 
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/f59d815b-67db-41ff-a08a-eea5d98447c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom change_form.html

2014-09-19 Thread Collin Anderson
if nothing else:

{% for item in list %}{% if item.user = user %}

{% endif %}{% endfor %}

-- 
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/09cc77ee-3fb8-433b-b80c-385d1d9f8cee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Possible Bug - PositiveSmallIntegerField Enables Saving Negative Values

2014-09-19 Thread Collin Anderson
Yes. I believe that type of validation only happens in forms, or if you 
manually call obj.full_clean().

-- 
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/102e627a-b1b6-4d7b-98e1-2bdccbd59fd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can not understand how to change auth.templates

2014-09-19 Thread Collin Anderson
from django.contrib.auth.views import logout

urlpatterns = [
url('^/accounts/logout/', logout, {'next_page': '/'}),
]

-- 
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/13163425-bc3d-4ba9-b780-5f5dbd49cc27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can not understand how to change auth.templates

2014-09-19 Thread Collin Anderson
or send them to /accounts/logout/?next=/another/page/

-- 
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/aecb07eb-dfc9-4ace-b168-9a03b5468d6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Any stable and trusted packages for python XML?

2014-09-19 Thread Chen Xu
Hi Everyone,
I wonder if there is any good, stable and trusted django or python package
that can convert dict to  xml, and load xml into dict, just like what the
json package does.

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


Re: Struggling with One to One relationships

2014-09-19 Thread Lachlan Musicman
Ah! OK, it's not just me then. Good.

It's a usual inheritance problem? I've never seen it with o2m or m2m
relations? I think I'll just change them to o2m and check to make sure
there's only one in the save method - seems clearer -easier to read
for !me, and less scary.

Thanks for your help

L.

On 20 September 2014 08:43, Collin Anderson  wrote:
> Yes, this seems to be the usual problem with inheritance.
>
> You need to do something scary like
> workshop_job.__dict__.update(job.__dict__) so that your workshop_job object
> will actually have all of the info from the job, like date_opened.
>
> --
> 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/6fbb336e-bd13-4e94-bbfd-88c7bbe4be32%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+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/CAGBeqiOn4%2B36eH_qiNiZRc9wHhv3KXaLkrGsAcB0GHWBpf%3DTtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Possible bug introduced in Django 1.7 admin/docs?

2014-09-19 Thread Russell Keith-Magee
On Sat, Sep 20, 2014 at 2:17 AM, Christopher Welborn 
wrote:

> On 09/18/2014 10:50 PM, James Bennett wrote:
> > Are you using any third-party libraries which were installed as eggs?
> >
>
> Sorry, but was that supposed to be a hint to say "Don't use eggs"? I can
> see why it may fail looking for '__file__', but I don't understand
> why that is acceptable. Surely there should be some graceful error
> handling in the case that '__file__' is not available, instead of a
> hard 500 internal server error.
>
> Like if a third-party extension errors while looking for tags and
> filters, the extension would be skipped instead of halting.
>
> This is what made me think it was a bug. I don't want to file one if
> it's not though, so could someone enlighten me please? I am being
> sincere. Maybe I could even offer a patch for it.
>

Everything you say is true. Errors of this nature *can* be caught, and
*could* be worked around. This sort of error *could* be considered a bug.

However, the experience of the Django core team over the last 9 years has
been that eggs are just more trouble than they're worth. We've tried to
accommodate them in the past in various ways  - there is, for example an
egg-based template loader.

I doubt we'd close egg-related issues as a wontfix - but they're also not
getting a whole lot of attention, either. We don't pre-emptively do a whole
lot of specific testing for egg-related problems. If someone reports a
problem and provides a fix and test, we'll include it in our codebase; but
actively looking for egg-related issues isn't high on the priority list.

This is then compounded by the fact that the use of eggs is generally
decreasing. They were popular 10 years ago when easy_install was king;
these days, we use pip install, and wheels are the endorsed Python way for
installing packages.

So - James' comment should be interpreted as "Are you using eggs? Well,
there's your first problem". If you're actually using eggs, I'd strongly
encourage you to consider why, because there's almost certainly a better
way to distribute your code, and that way won't involve the random bugs
that eggs introduce.

Also - to clarify; existence of an .egg-info file doesn't *necessarily*
mean you're using an egg - for historical reasons, the .egg-info file is
used for other packaging purposes.

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


Re: Possible bug introduced in Django 1.7 admin/docs?

2014-09-19 Thread Christopher Welborn
On 09/19/2014 08:26 PM, Russell Keith-Magee wrote:
> So - James' comment should be interpreted as "Are you using eggs? Well,
> there's your first problem". If you're actually using eggs, I'd strongly
> encourage you to consider why, because there's almost certainly a better
> way to distribute your code, and that way won't involve the random bugs
> that eggs introduce.
> 
> Also - to clarify; existence of an .egg-info file doesn't *necessarily*
> mean you're using an egg - for historical reasons, the .egg-info file is
> used for other packaging purposes.
> 
> Yours,
> Russ Magee %-)
> 

Thank you for that response. You spelled it out perfectly. I'll look
into my libraries and installation methods to see if there is something
I can do on my end to help with my error.

-- 
\¯\  /¯/\
 \ \/¯¯\/ / / Christopher Welborn (cj)
  \__/\__/ /  cjwelborn at live·com
   \__/\__/   http://welbornprod.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/lviq4j%24tau%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.


Re: Turn off migrations completely in Django 1.7

2014-09-19 Thread Anthony Tuininga
Hmm, the problem is that there doesn't appear to be any way to turn off the 
creation of the migrations table itself, even if all of the other models 
are set to managed=False as suggested by Nikolas. I've commented it out for 
now but it would be ideal to have some way of turning it off completely -- 
or simply doing nothing if there are no managed models.

On Thursday, September 18, 2014 5:27:45 PM UTC-6, mike wrote:
>
> Hi, 
>
> I feel your pain, but I think you can utilize something with --fake 
>
> I have been using databases for many, many years, and honestly- 
> migrations definitely make sense. I am able to add new fields within a 
> few seconds without having to do any extra work. It takes 2 minutes to 
> learn how to use migrations, and I will personally never look back. 
>
> Mike 
>
>
>
> On Thu, Sep 18, 2014 at 5:04 PM, Anthony Tuininga 
> > wrote: 
> > Hi, 
> > 
> > I just upgraded my test environment to Django 1.7 and immediately 
> noticed 
> > that mgirations appear to be a requirement. Searching the documentation 
> and 
> > the code itself seems to indicate that there is no way to disable it, 
> > either. Did I miss something? I don't need or want Django to create or 
> alter 
> > any database objects and up to Django 1.6 I could quite happily ignore 
> > syncdb but it seems I can't ignore migrations. Please advise! Thanks. 
> > 
> > Anthony 
> > 
> > -- 
> > 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/9bdd258f-a21b-48a0-ab1b-b3a4123b40c1%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/1b63e451-15bd-46be-bd93-2a8bca9d3780%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Any stable and trusted packages for python XML?

2014-09-19 Thread Timothy W. Cook
XML is more complex than JSON and AFAIK there isn't a generic tool to do
this.  I work with XML all the time with Python/Django and I would only
recommend lxml http://lxml.de/



On Fri, Sep 19, 2014 at 9:39 PM, Chen Xu  wrote:

> Hi Everyone,
> I wonder if there is any good, stable and trusted django or python package
> that can convert dict to  xml, and load xml into dict, just like what the
> json package does.
>
> 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-qbM%3DXx4NX%2BSCsyfdJ8UxdKNLbETFj2FAH8q3czixtxA4A%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

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


Re: Possible Bug - PositiveSmallIntegerField Enables Saving Negative Values

2014-09-19 Thread Patti Chen
I guess you're probably using SQLite as the database engine. "unsigned
integer" and "signed integer" belong to same affinity in SQLite
(http://www.sqlite.org/datatype3.html). Even if you specify "unsigned
int" for the column during creation, you can save negative values
without any error.
If you use MySQL or PostgrSQL, the exception will be raised.

On Sat, Sep 20, 2014 at 7:39 AM, Collin Anderson  wrote:
> Yes. I believe that type of validation only happens in forms, or if you
> manually call obj.full_clean().
>
> --
> 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/102e627a-b1b6-4d7b-98e1-2bdccbd59fd4%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/CAN1WgRKRQwaWBDN7DGOajpjuZhYyryhH5SXz7UiS%3DNDgzOi9ZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.