groups and permissions data migrations?

2014-10-14 Thread Michael
Hi,

Since the permissions are not yet created when the migrations are run, it 
is not possible to have a data migration that creates a group and assigns 
permissions.

Based on this ticket: https://code.djangoproject.com/ticket/23422, I 
understand there will not be a fix. Do you recommend to keep using an 
initial fixture to create a group?

Thanks
Michael

-- 
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/a589e6e3-48a6-464f-9be7-298adf9cde7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Using data migration to create initial users errors

2014-10-14 Thread BenW
I am trying to create initial users in Django 1.7 via a simple data 
migration like so:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models, migrations


def populate_initial_data(apps, schema_editor):


User = apps.get_model(settings.AUTH_USER_MODEL)
Group = apps.get_model('auth', 'Group')

user = User.objects.create_user("test", email="t...@test.com", 
password="test")
# AttributeError: 'Manager' object has no attribute 'create_user'

group = Group.objects.create(name="Test Group")
user.groups.add(group)


class Migration(migrations.Migration):

dependencies = [
('auth', '__first__')
]

operations = [
migrations.RunPython(populate_initial_data)
]


However the instance of User does not have a UserManager, but rather a 
vanilla Manager object?

Possibly related problem, if I instead retrieve User via get_user_model() 
then I get a type error attempting to add that user to a group, like so:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models, migrations


def populate_initial_data(apps, schema_editor):


User = get_user_model()
Group = apps.get_model('auth', 'Group')

user = User.objects.create_user("test", email="t...@test.com", 
password="test")
group = Group.objects.create(name="Test Group")
user.groups.add(group)
# TypeError: 'Group' instance expected, got 


class Migration(migrations.Migration):

dependencies = [
('auth', '__first__')
]

operations = [
migrations.RunPython(populate_initial_data)
]


I'm trying to replace the functionality of fixtures, which has apparently 
been deprecated with apps that use migrations.


Thanks!

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


save as new in the Admin with 1:1 inlines causes IntegrityError

2014-10-14 Thread Mike Dewhirst
Using Django 1.6.7, in the Admin if I change the name of an object (in 
this case "substance") with 1:1 relationships and click [Save as new] I 
get an integrity error[1]. This was working in Django 1.5.x.


Before I put in the effort to roll back to 1.5 for proof I thought I'd 
check the docs and found this with a "Changed in Django 1.6" note ...


https://docs.djangoproject.com/en/1.6/ref/models/instances/#how-django-knows-to-update-vs-insert

Does anyone have a suggestion?

The interactive traceback indicates my save() method on one of the 1:1 
models (in this case "gas") is triggering the problem. See below.


Thanks for any pointers

Mike

- - - - - - - - - - - -

[1] Environment:


Request Method: POST
Request URL: http://localhost:8000/admin/substance/substance/17/

Django Version: 1.6.7
Python Version: 2.7.6
Installed Applications:
(u'django.contrib.auth',
 u'django.contrib.contenttypes',
 u'django.contrib.sessions',
 u'django.contrib.sites',
 u'django.contrib.messages',
 u'django.contrib.admin',
 u'django.contrib.admindocs',
 u'django.contrib.staticfiles',
 u'common',
 u'company',
 u'refer',
 u'substance',
 u'workplace')
Installed Middleware:
(u'django.middleware.cache.UpdateCacheMiddleware',
 u'django.contrib.sessions.middleware.SessionMiddleware',
 u'django.middleware.locale.LocaleMiddleware',
 u'django.middleware.common.CommonMiddleware',
 u'django.middleware.transaction.TransactionMiddleware',
 u'django.middleware.csrf.CsrfViewMiddleware',
 u'django.contrib.auth.middleware.AuthenticationMiddleware',
 u'django.contrib.messages.middleware.MessageMiddleware',
 u'django.middleware.doc.XViewMiddleware',
 u'django.middleware.clickjacking.XFrameOptionsMiddleware',
 u'django.middleware.cache.FetchFromCacheMiddleware')


