set current user value in Django admin for Foreign Key

2014-12-10 Thread Akshay Mukadam
Hi,
I just want to show the current logged in user in for foreign key in Django 
admin. Following are the approach used buy me:

1-> def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "user":
"set the current user as a default value for drop down"
kwargs["initial"] = request.user.id 
return super(ResponseAdmin, 
self).formfield_for_foreignkey(db_field, request, **kwargs)

2->def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "user":
"Filter the drop down as per standard procedure"
kwargs["queryset"] = User.objects.filter(username = 
request.user.username)
return super(ResponseAdmin, 
self).formfield_for_foreignkey(db_field, request, **kwargs)

Problems for 1st approach is the current logged in user gets properly set 
but it also shows the other users in the existing database. That is 
actually wrong because the current user may select the other user name and 
post the data in  admin.

Problem for second appraoch(For my Team Manager not me) the only logged in 
user gets populated and user has to select his name. He is unagreed with 
this scenario neither ok with the 1st solution(neither me).

Is there any other way to solve this

-- 
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/e6d4a7c9-4201-46c3-baaf-1c6f156764ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I can't syncdb via django_pyodbc of Django.

2014-12-10 Thread Sugita Shinsuke


Hi there.

Could you tell me a good way to use Django with Micro Soft DB SQL server. I 
tried django_pyodbc. Any suggestion is appreciated.

my PC of Environment is below.

Database:
SQL Server 2014 Express

OS:
Windows 7 Home Premium SP1

I used the django module, django_pyodbc.
And, I tried to run syncdb but I couldn't.

My settings.py is below.

DATABASES = {
   'default': {
   'ENGINE': "django_pyodbc",
   'HOST': "localhost",
   'USER': "djangouser",
   'PASSWORD': "x",
   'NAME': "db_test",
   'OPTIONS': {
'host_is_server': True,
'autocommit': True,
'unicode_results': True,
'extra_params': 'tds_version=8.0'
},
   }
}

Things I tried and did not work:
1,change "localhost" to "127.0.0.1,1433" in the HOST property of the code.
2,removed 'OPTIONS'.


However, I tried the module pyodbc of pure python like below. It was fine.

---
conn = pyodbc.connect('driver={SQL 
Server};server=localhost;UID=djangouser;PWD=x;DATABASE=shannon_test;Trusted_Connection=yes')
---

But, DB connection is not established without "Trusted_Connection=yes".
At least I do not know any other way. Anyone who know this matter, please help.



The error message is here.



pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL Server Driver][
SQL Server]\x82\xb1\x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\x
b3\x82\xea\x82\xbd\x83f\x81[\x83^\x83x\x81[\x83X "shannon_test" \x82\xf0\x8aJ\x8
2\xaf\x82\xdc\x82\xb9\x82\xf1\x81B\x83\x8d\x83O\x83C\x83\x93\x82\xc9\x8e\xb8\x94
s\x82\xb5\x82\xdc\x82\xb5\x82\xbd\x81B (4060) (SQLDriverConnect); [01S00] [Micro
soft][ODBC SQL Server Driver]\x90\xda\x91\xb1\x95\xb6\x8e\x9a\x97\xf1\x82\xcc\x9
1\xae\x90\xab\x82\xaa\x90\xb3\x82\xb5\x82\xad\x82\xa0\x82\xe8\x82\xdc\x82\xb9\x8
2\xf1\x81B (0); [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]\x82\xb1\
x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\xb3\x82\xea\x82\xbd\x
83f\x81[\x83^\x83x\x81[\x83X "shannon_test" \x82\xf0\x8aJ\x82\xaf\x82\xdc\x82\xb
9\x82\xf1\x81B\x83\x8d\x83O\x83C\x83\x93\x82\xc9\x8e\xb8\x94s\x82\xb5\x82\xdc\x8
2\xb5\x82\xbd\x81B (4060); [01S00] [Microsoft][ODBC SQL Server Driver]\x90\xda\x
91\xb1\x95\xb6\x8e\x9a\x97\xf1\x82\xcc\x91\xae\x90\xab\x82\xaa\x90\xb3\x82\xb5\x
82\xad\x82\xa0\x82\xe8\x82\xdc\x82\xb9\x82\xf1\x81B (0)')



-- 
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/5f3e2749-8da5-45eb-8c6f-1476e42c3164%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unable to create translation files

2014-12-10 Thread gerard

hello all,

i'm using Django 1.4 LTS, and try to add localisation to my project.
According the doc:
https://docs.djangoproject.com/en/1.4/topics/i18n/translation/#localization-how-to-create-language-files

i have to do:
django-admin.py makemessages --all

i did it and have the error:
django-admin.py makemessages -v 3 --traceback --all 
--settings=agenda.settings

...
ImportError: Could not import settings 'agenda.settings' (Is it on 
sys.path?): No module named agenda.settings


but it exists:
$ python manage.py shell
Python 2.7.8 (default, Oct 19 2014, 16:03:53)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from agenda.settings import *
>>>

Anybody can help? Thanks in advance,

--
Gérard Henry

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


Re: set current user value in Django admin for Foreign Key

2014-12-10 Thread Vijay Khemlani
Hmmm... why are you showing the user field in the first place? I would
exclude it from the form and set it programatically after the user as
submitted the form.

On Wed, Dec 10, 2014 at 5:38 AM, Akshay Mukadam 
wrote:

> Hi,
> I just want to show the current logged in user in for foreign key in
> Django admin. Following are the approach used buy me:
>
> 1-> def formfield_for_foreignkey(self, db_field, request, **kwargs):
> if db_field.name == "user":
> "set the current user as a default value for drop down"
> kwargs["initial"] = request.user.id
> return super(ResponseAdmin,
> self).formfield_for_foreignkey(db_field, request, **kwargs)
>
> 2->def formfield_for_foreignkey(self, db_field, request, **kwargs):
> if db_field.name == "user":
> "Filter the drop down as per standard procedure"
> kwargs["queryset"] = User.objects.filter(username =
> request.user.username)
> return super(ResponseAdmin,
> self).formfield_for_foreignkey(db_field, request, **kwargs)
>
> Problems for 1st approach is the current logged in user gets properly set
> but it also shows the other users in the existing database. That is
> actually wrong because the current user may select the other user name and
> post the data in  admin.
>
> Problem for second appraoch(For my Team Manager not me) the only logged in
> user gets populated and user has to select his name. He is unagreed with
> this scenario neither ok with the 1st solution(neither me).
>
> Is there any other way to solve this
>
> --
> 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/e6d4a7c9-4201-46c3-baaf-1c6f156764ab%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/CALn3ei36PBjwzs-XZpTvMty-EPiurXSxTH6zg2qfCd2%2BuG%3DJew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: modelformst save

2014-12-10 Thread Collin Anderson
Hi,

This might be a complicated enough case where a functional view might help 
make things more clear what's going on.

Collin


On Friday, December 5, 2014 8:22:07 PM UTC-5, Brad Rice wrote:
>
> For the life of me I can't figure out how to use a modelformset with class 
> view. I get it to display but it won't save. Also, when it goes into 
> form_invalid, it doesn't display the 3 formsets. Can anyone shed a little 
> light? 
>
> I'm using crispy forms with this in my template:
>
> {% crispy reference_form referencehelper %}
>
> This is my model
>
> class Reference(models.Model):
> ref_name = models.CharField(max_length=256)
> ref_phone = models.CharField(max_length=20, 
> validators=[RegexValidator(regex='\(?([0-9]{3})\)?([ .-]?)([0-9]{3})([ 
> .-]?)([0-9]{4})', message='Looks like your phone number is not formatted 
> correctly', code='Invalid number')])
> ref_email = models.EmailField(max_length=256)
> created_by = models.ForeignKey(User, unique=True)
> applicant = models.ForeignKey("Applicant")
> application = models.ForeignKey("Application")
>
> This is my form.py form
>
> class ReferenceForm(forms.ModelForm):
> class Meta:
> model = Reference
> exclude = ('created_by', 'application', 'applicant')
>
> def __init__(self, *args, **kwargs):
> super(ReferenceForm, self).__init__(*args, **kwargs)
>
>
> class ReferenceFormSetHelper(FormHelper):
> def __init__(self, *args, **kwargs):
> super(ReferenceFormSetHelper, self).__init__(*args, **kwargs)
> self.form_method = 'post'
> self.layout = Layout(
> Fieldset('Reference',
> 'ref_name',
> 'ref_phone',
> 'ref_email',
> ))
> self.add_input(Submit("submit", "Save"))
>
>
>
> ReferenceFormSet = modelformset_factory(Reference, form=ReferenceForm, 
> extra=3, max_num=3, can_delete=True)
>
> This is my view:
>
> class ReferenceCreate(LoginRequiredMixin, CreateView):
> model = Reference
> form_class = ReferenceForm
> template_name = 'requestform/reference_form.html'
>
> def dispatch(self, *args, **kwargs):
> return super(ReferenceCreate, self).dispatch(*args, **kwargs)
>
> def get(self, request, *args, **kwargs):
> """
> Handles GET requests and instantiates blank versions of the form
> and its inline formsets.
> """
> self.object = None
> form_class = self.get_form_class()
> form = self.get_form(form_class)
> reference_form = ReferenceFormSet()
> refhelper = ReferenceFormSetHelper()
> return self.render_to_response(
> self.get_context_data(
>   reference_form=reference_form,
>   referencehelper=refhelper
>   ))
>
> def form_valid(self, form):
> """
> Called if all forms are valid. Creates a Recipe instance along with
> associated Ingredients and Instructions and then redirects to a
> success page.
> """
> self.object = form.save()
> reference_form.instance = self.object
> reference_form.save()
> return HttpResponseRedirect(reverse('requestform:app_check', 
> kwargs={'app_id': obj.application_id}))
>
>
> def form_invalid(self, reference_form):
> refhelper = ReferenceFormSetHelper()
> return self.render_to_response(self.get_context_data(
>   reference_form=reference_form,
>   referencehelper=refhelper
>   ))
>

-- 
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/de28611b-d13f-4eca-b958-19b243640572%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django, multi-tenancy and urls

2014-12-10 Thread Collin Anderson
Hi,

Are you using nginx or apache?

The especially tricky part about this is handling the local-machine case.

Collin

On Friday, December 5, 2014 6:10:36 AM UTC-5, vijay shanker wrote:
>
>  am writing a e-commerce application where different people can have 
> stores with urls like this: www.store-one.saas.com, www.store-two.saas.com, 
> and so on.
>
> These domains have to be generated automatically when a user signs up for 
> store.
>
> I have read somewhere that www.saas.com/store-one can be rewritten as 
> store-one.saas.com (ofcourse, they din told me how :( ).
>
> Is it possible and how it can be done, how can i achieve it in production 
> and with my local machine?
>

-- 
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/8a19275e-24eb-4ef7-87c2-85a0479bf3d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Changes to Model does not migrate to sqlite with Django 1.7?

2014-12-10 Thread Collin Anderson
Hi,

Storing your files in dropbox _should_ be fine, unless it's a problem with 
*.pyc or __pycache__ files.

Collin

On Tuesday, December 9, 2014 2:38:31 PM UTC-5, Tobias Dacoir wrote:
>
> Hi,
>
> I'm afraid I don't have them. Apparently after deleting my database file 
> and then just running manage.py makemigrations, it deleted the old 
> migration files and started anew. Right now I'm also unable to re-produce 
> it on purpose :( But it happened a couple of times for me since I regularly 
> make multiple changes to my model (I'm still at the beginning of 
> development) but if I just add a single new field now it works as expected.
>
> Maybe sometimes Django can't detect changes to my file because I store my 
> project in my dropbox folder and maybe this might be messing it up?
>
> On Monday, December 8, 2014 1:04:37 PM UTC+1, Markus Holtermann wrote:
>>
>> I tried to reproduce the problem with the steps you explained, but it 
>> works fine for me. Can you post your existing migration files for that app 
>> too, please. This will then hopefully give us some hints to solve your 
>> problem.
>>
>>

-- 
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/edad6a10-8d84-4513-8074-05a94650d014%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unable to create translation files

2014-12-10 Thread Tom Evans
On Wed, Dec 10, 2014 at 9:57 AM, gerard  wrote:
> hello all,
>
> i'm using Django 1.4 LTS, and try to add localisation to my project.
> According the doc:
> https://docs.djangoproject.com/en/1.4/topics/i18n/translation/#localization-how-to-create-language-files
>
> i have to do:
> django-admin.py makemessages --all
>
> i did it and have the error:
> django-admin.py makemessages -v 3 --traceback --all
> --settings=agenda.settings
> ...
> ImportError: Could not import settings 'agenda.settings' (Is it on
> sys.path?): No module named agenda.settings
>
> but it exists:
> $ python manage.py shell
> Python 2.7.8 (default, Oct 19 2014, 16:03:53)
> [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
 from agenda.settings import *

>
> Anybody can help? Thanks in advance,
>

"python manage.py makemessages --settings=agenda.settings"

I suspect the difference is between running manage.py and running
django-admin.py - manage.py might add the directory containing it to
sys.path.

If you run "python" (rather than manage.py shell) in the directory you
are trying to makemessages in, can you import agenda.settings?

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


Re: unable to create translation files

2014-12-10 Thread gerard

Le 10/12/2014 16:02, Tom Evans a écrit :


"python manage.py makemessages --settings=agenda.settings"

I suspect the difference is between running manage.py and running
django-admin.py - manage.py might add the directory containing it to
sys.path.



you're right:
$ python manage.py makemessages --all --settings=agenda.settings -v 3 
--traceback --all

examining files with the extensions: .html and .txt

very thanks!


--
Gérard Henry

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


Django-compressor manifest.json problem on Heroku

2014-12-10 Thread Guy Tamir
Hey all,

I'm trying to add django-compressor into my app.
I'm deploying to Heroku.

This is the code in my Settings file
AWS_QUERYSTRING_AUTH = False
AWS_STORAGE_BUCKET_NAME = os.environ.get('BUCKET_NAME')

conn = S3Connection(AWS_ACCESS_KEY, AWS_SECRET_KEY,host=
"s3-us-west-1.amazonaws.com")
STATIC_ROOT = 'static'
COMPRESS_ROOT = 'static'



COMPRESS_CSS_FILTERS = ['compressor.filters.yuglify.YUglifyCSSFilter',
'compressor.filters.cssmin.CSSMinFilter']
COMPRESS_JS_FILTERS = ['compressor.filters.jsmin.JSMinFilter'] 
#,'compressor.filters.jsmin.SlimItFilter'
COMPRESS_OUTPUT_DIR = 'compressed'
COMPRESS_CSS_BACKEND = 'django_compressor.css.CssCompressor'
COMPRESS_JS_BACKEND = 'django_compressor.js.JsCompressor'
COMPRESS_OFFLINE = True
COMPRESS_ENABLED = True


if DEBUG:
STATIC_URL = '/static/'
else:
AWS_S3_CUSTOM_DOMAIN = os.environ.get('COMPRESS_URL') # cdn.test.com
STATIC_URL =  'http://' + AWS_S3_CUSTOM_DOMAIN + '/'
STATICFILES_STORAGE = 'myapp.CachedS3BotoStorage.CachedS3BotoStorage'
COMPRESS_STORAGE = 'myapp.CachedS3BotoStorage.CachedS3BotoStorage'


COMPRESS_URL = STATIC_URL


I ran the compress command locally and then deployed to Heroku.
When I see my deployed pages I can see in the source files that the browser 
is using the compressed css and js file like expected.

My problem is that when I see my logs from Heroku, each time that I refresh 
a page, it seems like Heroku goes and fetches the manifest.json file from 
my S3 bucket.
This obviously slows down the requests..

Logs from Heroku:
2014-12-10T16:01:14.087225+00:00 app[web.1]: DEBUG:boto:Token: None
2014-12-10T16:01:14.086183+00:00 app[web.1]: DEBUG:boto:auth
_path=/test-dollarsocial/compressed/manifest.json
2014-12-10T16:01:14.137618+00:00 heroku[router]: at=info method=GET path=
"/login/" host=test-dollar-social.herokuapp.com request_id=bede0d95-e9b6-
4453-95b3-438606fc7e62 fwd="93.172.158.119" dyno=web.1 connect=1ms service=
194ms status=200 bytes=13248
2014-12-10T16:01:14.051410+00:00 app[web.1]: DEBUG:boto:Using secret key 
provided by client.
2014-12-10T16:01:14.051322+00:00 app[web.1]: DEBUG:boto:Using access key 
provided by client.
2014-12-10T16:01:14.051990+00:00 app[web.1]: DEBUG:boto:path=/compressed/
manifest.json
2014-12-10T16:01:14.052126+00:00 app[web.1]: DEBUG:boto:auth_path=
/test-dollarsocial/compressed/manifest.json
2014-12-10T16:01:14.052405+00:00 app[web.1]: DEBUG:boto:Path: /compressed/
manifest.json
2014-12-10T16:01:14.052316+00:00 app[web.1]: DEBUG:boto:Method: HEAD
2014-12-10T16:01:14.052490+00:00 app[web.1]: DEBUG:boto:Data:
2014-12-10T16:01:14.052605+00:00 app[web.1]: DEBUG:boto:Headers: {}
2014-12-10T16:01:14.052734+00:00 app[web.1]: DEBUG:boto:Host: test-
dollarsocial.s3.amazonaws.com
2014-12-10T16:01:14.052828+00:00 app[web.1]: DEBUG:boto:Params: {}
2014-12-10T16:01:14.052970+00:00 app[web.1]: DEBUG:boto:establishing HTTPS 
connection: host=test-dollarsocial.s3.amazonaws.com, kwargs={'timeout': 70}
2014-12-10T16:01:14.053082+00:00 app[web.1]: DEBUG:boto:Token: None
2014-12-10T16:01:14.053224+00:00 app[web.1]: DEBUG:boto:StringToSign:
2014-12-10T16:01:14.053227+00:00 app[web.1]: HEAD
2014-12-10T16:01:14.053228+00:00 app[web.1]:
2014-12-10T16:01:14.053230+00:00 app[web.1]:
2014-12-10T16:01:14.053231+00:00 app[web.1]: Wed, 10 Dec 2014 16:01:14 GMT
2014-12-10T16:01:14.053233+00:00 app[web.1]: /test-dollarsocial/compressed/
manifest.json
2014-12-10T16:01:14.085443+00:00 app[web.1]: DEBUG:boto:path=/compressed/
manifest.json
2014-12-10T16:01:14.086354+00:00 app[web.1]: DEBUG:boto:Method: HEAD
2014-12-10T16:01:14.086473+00:00 app[web.1]: DEBUG:boto:Path: /compressed/
manifest.json
2014-12-10T16:01:14.086576+00:00 app[web.1]: DEBUG:boto:Data:
2014-12-10T16:01:14.086685+00:00 app[web.1]: DEBUG:boto:Headers: {}
2014-12-10T16:01:14.053367+00:00 app[web.1]: DEBUG:boto:Signature:
2014-12-10T16:01:14.053370+00:00 app[web.1]: AWS :
2014-12-10T16:01:14.086965+00:00 app[web.1]: DEBUG:boto:Params: {}
2014-12-10T16:01:14.086802+00:00 app[web.1]: DEBUG:boto:Host: test-
dollarsocial.s3.amazonaws.com
2014-12-10T16:01:14.087538+00:00 app[web.1]: DEBUG:boto:StringToSign:
2014-12-10T16:01:14.087540+00:00 app[web.1]: HEAD
2014-12-10T16:01:14.087541+00:00 app[web.1]:
2014-12-10T16:01:14.087543+00:00 app[web.1]:
2014-12-10T16:01:14.087567+00:00 app[web.1]: /test-dollarsocial/compressed/
manifest.json
2014-12-10T16:01:14.087918+00:00 app[web.1]: DEBUG:boto:Signature:
2014-12-10T16:01:14.087921+00:00 app[web.1]: AWS X
:XXX
2014-12-10T16:01:14.099581+00:00 app[web.1]: DEBUG:boto:path=/compressed/
manifest.json
2014-12-10T16:01:14.099629+00:00 app[web.1]: DEBUG:boto:auth_path=
/test-dollarsocial/compressed/manifest.json
2014-12-10T16:01:14.099784+00:00 app[web.1]: DEBUG:boto:Method: GET
2014-12-10T16:01:14.099870+00:00 app[web.1]: DEBUG:boto:Path: /compressed/
manifest.json
2014-12-10T16:01:14.099956+00:00 app[web.1]: DEBUG:boto:Data:
2014-12-10T16:01:14.087544+00:00 app[web.1]

Re: Advice on creating an SFTP frontend in Django

2014-12-10 Thread Raj Kairam
Please stop sending these emails to my gmail account

On Tue, Dec 9, 2014 at 1:07 PM, Андрей Максимов 
wrote:

> Hi Paul.
> I hope you moved to your final goal. Now before me there is the same
> objective is to make a simple Client Area that allows the downloading of
> files hosted on SFTP.
> Unfortunately I can not help you with your questions but I hope if you are 
> advanced
> with this issue, you will be able to tell a little detail as you have
> implemented it.
> T
> hanks in advance.
>
> среда, 3 июля 2013 г., 23:43:27 UTC+4 пользователь Paul Hudson написал:
>>
>> Hi,
>>
>> I have successfully used django-storages (http://django-storages.
>> readthedocs.org/en/latest/index.html)  and paramiko directly to log into
>> an SFTP server and list a directory.  My end goal is to make a simple
>> Client Area that allows the downloading of files hosted on SFTP.  I am open
>> to any advice.  But here are a few specific questions:
>>
>>
>>1. How should I handle authentication?  Use django's built in
>>authentication and pass the usr/pwd onto the SFTP? (is that possible in a
>>secure way?)  Authenticate directly against SFTP server in a secure way?
>>2. Are files going to be transferred twice?  Once from SFTP to temp
>>area on Django server.  And then downloaded via client's web browser...  
>> Am
>>I just better off hosting the files on the web server to begin with?  (The
>>files need to be available on SFTP and via web browser.  Maybe instead of
>>direct access to SFTP via Django, I should focus on a simple way to post
>>the original files to both places???)
>>3. Are they any Django Projects/Plugins/Components for File
>>Explorer/FTP Client type GUIs that you would recommend using or 
>> referencing?
>>
>>
>>
>> Thanks for any and all input!
>> -Paul
>>
>  --
> 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/959743f9-8a4a-4ea4-b546-cc4ecc440546%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/CAKQv5yeV-iyXLfZpLsjTUoG6tk-9Ko85rbqDKJqMs-jqmZsySQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


PostGis, GeoDjango. How to install a updated version?

2014-12-10 Thread Bruno Messias

Someone managed to install postgis 2.4 and gdal 1:11 on a Ubuntu 
distribution 14. I followed several tutorials. I fixed many errors, but the 
only thing I can do is instal an older postgis, 2.0.3 (2009) version. 

Atualmente, I'm deploying a project that needs of postgis.

-- 
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/757abae6-cba0-413a-8b5e-167d53c9015a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django and SSL

2014-12-10 Thread pythonista
I am getting a request from the security infrastructure and I could use 
some advice/recommendation.

This is a 3 tier application.

Apache/Django/Sql Server

Apache is https and there is a proxy server between.

The security team is saying that the communication from Django should also 
be ssl encrypted in case the proxy server goes down.

1. Can Django be made hardened via ssl?
2. Doesn't Apache and the Proxy server provide sufficient security so that 
ssl / django is not required?

3. If the Proxy server goes down I can test some header responses to 
determine if the call is from a secure call and from the expected server
 If such security is required is that not sufficient?

Thanks in advance.

-- 
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/611a928d-b3bf-4672-b850-591d62b7d350%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I can't syncdb via django_pyodbc of Django.

2014-12-10 Thread pythonista
I can actually help you here.

I had the same problem and tried 4 different modules.
The only module that works with sql server is 

https://github.com/michiya/django-pyodbc-azure


I am running it both on windows and linux, simultaneously.


The settings components are displayed on the web site.

Works like a charm

One dependency is pyodbc to be installed.



On Wednesday, December 10, 2014 4:22:44 AM UTC-5, Sugita Shinsuke wrote:
>
> Hi there.
>
> Could you tell me a good way to use Django with Micro Soft DB SQL server. I 
> tried django_pyodbc. Any suggestion is appreciated.
>
> my PC of Environment is below.
>
> Database:
> SQL Server 2014 Express
>
> OS:
> Windows 7 Home Premium SP1
>
> I used the django module, django_pyodbc.
> And, I tried to run syncdb but I couldn't.
>
> My settings.py is below.
>
> DATABASES = {
>'default': {
>'ENGINE': "django_pyodbc",
>'HOST': "localhost",
>'USER': "djangouser",
>'PASSWORD': "x",
>'NAME': "db_test",
>'OPTIONS': {
> 'host_is_server': True,
> 'autocommit': True,
> 'unicode_results': True,
> 'extra_params': 'tds_version=8.0'
> },
>}
> }
>
> Things I tried and did not work:
> 1,change "localhost" to "127.0.0.1,1433" in the HOST property of the code.
> 2,removed 'OPTIONS'.
>
>
> However, I tried the module pyodbc of pure python like below. It was fine.
>
> ---
> conn = pyodbc.connect('driver={SQL 
> Server};server=localhost;UID=djangouser;PWD=x;DATABASE=shannon_test;Trusted_Connection=yes')
> ---
>
> But, DB connection is not established without "Trusted_Connection=yes".
> At least I do not know any other way. Anyone who know this matter, please 
> help.
>
>
>
> The error message is here.
>
> 
>
> pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL Server 
> Driver][
> SQL 
> Server]\x82\xb1\x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\x
> b3\x82\xea\x82\xbd\x83f\x81[\x83^\x83x\x81[\x83X "shannon_test" 
> \x82\xf0\x8aJ\x8
> 2\xaf\x82\xdc\x82\xb9\x82\xf1\x81B\x83\x8d\x83O\x83C\x83\x93\x82\xc9\x8e\xb8\x94
> s\x82\xb5\x82\xdc\x82\xb5\x82\xbd\x81B (4060) (SQLDriverConnect); [01S00] 
> [Micro
> soft][ODBC SQL Server 
> Driver]\x90\xda\x91\xb1\x95\xb6\x8e\x9a\x97\xf1\x82\xcc\x9
> 1\xae\x90\xab\x82\xaa\x90\xb3\x82\xb5\x82\xad\x82\xa0\x82\xe8\x82\xdc\x82\xb9\x8
> 2\xf1\x81B (0); [42000] [Microsoft][ODBC SQL Server Driver][SQL 
> Server]\x82\xb1\
> x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\xb3\x82\xea\x82\xbd\x
> 83f\x81[\x83^\x83x\x81[\x83X "shannon_test" 
> \x82\xf0\x8aJ\x82\xaf\x82\xdc\x82\xb
> 9\x82\xf1\x81B\x83\x8d\x83O\x83C\x83\x93\x82\xc9\x8e\xb8\x94s\x82\xb5\x82\xdc\x8
> 2\xb5\x82\xbd\x81B (4060); [01S00] [Microsoft][ODBC SQL Server 
> Driver]\x90\xda\x
> 91\xb1\x95\xb6\x8e\x9a\x97\xf1\x82\xcc\x91\xae\x90\xab\x82\xaa\x90\xb3\x82\xb5\x
> 82\xad\x82\xa0\x82\xe8\x82\xdc\x82\xb9\x82\xf1\x81B (0)')
> 
>
>
>

-- 
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/75829654-59e0-4ba5-a824-8a61123387c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and SSL

2014-12-10 Thread Brian Schott
Hopefully you aren’t using Django runserver command for actually running 
Django.  This is really a configuration question relating to your WSGI 
application server.  Gunicorn is popular and supports SSL.  

http://gunicorn-docs.readthedocs.org/en/latest/settings.html#ssl 


Brian Schott
bfsch...@gmail.com



> On Dec 10, 2014, at 11:55 AM, pythonista  wrote:
> 
> I am getting a request from the security infrastructure and I could use some 
> advice/recommendation.
> 
> This is a 3 tier application.
> 
> Apache/Django/Sql Server
> 
> Apache is https and there is a proxy server between.
> 
> The security team is saying that the communication from Django should also be 
> ssl encrypted in case the proxy server goes down.
> 
> 1. Can Django be made hardened via ssl?
> 2. Doesn't Apache and the Proxy server provide sufficient security so that 
> ssl / django is not required?
> 
> 3. If the Proxy server goes down I can test some header responses to 
> determine if the call is from a secure call and from the expected server
>  If such security is required is that not sufficient?
> 
> Thanks in advance.
> 
> -- 
> 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/611a928d-b3bf-4672-b850-591d62b7d350%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/7AFEAE16-1C7D-4ABF-864D-BB20A4A9C509%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and SSL

2014-12-10 Thread pythonista
Is there a need for ssl if apache (https) and a proxy are between django 
and the outside world.

Doesn't the apache server/proxy provide a sufficient layer of security.
isn't it true that the data is being served through the server securely via 
https?

Thanks

On Wednesday, December 10, 2014 11:55:15 AM UTC-5, pythonista wrote:
>
> I am getting a request from the security infrastructure and I could use 
> some advice/recommendation.
>
> This is a 3 tier application.
>
> Apache/Django/Sql Server
>
> Apache is https and there is a proxy server between.
>
> The security team is saying that the communication from Django should also 
> be ssl encrypted in case the proxy server goes down.
>
> 1. Can Django be made hardened via ssl?
> 2. Doesn't Apache and the Proxy server provide sufficient security so that 
> ssl / django is not required?
>
> 3. If the Proxy server goes down I can test some header responses to 
> determine if the call is from a secure call and from the expected server
>  If such security is required is that not sufficient?
>
> Thanks in advance.
>

-- 
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/6a6d6601-166e-4234-869f-3442d6c2876b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and SSL

2014-12-10 Thread Javier Guerra Giraldez
On Wed, Dec 10, 2014 at 1:22 PM, pythonista
 wrote:
> Is there a need for ssl if apache (https) and a proxy are between django and
> the outside world.


if they're serving Django with apache, they should be using mod_wsgi,
in that case not only there's no more needs for SSL, there's no space
for SSL between apache and Django.

-- 
Javier

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


Re: Seeking for advise on usage MySQL together with MongoDB

2014-12-10 Thread Artie
I would like to thank you a lot for so detailed answers, actually I didn't 
expect to get so much information on my question. 
That really great and inspiring. So thank you very much again.
Guess now I need to start learning PostgreSQL, cause that is not first time 
when I hear that Python and Postgres rocks.


пятница, 5 декабря 2014 г., 14:56:57 UTC+2 пользователь Artie написал:
>
> Good day, Community,
>
> I'm looking for advise on MySQL & MongoDB usage so please let me take your 
> time to describe the situation.
>
> I came to work on e-commerce shop of electrical components with about 10 
> millions of products. Now all of it stored in awful structure of tables in 
> MySQL. Products stored in 10 small tables, each of them represents 
> individual manufacturer of products and 1 generalized table, where all 10 
> millions of goods is stored. Those big table serves Sphinx search to 
> implement search on site.
> All these products being crawled from several APIs and sites on web, so 
> this shop is kind of authorized reseller in our region.
>
> The case is that we have to update all products daily and  parsing with 
> updating of products takes very long time.
>
> I have an idea to start using MongoDB to update and store products and as 
> I think it might take less time than same in MySQL. First question: Am I 
> correct with this statement?
>
> Browsing web I've found that some recommend using pymongo, avoiding django 
> rather than mongodb for django. So for your opinion is this statement 
> correct?
>
> Also it will be highly highly appreciated if you can share your personal 
> use experience with MongoDB and any information you think be useful.
>
> Thank you in advance
>

-- 
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/2b832802-6214-43db-bc65-cb7c69d375b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Seeking for advise on usage MySQL together with MongoDB

2014-12-10 Thread Artie
Can you please advise why actually you hate Django ORM and what should be 
considered instead of it?

суббота, 6 декабря 2014 г., 23:18:06 UTC+2 пользователь Cal Leeming написал:
>
> Hi Artie,
>
> First, I would strongly recommend reading some of the work by David Mytton 
> at Server Density, he and his team have been using MongoDB extensively for 
> many years and they have shared a lot of their insight [1]. It's also worth 
> mentioning that Postgres has support for JSON field type [2] which 
> satisfies many of the use cases for document store, though I haven't 
> finished my own experiments yet so can't comment on comparative 
> performance/functionality.
>
> It's industry knowledge that MySQL is bleeding out, rapidly [3] [4]. At 
> this point, I introduce you to Monty and his creation MariaDB [5]. Although 
> I would agree with Russell on many of the points he's made about MySQL, 
> it's hard not to have respect for the work that Monty and his team have 
> done previously on MySQL, and the vision that is now MariaDB. I would 
> strongly recommend you spend some time looking into this yourself, read as 
> many comparison articles as your eyes will allow, and come to your own 
> conclusions. 
>
> I have built numerous "large scale" systems with a variety of 
> technologies.. Sphinx, ElasticSearch, MongoDB, MySQL, CouchBase, Redis. 
> I've also spent many years battling with MongoEngine and have learnt to 
> hate it, as much as I now hate the Django ORM. So, unless you are edging 
> towards terabytes of data, assuming you are using SSDs and high memory 
> nodes, then the impact of your choice will probably be negligible. And if 
> you are using the Django ORM, then you are even less likely to reap any of 
> these benefits out of the box [6] There are many different reasons for 
> choosing one over the over, and you should assess this based on your own 
> use case/needs/skills, rather than religious bias.
>
> Determine your use case and test all viable options, otherwise you could 
> be avoiding something for the wrong reasons. You can build *beautiful* 
> things with all these different technologies, and it's actually the mindset 
> which matters the most [7]. Don't just settle for what others are telling 
> you, try for yourself and come to your own conclusions, only then can you 
> be sure. It's also a good way to gain in-depth knowledge about how these 
> technologies work, which can be invaluable.
>
> Cal
>
>
> [1] https://blog.serverdensity.com/mongodb/
> [2] http://www.postgresql.org/docs/9.3/static/datatype-json.html
> [3] http://www.theregister.co.uk/2012/11/29/monty_oracle_eu_promises/
> [4] 
> http://www.computing.co.uk/ctg/news/2271011/mysql-creator-monty-widenius-wants-it-to-disappear-from-the-earth
> [5] http://www.themukt.com/2014/09/11/reason-use-mysql-michael-widenius/
> [6] https://news.ycombinator.com/item?id=4076834
> [7] 
> http://www.amazon.co.uk/The-Clean-Coder-Professional-Programmers/dp/0137081073
>
>
>
> On Sat, Dec 6, 2014 at 12:26 AM, Russell Keith-Magee <
> rus...@keith-magee.com > wrote:
>
>>
>> On Fri, Dec 5, 2014 at 8:56 PM, Artie > 
>> wrote:
>>
>>> Good day, Community,
>>>
>>> I'm looking for advise on MySQL & MongoDB usage so please let me take 
>>> your time to describe the situation.
>>>
>>> I came to work on e-commerce shop of electrical components with about 10 
>>> millions of products. Now all of it stored in awful structure of tables in 
>>> MySQL. Products stored in 10 small tables, each of them represents 
>>> individual manufacturer of products and 1 generalized table, where all 10 
>>> millions of goods is stored. Those big table serves Sphinx search to 
>>> implement search on site.
>>> All these products being crawled from several APIs and sites on web, so 
>>> this shop is kind of authorized reseller in our region.
>>>
>>> The case is that we have to update all products daily and  parsing with 
>>> updating of products takes very long time.
>>>
>>> I have an idea to start using MongoDB to update and store products and 
>>> as I think it might take less time than same in MySQL. First question: Am I 
>>> correct with this statement?
>>>
>>> Browsing web I've found that some recommend using pymongo, avoiding 
>>> django rather than mongodb for django. So for your opinion is this 
>>> statement correct?
>>>
>>> Also it will be highly highly appreciated if you can share your personal 
>>> use experience with MongoDB and any information you think be useful.
>>>
>>  
>> Hi Artie,
>>
>> Can I make an alternate suggestion? Get a real database.
>>
>> In all honesty, I've never heard anyone in the Django community express a 
>> deep love of MySQL or MongoDB. I know people who use MySQL, but when they 
>> admit that, they say "Yeah, I know, but the customer required it" or "Yeah, 
>> I know, but at the time we started it was the only thing Amazon supported". 
>> As for MongoDB, the sentiment is usually "... and that was our first 
>> mistake.".
>>
>> Personally - I hav

Re: Seeking for advise on usage MySQL together with MongoDB

2014-12-10 Thread Cal Leeming
If you're using Django, then there isn't really an alternative, as it's
really a key selling point of Django.

Some people recommend SQLAlchemy, but I dislike that even more for it's
over-engineered complexity.

Peewee [1] shows some good potential, but I haven't tried it for myself yet.

As for why I dislike the Django ORM, many of the technical reasons are
already explained (in detail) in that thread [2] I mentioned before, but a
lot of it comes down to personal taste and opinion of what matters most
about an ORM etc.

Cal

[1] https://github.com/coleifer/peewee
[2] https://news.ycombinator.com/item?id=4076834

On Wed, Dec 10, 2014 at 7:17 PM, Artie  wrote:

> Can you please advise why actually you hate Django ORM and what should be
> considered instead of it?
>
> суббота, 6 декабря 2014 г., 23:18:06 UTC+2 пользователь Cal Leeming
> написал:
>>
>> Hi Artie,
>>
>> First, I would strongly recommend reading some of the work by David
>> Mytton at Server Density, he and his team have been using MongoDB
>> extensively for many years and they have shared a lot of their insight [1].
>> It's also worth mentioning that Postgres has support for JSON field type
>> [2] which satisfies many of the use cases for document store, though I
>> haven't finished my own experiments yet so can't comment on comparative
>> performance/functionality.
>>
>> It's industry knowledge that MySQL is bleeding out, rapidly [3] [4]. At
>> this point, I introduce you to Monty and his creation MariaDB [5]. Although
>> I would agree with Russell on many of the points he's made about MySQL,
>> it's hard not to have respect for the work that Monty and his team have
>> done previously on MySQL, and the vision that is now MariaDB. I would
>> strongly recommend you spend some time looking into this yourself, read as
>> many comparison articles as your eyes will allow, and come to your own
>> conclusions.
>>
>> I have built numerous "large scale" systems with a variety of
>> technologies.. Sphinx, ElasticSearch, MongoDB, MySQL, CouchBase, Redis.
>> I've also spent many years battling with MongoEngine and have learnt to
>> hate it, as much as I now hate the Django ORM. So, unless you are edging
>> towards terabytes of data, assuming you are using SSDs and high memory
>> nodes, then the impact of your choice will probably be negligible. And if
>> you are using the Django ORM, then you are even less likely to reap any of
>> these benefits out of the box [6] There are many different reasons for
>> choosing one over the over, and you should assess this based on your own
>> use case/needs/skills, rather than religious bias.
>>
>> Determine your use case and test all viable options, otherwise you could
>> be avoiding something for the wrong reasons. You can build *beautiful*
>> things with all these different technologies, and it's actually the mindset
>> which matters the most [7]. Don't just settle for what others are telling
>> you, try for yourself and come to your own conclusions, only then can you
>> be sure. It's also a good way to gain in-depth knowledge about how these
>> technologies work, which can be invaluable.
>>
>> Cal
>>
>>
>> [1] https://blog.serverdensity.com/mongodb/
>> [2] http://www.postgresql.org/docs/9.3/static/datatype-json.html
>> [3] http://www.theregister.co.uk/2012/11/29/monty_oracle_eu_promises/
>> [4] http://www.computing.co.uk/ctg/news/2271011/mysql-
>> creator-monty-widenius-wants-it-to-disappear-from-the-earth
>> [5] http://www.themukt.com/2014/09/11/reason-use-mysql-michael-widenius/
>> [6] https://news.ycombinator.com/item?id=4076834
>> [7] http://www.amazon.co.uk/The-Clean-Coder-Professional-
>> Programmers/dp/0137081073
>>
>>
>>
>> On Sat, Dec 6, 2014 at 12:26 AM, Russell Keith-Magee <
>> rus...@keith-magee.com> wrote:
>>
>>>
>>> On Fri, Dec 5, 2014 at 8:56 PM, Artie  wrote:
>>>
 Good day, Community,

 I'm looking for advise on MySQL & MongoDB usage so please let me take
 your time to describe the situation.

 I came to work on e-commerce shop of electrical components with about
 10 millions of products. Now all of it stored in awful structure of tables
 in MySQL. Products stored in 10 small tables, each of them represents
 individual manufacturer of products and 1 generalized table, where all 10
 millions of goods is stored. Those big table serves Sphinx search to
 implement search on site.
 All these products being crawled from several APIs and sites on web, so
 this shop is kind of authorized reseller in our region.

 The case is that we have to update all products daily and  parsing with
 updating of products takes very long time.

 I have an idea to start using MongoDB to update and store products and
 as I think it might take less time than same in MySQL. First question: Am I
 correct with this statement?

 Browsing web I've found that some recommend using pymongo, avoiding
 django rather than mongodb for django. So for y

Re: I can't syncdb via django_pyodbc of Django.

2014-12-10 Thread Sugita Shinsuke


Hello pythonista,

Thank you for replying.
I tried django-pyodbc-azure But syncdb didn't run yet.

As the website says, since I use Django 1.6.4,
I installed django-pyodbc-azure as "pip install "django-pyodbc-azure<1.2""

I checked the odbc driver by Control Panel > Administrative Tools > Data 
Sources (ODBC) > "Driver" tab
My settings.py is as below.

DATABASES = {
   'default': {
   'ENGINE': 'sql_server.pyodbc',
   'HOST': 'localhost', # I also tried 127.0.0.1
   'PORT': '1433', # I also tried empty
   'USER': 'djangouser',
   'PASSWORD': 'x',
   'NAME': 'db_test',
   'OPTIONS': { # I also removed the OPTION
   'driver': 'SQL Server Native Client 11.0', # I also change 'SQL 
Server Native Client 10.0'
   },
   }
}

I tried to run syncdb command again, and then I got some errors again.
here are error messages.

django.db.utils.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL Server
 Driver][SQL Server]

 [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]

[01S00] [Microsoft][ODBC SQL Server Driver]




2014年12月11日木曜日 1時58分58秒 UTC+9 pythonista:
>
> I can actually help you here.
>
> I had the same problem and tried 4 different modules.
> The only module that works with sql server is 
>
> https://github.com/michiya/django-pyodbc-azure
>
>
> I am running it both on windows and linux, simultaneously.
>
>
> The settings components are displayed on the web site.
>
> Works like a charm
>
> One dependency is pyodbc to be installed.
>
>
>
> On Wednesday, December 10, 2014 4:22:44 AM UTC-5, Sugita Shinsuke wrote:
>>
>> Hi there.
>>
>> Could you tell me a good way to use Django with Micro Soft DB SQL server. I 
>> tried django_pyodbc. Any suggestion is appreciated.
>>
>> my PC of Environment is below.
>>
>> Database:
>> SQL Server 2014 Express
>>
>> OS:
>> Windows 7 Home Premium SP1
>>
>> I used the django module, django_pyodbc.
>> And, I tried to run syncdb but I couldn't.
>>
>> My settings.py is below.
>>
>> DATABASES = {
>>'default': {
>>'ENGINE': "django_pyodbc",
>>'HOST': "localhost",
>>'USER': "djangouser",
>>'PASSWORD': "x",
>>'NAME': "db_test",
>>'OPTIONS': {
>> 'host_is_server': True,
>> 'autocommit': True,
>> 'unicode_results': True,
>> 'extra_params': 'tds_version=8.0'
>> },
>>}
>> }
>>
>> Things I tried and did not work:
>> 1,change "localhost" to "127.0.0.1,1433" in the HOST property of the code.
>> 2,removed 'OPTIONS'.
>>
>>
>> However, I tried the module pyodbc of pure python like below. It was fine.
>>
>> ---
>> conn = pyodbc.connect('driver={SQL 
>> Server};server=localhost;UID=djangouser;PWD=x;DATABASE=shannon_test;Trusted_Connection=yes')
>> ---
>>
>> But, DB connection is not established without "Trusted_Connection=yes".
>> At least I do not know any other way. Anyone who know this matter, please 
>> help.
>>
>>
>>
>> The error message is here.
>>
>> 
>>
>> pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL Server 
>> Driver][
>> SQL 
>> Server]\x82\xb1\x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\x
>> b3\x82\xea\x82\xbd\x83f\x81[\x83^\x83x\x81[\x83X "shannon_test" 
>> \x82\xf0\x8aJ\x8
>> 2\xaf\x82\xdc\x82\xb9\x82\xf1\x81B\x83\x8d\x83O\x83C\x83\x93\x82\xc9\x8e\xb8\x94
>> s\x82\xb5\x82\xdc\x82\xb5\x82\xbd\x81B (4060) (SQLDriverConnect); [01S00] 
>> [Micro
>> soft][ODBC SQL Server 
>> Driver]\x90\xda\x91\xb1\x95\xb6\x8e\x9a\x97\xf1\x82\xcc\x9
>> 1\xae\x90\xab\x82\xaa\x90\xb3\x82\xb5\x82\xad\x82\xa0\x82\xe8\x82\xdc\x82\xb9\x8
>> 2\xf1\x81B (0); [42000] [Microsoft][ODBC SQL Server Driver][SQL 
>> Server]\x82\xb1\
>> x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\xb3\x82\xea\x82\xbd\x
>> 83f\x81[\x83^\x83x\x81[\x83X "shannon_test" 
>> \x82\xf0\x8aJ\x82\xaf\x82\xdc\x82\xb
>> 9\x82\xf1\x81B\x83\x8d\x83O\x83C\x83\x93\x82\xc9\x8e\xb8\x94s\x82\xb5\x82\xdc\x8
>> 2\xb5\x82\xbd\x81B (4060); [01S00] [Microsoft][ODBC SQL Server 
>> Driver]\x90\xda\x
>> 91\xb1\x95\xb6\x8e\x9a\x97\xf1\x82\xcc\x91\xae\x90\xab\x82\xaa\x90\xb3\x82\xb5\x
>> 82\xad\x82\xa0\x82\xe8\x82\xdc\x82\xb9\x82\xf1\x81B (0)')
>> 
>>
>>
>>

-- 
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/bc0eaa7a-3943-4091-a318-00c885352b0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Adding annotations to raw sql

2014-12-10 Thread Ruslan Batukaev
Suppose I have the following SQL query:

SELECT a.id, ct, 1 as one
FROM article a
LEFT JOIN (
   SELECT article_id, count(distinct(tag)) AS ct
   FROM   article_tag
   WHERE  tag IN ('football', 'tennis', 'django', 'mma')
   GROUP  BY article_id
   ORDER  BY ct
   ) t ON t.article_id = a.ID
ORDER BY t.ct DESC NULLS LAST
   , (a.blog = 'ign.com') DESC NULLS LAST
   , rating DESC NULLS LAST;

Now execute it in Django:

Article.objects.raw(query);


According to [Django documentation][1], the queryset will contain the 
values of `ct` and `one` for each article. However, while it prints the 
value of `one` correctly, it does not for `ct` and just returns `null`. Is 
there any way to get `ct` for each article?
Thanks. 

  


  [1]: 
https://docs.djangoproject.com/en/dev/topics/db/sql/#adding-annotations

-- 
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/5a93348a-6d18-4735-988e-5cbadc6ca245%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


fdv

2014-12-10 Thread Kadhir Mani
what purpose using admin.py

-- 
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/747b7199-2668-4c76-a119-292bd39c7f4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I can't syncdb via django_pyodbc of Django.

2014-12-10 Thread Sugita Shinsuke
I use SQL Server Japanese edition.
So, I also wrote Japanese error message here.

django.db.utils.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL 
Server Driver][SQL Server]このログインで要求されたデータベース "db_test" 
を開けません。ログインに失敗しました。 (4060) (SQLDriverConnect);
[01S00] [Microsoft][ODBC SQL Server Driver]接続文字列の属性が正しくありません。 (0);
[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]
このログインで要求されたデータベース "shannon_test" を開けません。ログインに失敗しました。 (4060); [01S00] 
[Microsoft][ODBC SQL Server Driver]接続文字列の属性が正しくありません。 (0)')

更新  時間を記録 
 ウォッチをやめる 

 コピー 

2014年12月11日木曜日 1時58分58秒 UTC+9 pythonista:
>
> I can actually help you here.
>
> I had the same problem and tried 4 different modules.
> The only module that works with sql server is 
>
> https://github.com/michiya/django-pyodbc-azure
>
>
> I am running it both on windows and linux, simultaneously.
>
>
> The settings components are displayed on the web site.
>
> Works like a charm
>
> One dependency is pyodbc to be installed.
>
>
>
> On Wednesday, December 10, 2014 4:22:44 AM UTC-5, Sugita Shinsuke wrote:
>>
>> Hi there.
>>
>> Could you tell me a good way to use Django with Micro Soft DB SQL server. I 
>> tried django_pyodbc. Any suggestion is appreciated.
>>
>> my PC of Environment is below.
>>
>> Database:
>> SQL Server 2014 Express
>>
>> OS:
>> Windows 7 Home Premium SP1
>>
>> I used the django module, django_pyodbc.
>> And, I tried to run syncdb but I couldn't.
>>
>> My settings.py is below.
>>
>> DATABASES = {
>>'default': {
>>'ENGINE': "django_pyodbc",
>>'HOST': "localhost",
>>'USER': "djangouser",
>>'PASSWORD': "x",
>>'NAME': "db_test",
>>'OPTIONS': {
>> 'host_is_server': True,
>> 'autocommit': True,
>> 'unicode_results': True,
>> 'extra_params': 'tds_version=8.0'
>> },
>>}
>> }
>>
>> Things I tried and did not work:
>> 1,change "localhost" to "127.0.0.1,1433" in the HOST property of the code.
>> 2,removed 'OPTIONS'.
>>
>>
>> However, I tried the module pyodbc of pure python like below. It was fine.
>>
>> ---
>> conn = pyodbc.connect('driver={SQL 
>> Server};server=localhost;UID=djangouser;PWD=x;DATABASE=shannon_test;Trusted_Connection=yes')
>> ---
>>
>> But, DB connection is not established without "Trusted_Connection=yes".
>> At least I do not know any other way. Anyone who know this matter, please 
>> help.
>>
>>
>>
>> The error message is here.
>>
>> 
>>
>> pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL Server 
>> Driver][
>> SQL 
>> Server]\x82\xb1\x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\x
>> b3\x82\xea\x82\xbd\x83f\x81[\x83^\x83x\x81[\x83X "shannon_test" 
>> \x82\xf0\x8aJ\x8
>> 2\xaf\x82\xdc\x82\xb9\x82\xf1\x81B\x83\x8d\x83O\x83C\x83\x93\x82\xc9\x8e\xb8\x94
>> s\x82\xb5\x82\xdc\x82\xb5\x82\xbd\x81B (4060) (SQLDriverConnect); [01S00] 
>> [Micro
>> soft][ODBC SQL Server 
>> Driver]\x90\xda\x91\xb1\x95\xb6\x8e\x9a\x97\xf1\x82\xcc\x9
>> 1\xae\x90\xab\x82\xaa\x90\xb3\x82\xb5\x82\xad\x82\xa0\x82\xe8\x82\xdc\x82\xb9\x8
>> 2\xf1\x81B (0); [42000] [Microsoft][ODBC SQL Server Driver][SQL 
>> Server]\x82\xb1\
>> x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\xb3\x82\xea\x82\xbd\x
>> 83f\x81[\x83^\x83x\x81[\x83X "shannon_test" 
>> \x82\xf0\x8aJ\x82\xaf\x82\xdc\x82\xb
>> 9\x82\xf1\x81B\x83\x8d\x83O\x83C\x83\x93\x82\xc9\x8e\xb8\x94s\x82\xb5\x82\xdc\x8
>> 2\xb5\x82\xbd\x81B (4060); [01S00] [Microsoft][ODBC SQL Server 
>> Driver]\x90\xda\x
>> 91\xb1\x95\xb6\x8e\x9a\x97\xf1\x82\xcc\x91\xae\x90\xab\x82\xaa\x90\xb3\x82\xb5\x
>> 82\xad\x82\xa0\x82\xe8\x82\xdc\x82\xb9\x82\xf1\x81B (0)')
>> 
>>
>>
>>

-- 
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/e7ec8df4-307b-451f-bcf4-b01dfa57f6bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Adding annotations to raw sql

2014-12-10 Thread john

should that be "t.ct"
Johnf
On 12/10/2014 03:23 PM, Ruslan Batukaev wrote:

Suppose I have the following SQL query:

SELECT a.id, ct, 1 as one
FROM article a
LEFT JOIN (
   SELECT article_id, count(distinct(tag)) AS ct
   FROM   article_tag
   WHERE  tag IN ('football', 'tennis', 'django', 'mma')
   GROUP  BY article_id
   ORDER  BY ct
   ) t ON t.article_id = a.ID
ORDER BY t.ct DESC NULLS LAST
   , (a.blog = 'ign.com') DESC NULLS LAST
   , rating DESC NULLS LAST;

Now execute it in Django:

Article.objects.raw(query);


According to [Django documentation][1], the queryset will contain the 
values of `ct` and `one` for each article. However, while it prints 
the value of `one` correctly, it does not for `ct` and just returns 
`null`. Is there any way to get `ct` for each article?

Thanks.



  [1]: 
https://docs.djangoproject.com/en/dev/topics/db/sql/#adding-annotations

--
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/5a93348a-6d18-4735-988e-5cbadc6ca245%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/54892777.6060801%40jfcomputer.com.
For more options, visit https://groups.google.com/d/optout.