Traceback:
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\core\handlers\base.py" 
in get_response
  112. response = wrapped_callback(request, 
*callback_args, **callback_kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\contrib\admin\options.py" 
in wrapper
  452. return self.admin_site.admin_view(view)(*args, 
**kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\utils\decorators.py" in 
_wrapped_view

  99. response = view_func(request, *args, **kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\views\decorators\cache.py" 
in _wrapped_view_func

  52. response = view_func(request, *args, **kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\contrib\admin\sites.py" 
in inner

  198. return view(request, *args, **kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\utils\decorators.py" in 
_wrapper

  29. return bound_func(*args, **kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\utils\decorators.py" in 
_wrapped_view

  99. response = view_func(request, *args, **kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\utils\decorators.py" in 
bound_func

  25. return func(self, *args2, **kwargs2)
File "C:\Users\mike\env\xxdx\lib\site-packages\django\db\transaction.py" 
in inner

  371. return func(*args, **kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\contrib\admin\options.py" 
in change_view
  1224. 
current_app=self.admin_site.name))
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\utils\decorators.py" in 
_wrapper

  29. return bound_func(*args, **kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\utils\decorators.py" in 
_wrapped_view

  99. response = view_func(request, *args, **kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\utils\decorators.py" in 
bound_func

  25. return func(self, *args2, **kwargs2)
File "C:\Users\mike\env\xxdx\lib\site-packages\django\db\transaction.py" 
in inner

  371. return func(*args, **kwargs)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\contrib\admin\options.py" 
in add_view

  1152. self.save_related(request, form, formsets, False)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\contrib\admin\options.py" 
in save_related

  904. self.save_formset(request, form, formset, change=change)
File 
"C:\Users\mike\env\xxdx\lib\site-packages\django\contrib\admin\options.py" 
in save_formset

  892. formset.save()
File "C:\Users\mike\env\xxdx\lib\site-packages\django\forms\models.py" 
in save
  618. return self.save_existing_objects(commit) + 
self.save_new_objects(commit)
File "C:\Users\mike\env\xxdx\lib\site-packages\django\forms\models.py" 
in save_new_objects
  747. self.new_objects.append(self.save_new(form, 
commit=commit))
File "C:\Users\mike\env\xxdx\lib\site-packages\django\forms\models.py" 
in save_new

  877. obj.save()
File "C:\Users\mike\env\xxdx\ssds\substance\models\gas.py" in save
  168. super(Gas, self).save(*args, 

Re: django email client (reusable app) kickstarter

2014-10-14 Thread Internet Profil Filip Kowalski
You are right, we will provide support for all db backends. Extra 
functionality that is fully possible only with Postgres (e.g. use of 
GeoDjango) will require that backend. Core features mentioned in 
kickstarter description will work everywhere.


Filip Kowalski
Internet Profil
www.internetprofil.pl 
mob. 506 385 326
tel. 58 661 11 62
skype: easy-r1der
ul. Śląska 53
81-304 Gdynia
VAT EU: PL586-203-45-48
W dniu 2014-10-13 o 18:13, Scot Hacker pisze:



On Monday, October 13, 2014 4:18:52 AM UTC-7, biuro wrote:



perhaps I run out too far in the future and this should be put on
a different database.
what do you think guys?


I think that database independence is a core feature of Django and of 
virtually every reusable app. Your project is designed (I assume) to 
be integrated into existing Django projects. By tying yourself to one 
database, your app is not being a good Django community citizen, and 
will be unusable by hundreds of thousands of existing Django projects 
that don't use postgres.


If you find down the line that your app absolutely must have some 
pg-specific features, I recommend making those into *optional* 
features that can be enabled for qualifying users.


./s

--
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/1f8d0f7f-9e61-4fb4-ad7b-c5684cfab833%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/543D9E8A.8060009%40internetprofil.pl.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to import 3 modules when running tests

2014-10-14 Thread Jason Ridenour
Are you running on Windows? I noticed you are using django-mssql.

I'm having the same issue you are having - I'm using:
django 1.7
Python 2.7
Windows 7
django-mssql 1.6

I'm thinking it's either an issue with the windows install of django or 
with django-mssql

-- 
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/dc57e5e2-ac91-4cdc-a608-d221db294226%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django language tag

2014-10-14 Thread 6233114 6233114
Hello,

There is no error. The translation simply reverts to the default language, 
which is English.

On Wednesday, 15 October 2014 02:48:50 UTC+11, Collin Anderson wrote:
>
> Hello,
>
> What does the error say?
>
> Collin
>
>

-- 
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/abc8f57b-12f7-450d-a2a2-dc5c0ed4d9b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: An elegant and simple way to fire a signal after a Save is complete (completely complete :) )

2014-10-14 Thread Carl Meyer
On 10/14/2014 01:58 PM, Spiros Mouzakitis wrote:
> What i finally did was to create a post_save signal as usual, and then
> in my receiver function i execute the "specific code block" in a thread
> (as mentioned
> here: 
> http://stackoverflow.com/questions/11899088/is-django-post-save-signal-asynchronous)
> In the thread i also put a time sleep. By the time the thread is resumed
> from the time.sleep function, the database has been updated and unlocked
> It works, but definitely not elegant :)

I think using django-transaction-hooks would be both more elegant and
more reliable, and not any more complex than that.

Carl

-- 
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/543D8A0C.4010104%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


Re: An elegant and simple way to fire a signal after a Save is complete (completely complete :) )

2014-10-14 Thread Spiros Mouzakitis
Thanks Carls,

What i finally did was to create a post_save signal as usual, and then in 
my receiver function i execute the "specific code block" in a thread (as 
mentioned 
here: 
http://stackoverflow.com/questions/11899088/is-django-post-save-signal-asynchronous)
In the thread i also put a time sleep. By the time the thread is resumed 
from the time.sleep function, the database has been updated and unlocked
It works, but definitely not elegant :)


On Tuesday, October 14, 2014 7:05:36 PM UTC+3, Spiros Mouzakitis wrote:
>
> Hi all,
>
> I have a model (model Employee) and i want to each time that it is created 
> / saved to run a specific code block.
> My specific code requires that the model is already saved in the database 
> (i call an external API)
> I can't use post_save signal , because the transaction is still pending 
> (the database has not been updated).
>
> What can i do? What is the most elegant way to create a (custom?) signal 
> for after the save is complete? Can someone give an example?
>
> many thanks,
> Spiros
>
>

-- 
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/25f94558-c9b6-4343-93a0-ce57dbd90cc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Appending trailing slashes to jQuery Ajax requests automatically

2014-10-14 Thread Ustun Ozgur
I have published a small snippet 
at 
https://github.com/ustun/ensure-trailing-slash-for-jquery-ajax/blob/master/ensure_slash.js
 

that automatically adds a trailing slash to every outgoing AJAX request so 
as to minimize accidental redirects. 


Best,

Ustun


(Inspired by https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax )

-- 
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/a284fd82-a057-455f-bd36-815b262a4ef0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: An elegant and simple way to fire a signal after a Save is complete (completely complete :) )

2014-10-14 Thread Carl Meyer
Hi Spiros,

On 10/14/2014 10:05 AM, Spiros Mouzakitis wrote:
> I have a model (model Employee) and i want to each time that it is
> created / saved to run a specific code block.
> My specific code requires that the model is already saved in the
> database (i call an external API)
> I can't use post_save signal , because the transaction is still pending
> (the database has not been updated).
> 
> What can i do? What is the most elegant way to create a (custom?) signal
> for after the save is complete? Can someone give an example?

I don't know of a good _simple_ way to do this, but I think there are
some pieces you can put together to make a working solution.
Django-transaction-hooks [1] will let you register callback functions to
be run after the current transaction is committed. So you should be able
to write a post_save signal handler that registers a post-commit
callback for the just-saved model.

Carl


[1] http://django-transaction-hooks.readthedocs.org/en/latest/

-- 
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/543D57DE.9020908%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


Run some code after Model Save completes (and after database is updated)

2014-10-14 Thread Spiros Mouzakitis
Hi,

-I am looking for an elegant, and universal way to add some code AFTER the 
saving of a model and after of course the database is updated with changes.
-I have tried post_save signals, but the transaction is still on, the 
entries do not exist in database
-I have tried overriding save in models.py, but even if i put  the code 
after.super(MyModel, self).save(*args, **kwargs), the database is still 
not updated until the save function completes.

any ideas?

many thanks,
Spiros

-- 
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/763df2b0-5517-4296-9628-ba13132938e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


An elegant and simple way to fire a signal after a Save is complete (completely complete :) )

2014-10-14 Thread Spiros Mouzakitis
Hi all,

I have a model (model Employee) and i want to each time that it is created 
/ saved to run a specific code block.
My specific code requires that the model is already saved in the database 
(i call an external API)
I can't use post_save signal , because the transaction is still pending 
(the database has not been updated).

What can i do? What is the most elegant way to create a (custom?) signal 
for after the save is complete? Can someone give an example?

many thanks,
Spiros

-- 
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/c8a044bc-37ee-4f1b-91b3-f1309034f7d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: centos 6 python 2.6 django 1.7 install problem

2014-10-14 Thread Berker Peksağ
On Tue, Oct 14, 2014 at 7:38 PM, Berker Peksağ  wrote:
> On Tue, Oct 14, 2014 at 7:33 PM, Sells, Fred
>  wrote:
>> Downloaded the gz file, unzipped and ran python setup.py install
>
> Hi,
>
> Django 1.7 does not support Python 2.6. Please install Django 1.6
> instead. You can see the current supported Python versions at
> https://docs.djangoproject.com/en/1.7/faq/install/#should-i-use-the-stable-version-or-development-version

Oh, the correct URL is:
https://docs.djangoproject.com/en/1.7/faq/install/#what-python-version-can-i-use-with-django

--Berker

>
> --Berker
>
>>
>>
>> Note, due to network security settings, I cannot use pip or any similar tool
>> that needs external web access
>>
>>
>>
>> I get the following errors,  any advice on how to fix?
>>
>>
>>
>> …snip….
>>
>> creating /usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg
>>
>> Extracting Django-1.7-py2.6.egg to /usr/lib/python2.6/site-packages
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/forms/utils.py',
>> 57, 34, 'return {f: e.as_data() for f, e in self.items()}\n'))
>>
>>
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/utils/lru_cache.py',
>> 28, 34, ' fasttypes = {int, str, frozenset,
>> type(None)},\n'))
>>
>>
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/test/signals.py',
>> 103, 41, "if kwargs['setting'] in {'LANGUAGES', 'LANGUAGE_CODE',
>> 'LOCALE_PATHS'}:\n"))
>>
>>
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/template/loader_tags.py',
>> 145, 19, 'for name, var in
>> six.iteritems(self.extra_context)\n'))
>>
>>
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/humanize/tests.py',
>> 95, 40, "with translation.override('ja'),
>> self.settings(USE_L10N=True):\n"))
>>
>>
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/formtools/tests/wizard/wizardtests/tests.py',
>> 128, 40, "with open(THIS_FILE, 'rb') as f,
>> temp_storage.open(UPLOADED_FILE_NAME) as f2:\n"))
>>
>>
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py',
>> 160, 40, "with open(THIS_FILE, 'rb') as f,
>> temp_storage.open(UPLOADED_FILE_NAME) as f2:\n"))
>>
>>
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/auth/tests/test_forms.py',
>> 123, 42, "with self.settings(USE_I18N=True),
>> translation.override('pt-br', deactivate=True):\n"))
>>
>>
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/gis/db/models/constants.py',
>> 4, 17, "'bbcontains', 'bboverlaps', 'contained', 'contains',\n"))
>>
>>
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/gis/db/backends/postgis/operations.py',
>> 79, 34, "valid_aggregates = {'Collect', 'Extent', 'Extent3D',
>> 'MakeLine', 'Union'}\n"))
>>
>>
>>
>> SyntaxError: ('invalid syntax',
>> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/gis/db/backends/spatialite/operations.py',
>> 68, 33, "valid_aggregates = {'Extent', 'Union'}\n"))
>>
>> --
>> 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/DCD75728F460F14586086EA606E830820132593802%40ACEVXCHMBX1001.ADVENTISTCORP.NET.
>> 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/CAF4280%2BBsvtLZyRNQ%2BCjzQOPYevPyZhJfcE9DBmytvLByVv%2BxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: centos 6 python 2.6 django 1.7 install problem

2014-10-14 Thread Berker Peksağ
On Tue, Oct 14, 2014 at 7:33 PM, Sells, Fred
 wrote:
> Downloaded the gz file, unzipped and ran python setup.py install

Hi,

Django 1.7 does not support Python 2.6. Please install Django 1.6
instead. You can see the current supported Python versions at
https://docs.djangoproject.com/en/1.7/faq/install/#should-i-use-the-stable-version-or-development-version

--Berker

>
>
> Note, due to network security settings, I cannot use pip or any similar tool
> that needs external web access
>
>
>
> I get the following errors,  any advice on how to fix?
>
>
>
> …snip….
>
> creating /usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg
>
> Extracting Django-1.7-py2.6.egg to /usr/lib/python2.6/site-packages
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/forms/utils.py',
> 57, 34, 'return {f: e.as_data() for f, e in self.items()}\n'))
>
>
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/utils/lru_cache.py',
> 28, 34, ' fasttypes = {int, str, frozenset,
> type(None)},\n'))
>
>
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/test/signals.py',
> 103, 41, "if kwargs['setting'] in {'LANGUAGES', 'LANGUAGE_CODE',
> 'LOCALE_PATHS'}:\n"))
>
>
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/template/loader_tags.py',
> 145, 19, 'for name, var in
> six.iteritems(self.extra_context)\n'))
>
>
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/humanize/tests.py',
> 95, 40, "with translation.override('ja'),
> self.settings(USE_L10N=True):\n"))
>
>
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/formtools/tests/wizard/wizardtests/tests.py',
> 128, 40, "with open(THIS_FILE, 'rb') as f,
> temp_storage.open(UPLOADED_FILE_NAME) as f2:\n"))
>
>
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py',
> 160, 40, "with open(THIS_FILE, 'rb') as f,
> temp_storage.open(UPLOADED_FILE_NAME) as f2:\n"))
>
>
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/auth/tests/test_forms.py',
> 123, 42, "with self.settings(USE_I18N=True),
> translation.override('pt-br', deactivate=True):\n"))
>
>
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/gis/db/models/constants.py',
> 4, 17, "'bbcontains', 'bboverlaps', 'contained', 'contains',\n"))
>
>
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/gis/db/backends/postgis/operations.py',
> 79, 34, "valid_aggregates = {'Collect', 'Extent', 'Extent3D',
> 'MakeLine', 'Union'}\n"))
>
>
>
> SyntaxError: ('invalid syntax',
> ('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/gis/db/backends/spatialite/operations.py',
> 68, 33, "valid_aggregates = {'Extent', 'Union'}\n"))
>
> --
> 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/DCD75728F460F14586086EA606E830820132593802%40ACEVXCHMBX1001.ADVENTISTCORP.NET.
> 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/CAF4280J_dE-ka0xKg%3Dn2gs6VWigTF5GJ1VeMPd2%2BR2U-%2Bx7BdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


centos 6 python 2.6 django 1.7 install problem

2014-10-14 Thread Sells, Fred
Downloaded the gz file, unzipped and ran python setup.py install

Note, due to network security settings, I cannot use pip or any similar tool 
that needs external web access

I get the following errors,  any advice on how to fix?

…snip….
creating /usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg
Extracting Django-1.7-py2.6.egg to /usr/lib/python2.6/site-packages
SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/forms/utils.py', 
57, 34, 'return {f: e.as_data() for f, e in self.items()}\n'))

SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/utils/lru_cache.py',
 28, 34, ' fasttypes = {int, str, frozenset, type(None)},\n'))

SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/test/signals.py',
 103, 41, "if kwargs['setting'] in {'LANGUAGES', 'LANGUAGE_CODE', 
'LOCALE_PATHS'}:\n"))

SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/template/loader_tags.py',
 145, 19, 'for name, var in 
six.iteritems(self.extra_context)\n'))

SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/humanize/tests.py',
 95, 40, "with translation.override('ja'), 
self.settings(USE_L10N=True):\n"))

SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/formtools/tests/wizard/wizardtests/tests.py',
 128, 40, "with open(THIS_FILE, 'rb') as f, 
temp_storage.open(UPLOADED_FILE_NAME) as f2:\n"))

SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py',
 160, 40, "with open(THIS_FILE, 'rb') as f, 
temp_storage.open(UPLOADED_FILE_NAME) as f2:\n"))

SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/auth/tests/test_forms.py',
 123, 42, "with self.settings(USE_I18N=True), 
translation.override('pt-br', deactivate=True):\n"))

SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/gis/db/models/constants.py',
 4, 17, "'bbcontains', 'bboverlaps', 'contained', 'contains',\n"))

SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/gis/db/backends/postgis/operations.py',
 79, 34, "valid_aggregates = {'Collect', 'Extent', 'Extent3D', 'MakeLine', 
'Union'}\n"))

SyntaxError: ('invalid syntax', 
('/usr/lib/python2.6/site-packages/Django-1.7-py2.6.egg/django/contrib/gis/db/backends/spatialite/operations.py',
 68, 33, "valid_aggregates = {'Extent', 'Union'}\n"))

-- 
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/DCD75728F460F14586086EA606E830820132593802%40ACEVXCHMBX1001.ADVENTISTCORP.NET.
For more options, visit https://groups.google.com/d/optout.


Re: How to "automatically " populate "last_updated_by" DB columns with the current user's id

2014-10-14 Thread Carl Meyer
On 10/14/2014 09:46 AM, Collin Anderson wrote:
> If you _really_ want it to be automatic, I think your best bet is to use
> a middleware to store the user or request object in a "thread local"
> variable, and then have a pre_save signal set the last_updated_by field
> based on that. That method is frowned upon, but should work. (If you're
> doing "green" threading, it may break.) The pre_save signal could error,
> or something if it is not able to determine the request (like in the
> command-line case).

I've done this while avoiding thread-locals (and signals) by just
overriding the model save method to add a ``user`` argument, and giving
the model a custom manager/queryset whose ``update`` method also takes a
``user`` argument. This just means anywhere you call ``save`` or
``update`` you have to pass in a ``user``. It's a bit more typing than
doing it via thread-local and signals, but I much prefer making it
explicit. Also makes it simpler for the cases (like a management
command) where there is no request, but you may still have a way to
identify the responsible user.

If you use the admin, it means you have to customize the ModelAdmin
slightly too so that it passes in the ``user`` kwarg, but that's not hard.

Carl

-- 
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/543D4B2C.3070204%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


Re: django language tag

2014-10-14 Thread Collin Anderson
Hello,

What does the error say?

Collin

-- 
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/e72f5b5d-7950-4274-a79c-29c44dd3332e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to "automatically " populate "last_updated_by" DB columns with the current user's id

2014-10-14 Thread Collin Anderson
Hi Ken,

If you _really_ want it to be automatic, I think your best bet is to use a 
middleware to store the user or request object in a "thread local" 
variable, and then have a pre_save signal set the last_updated_by field 
based on that. That method is frowned upon, but should work. (If you're 
doing "green" threading, it may break.) The pre_save signal could error, or 
something if it is not able to determine the request (like in the 
command-line case).

Thanks,
Collin

-- 
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/bcf744ef-17a4-4665-90f4-9611b7842dce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What is the correct way to set a field value in the form_valid method of a CreateView?

2014-10-14 Thread Daniel Grace
I found the way to do this is with the "form.save" method, for example in 
the form_valid:
state = get_state("test type", "test state")
obj = form.save(commit=False)
obj.state = state
obj.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/b0874775-2156-4d50-a886-417631227ea8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Question on url routing

2014-10-14 Thread robert brook
I have figured out how to determine if the url_conf was obtained from an 
internal link (which would be the only acceptable workflow) or through a 
url that the user typed into the address bar trying to subvert the workflow.

See the attached screen shot of the view.

If the view goes through the except statement, I would redirect to an 
appropriate page.

On Monday, October 13, 2014 9:58:28 AM UTC-4, Collin Anderson wrote:
>
> Hi Robert,
>
> I once had a 4-step ecommerce checkout, and at one point, I considered 
> using class based views for each step, and have a class method on each view 
> that runs form validation on the current data in the database to see if the 
> user is allowed to continue. It would then need to redirect back to itself 
> if it wasn't valid.
>
> In the end I decided to do some non DRY, but simple sanity checks in the 
> later views and redirect to a previous step if needed.
>
> Collin
>
>

-- 
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/3839438f-ebf0-436d-9a0e-dde412605b2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Static Media Server (Tango with Django)

2014-10-14 Thread Max Nathaniel Ho
Hi Carl, Colin and Andréas,

Thank you for all your replies.

You have more than answered my question and clarified my doubts :)

On Tuesday, October 14, 2014 1:11:37 AM UTC+8, Carl Meyer wrote:
>
> Hi Max, 
>
> On 10/13/2014 01:39 AM, Max Nathaniel Ho wrote: 
> > Hi all, 
> > 
> > I am going through this tutorial on Tango with Django 
> > - http://www.tangowithdjango.com/book/chapters/templates_static.html 
> > 
> > I extracted the specific part of the tutorial as seen in *BOLD*. 
> > 
> > 
> > *4.4. The Static Media 
> > Server<
> http://www.tangowithdjango.com/book/chapters/templates_static.html#the-static-media-server>*
>  
>
> > 
> > *Now that you can dispatch static files, let’s look at uploading media. 
> > Many websites provide their users with the ability to do this - for 
> > example, to upload a profile image. This section shows you how to add a 
> > simple development media server to your Django project. The development 
> > media server can be used in conjunction with file uploading forms which 
> > we will touch upon in Chapter 8 
> > .* 
> > 
> > *So, how do we go about setting up a development media server? The first 
> > step is to create another new directory called media within our Django 
> > project’s root (e.g./tango_with_django_project/). The 
> > new media directory should now be sitting alongside 
> > your templates and static directories. After you create the directory, 
> > you must then modify your Django project’s urls.py file, located in the 
> > project configuration directory 
> > (e.g./tango_with_django_project/tango_with_django_project/). 
> > Add the following code to the urls.py file.* 
>
> I think that tutorial is confusing things by calling it a "Static Media 
> Server". 
>
> In Django terminology, "static assets" and "media" are two very 
> different things. "Static assets" are assets that are required for your 
> site to function (part of its code) and should be checked into your 
> version control. An example might be your site's logo. 
>
> Media, on the other hand, are part of your site's data, not it's code. 
> They are generally uploaded by users of your site, and you would back 
> them up periodically (along with your database contents), but not check 
> them into your codebase. An example might be user avatar images. 
>
> > It teaches about Static Media Server. Is this something that is still 
> > current? 
>
> Yes, if your site will have uploaded media, it is still necessary to 
> configure your local development server to serve them (and a standalone 
> web server, or a service like S3 or a CDN, to serve them in production). 
> The instructions given in that tutorial look correct. Here are the 
> related Django docs: 
>
> https://docs.djangoproject.com/en/1.7/ref/views/#serving-files-in-development 
>
> > From my understanding of the Official Django Tutorial and the 
> > Documentation, we can just use static files as seen here 
> > - https://docs.djangoproject.com/en/1.6/howto/static-files/ 
>
> The staticfiles contrib app is only for handling static assets, not 
> uploaded media. 
>
> Carl 
>

-- 
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/3b10209e-cb29-49f6-a0d2-35381d7ed8d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django: How to apply filter on geometry type using GeoDjango QuerySet

2014-10-14 Thread Shoaib Ijaz
Yeah, Now I am using .extra() function

My Implementation 


On Tuesday, 14 October 2014 12:22:44 UTC+5, Jani Tiainen wrote:
>
> On Mon, 13 Oct 2014 23:34:04 -0700 (PDT) 
> Shoaib Ijaz  wrote: 
>
> > 
> > 
> > I am trying to convert a SQL into Django Query: 
> > 
> > SELECT * from tbl_name where geometrytype(geometry) LIKE 'POINT'; 
> > 
> > I have searched on it but cannot find any geometry type function. 
> > 
>
> You can't, at least not with current Django versions. Geodjango assumes 
> that geometry column contains just one type of a geometries. 
>
> But you should be able to use .raw() query to get what you want to. 
>
> -- 
>
> Jani Tiainen 
>

-- 
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/952713cb-106c-4089-9b10-acbc02b90191%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django: How to apply filter on geometry type using GeoDjango QuerySet

2014-10-14 Thread Jani Tiainen
On Mon, 13 Oct 2014 23:34:04 -0700 (PDT)
Shoaib Ijaz  wrote:

> 
> 
> I am trying to convert a SQL into Django Query:
> 
> SELECT * from tbl_name where geometrytype(geometry) LIKE 'POINT';
> 
> I have searched on it but cannot find any geometry type function.
> 

You can't, at least not with current Django versions. Geodjango assumes
that geometry column contains just one type of a geometries.

But you should be able to use .raw() query to get what you want to.

-- 

Jani Tiainen

-- 
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/20141014101328.5d20ed42%40jns42-l.w2k.keypro.fi.
For more options, visit https://groups.google.com/d/optout.


Django: How to apply filter on geometry type using GeoDjango QuerySet

2014-10-14 Thread Shoaib Ijaz


I am trying to convert a SQL into Django Query:

SELECT * from tbl_name where geometrytype(geometry) LIKE 'POINT';

I have searched on it but cannot find any geometry type function.

Any Help? Thank you

-- 
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/d373701c-1f91-418a-8108-4b854692d39a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.