Re: django 1.8 and wsgi_mod

2015-04-27 Thread Abhaya Agarwal
This looks fine. Are there any errors in the web server logs?

Regards,
Abhaya

On Mon, Apr 27, 2015 at 10:23 PM, dk  wrote:

> we decided to test django 1.8,  using python manage.py runserver works
> great.  but now the production wsgi stop working,
> I remember there was a change between version 1.6 and 1.7.
> this is my code.   Did it something change?
>
> import os
> import sys
> sys.path.append("/code/projects/my_web")
> sys.path.append("/code/projects/my_web/core") # path to the project
> os.environ["DJANGO_SETTINGS_MODULE"]= "core.settings"
>
>
> *from django.core.wsgi import get_wsgi_applicationapplication =
> get_wsgi_application()*
>
> #this is the way for django 1.6
> #import django.core.handlers.wsgi
> #application = django.core.handlers.wsgi.WSGIHandler()
>
> thanks guys.
>
> --
> 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/2d130a53-d9e4-404e-bf79-ba4f1df492dc%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
blog: http://abhaga.blogspot.com
Twitter: http://twitter.com/abhaga
-

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


Re: Turn off migrations completely in Django 1.7

2015-04-27 Thread Mike Dewhirst

Jamie

Well I agree top-posting is usually a problem - especially for those who 
hate it. But in this case the top-poster was semi-hijacking the thread 
and in doing so felt the need to top post to differentiate the subject 
matter. That difference was in "disabling migrations" versus turning off 
migrations completely and preventing the creation of the migrations 
table - the latter not something the top poster seemed to worry about. 
Also, there is the line "even if all of the other models are set to 
managed=False" which implies another difference possibly justifying a 
thread semi-hijack. Anyway, I suspect disabling migration - even if a 
"master-switch" could be built - is undesirable if one is using any of 
the django tables.


Please forgive me for hijacking this thread to discuss top-posting.

Mike

On 28/04/2015 1:27 PM, Jamie Lawrence wrote:

On Apr 27, 2015, at 7:01 PM, Mike Dewhirst 
wrote:



On 27/04/2015 9:54 AM, marcin.j.no...@gmail.com wrote: So what
about that? I'm also interested in disabling migrations.


Would it suffice to have all your models specify "managed = False"
in the Meta class?

https://docs.djangoproject.com/en/1.7/ref/models/options/#managed


This is why top posting or at least failing to trim is bad for (at
least) technical mailing lists. Threads end up looping.


From the very email quoted:




On Saturday, September 20, 2014 at 6:37:59 AM UTC+2, Anthony
Tuininga wrote:

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




--
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/553F187A.7060401%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Turn off migrations completely in Django 1.7

2015-04-27 Thread Jamie Lawrence
On Apr 27, 2015, at 7:01 PM, Mike Dewhirst  wrote:
> 
>> On 27/04/2015 9:54 AM, marcin.j.no...@gmail.com wrote:
>> So what about that? I'm also interested in disabling migrations.
> 
> Would it suffice to have all your models specify "managed = False" in the 
> Meta class?
> 
> https://docs.djangoproject.com/en/1.7/ref/models/options/#managed

This is why top posting or at least failing to trim is bad for (at least) 
technical mailing lists. Threads end up looping. 

>From the very email quoted:


>> On Saturday, September 20, 2014 at 6:37:59 AM UTC+2, Anthony Tuininga wrote:
>> 
>>Hmm, the problem is that there doesn't appear to be any way to turn
>>off the creation of the migrations table itself, even if all of the
>>other models are set to managed=False as suggested by Nikolas. I've
>>commented it out for now but it would be ideal to have some way of
>>turning it off completely -- or simply doing nothing if there are no
>>managed models.

-- 
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/64EF1371-9C9B-45DF-8161-37FE05A5BB44%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Turn off migrations completely in Django 1.7

2015-04-27 Thread Mike Dewhirst

On 27/04/2015 9:54 AM, marcin.j.no...@gmail.com wrote:

So what about that? I'm also interested in disabling migrations.
I need to upgrade Django in big project (from 1.4 to newer version)
because of lack of support for 1.4, but migrations included in v1.7 will
complicate this process.


Would it suffice to have all your models specify "managed = False" in 
the Meta class?


https://docs.djangoproject.com/en/1.7/ref/models/options/#managed

Mike



I want to disable everything related to migrations. We're using better
migration solution, which is project-wide and related only to databases.
Django is a only small part of the project and it should not modify any
table and any record outside our migrations system.


/BR
Marcin

On Saturday, September 20, 2014 at 6:37:59 AM UTC+2, Anthony Tuininga wrote:

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

On Thursday, September 18, 2014 5:27:45 PM UTC-6, mike wrote:

Hi,

I feel your pain, but I think you can utilize something with --fake

I have been using databases for many, many years, and honestly-
migrations definitely make sense. I am able to add new fields
within a
few seconds without having to do any extra work. It takes 2
minutes to
learn how to use migrations, and I will personally never look back.

Mike



On Thu, Sep 18, 2014 at 5:04 PM, Anthony Tuininga
 wrote:
 > Hi,
 >
 > I just upgraded my test environment to Django 1.7 and
immediately noticed
 > that mgirations appear to be a requirement. Searching the
documentation and
 > the code itself seems to indicate that there is no way to
disable it,
 > either. Did I miss something? I don't need or want Django to
create or alter
 > any database objects and up to Django 1.6 I could quite
happily ignore
 > syncdb but it seems I can't ignore migrations. Please advise!
Thanks.
 >
 > Anthony
 >
 > --
 > You received this message because you are subscribed to the
Google Groups
 > "Django users" group.
 > To unsubscribe from this group and stop receiving emails from
it, send an
 > email to django-users...@googlegroups.com.
 > To post to this group, send email to django...@googlegroups.com.
 > Visit this group at
http://groups.google.com/group/django-users
.
 > To view this discussion on the web visit
 >

https://groups.google.com/d/msgid/django-users/9bdd258f-a21b-48a0-ab1b-b3a4123b40c1%40googlegroups.com

.

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

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/1f03aaad-1beb-4b84-9ca3-c1ce097ad0ca%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/553EE9E8.2000906%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: model.FileField

2015-04-27 Thread James Schneider
You can save the file wherever you like, just change the file path where
you are writing the file to make use of settings.MEDIA_ROOT rather than a
hard-coded URL.

Since you aren't using a model, Django is assuming you want to do something
fancy with the file, so you are responsible for doing the heavy lifting for
operations such as writing it to disk.

One or more of these packages may also help:

https://www.djangopackages.com/grids/g/file-managers/

-James
On Apr 27, 2015 6:17 AM, "mangu rajpurohit" 
wrote:

> Hi James,
>>
>>
> Thanks for suggesting me the page at location
> https://docs.djangoproject.com/en/1.8/topics/http/file-uploads/
> .
> I visited that page and as you suggested, there was no need of database in
> between, However, I noted that we have to manually write the file as shown
> in snippet given below(copied from url suggested by you)
>
> def handle_uploaded_file(f):
> with open('some/file/name.txt', 'wb+') as destination:
> for chunk in f.chunks():
> destination.write(chunk)
>
>
> So, I mean, Isn't there any way through which this file writing operation 
> takes places automatically in django. Moreover, you note that here, filepath 
> is hard-coded. I want that it file uploaded by user, must be copied at 
> MEDIA_ROOT variable set in settings.py of project.
>
>
>>
>>  --
> 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/9b9e962d-84a4-4344-b0a1-452623ac0db4%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/CA%2Be%2BciW2bt83d6U7KxCEgs%2BLvoO%3DAQFiq8MZguKWUmRWc9gpiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django 1.8 and wsgi_mod

2015-04-27 Thread dk
we decided to test django 1.8,  using python manage.py runserver works 
great.  but now the production wsgi stop working, 
I remember there was a change between version 1.6 and 1.7.  
this is my code.   Did it something change?

import os
import sys
sys.path.append("/code/projects/my_web")
sys.path.append("/code/projects/my_web/core") # path to the project
os.environ["DJANGO_SETTINGS_MODULE"]= "core.settings"


*from django.core.wsgi import get_wsgi_applicationapplication = 
get_wsgi_application()*

#this is the way for django 1.6
#import django.core.handlers.wsgi
#application = django.core.handlers.wsgi.WSGIHandler()

thanks guys.

-- 
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/2d130a53-d9e4-404e-bf79-ba4f1df492dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pyodbc: Works in Plain Python, Django 1.8 Shell Throws Error

2015-04-27 Thread Matt Woodward
Running into a bit of an odd problem I hope someone can help with.

Envrionment:
* Ubuntu Server 14.04, 64-bit (Vagrant box)
* Python 3.4
* Django 1.8
* pyodbc 3.0.8

pyodbc installs fine. When I do python3 and then import pyodbc, that works 
fine.

When I do python3 manage.py shell and then import pyodbc, however, I get 
this:
http://pastebin.com/cNDrmvcb

Got a bit of help in IRC with someone suggested to turn on pdb trace on the 
run_shell command, which I did, but then I just get this:
*** SystemError: initialization of pyodbc raised unreported exception

I just can't figure out why it'd work in a plain python interpreter but not 
in the Django shell, and I'm not sure how to diagnose or troubleshoot 
further.

Appreciate any tips or suggestions anyone might have. 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/949d8be7-8ca2-499d-90eb-aa621498b038%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: form_invalid redirection with CBVs

2015-04-27 Thread David
Got this working. See below:

class CreateComment(MultipleObjectMixin, FormView):
template_name = 'comment/comment_list.html'
form_class = CommentForm
model = Comment
paginate_by = 5

def post(self, request, *args, **kwargs):
if not request.user.is_authenticated():
return HttpResponseForbidden()
self.object_list = Comment.objects.filter(
object_id=self.kwargs['pk'], content_type_id=self.kwargs['ct']
).order_by('-created')
form = self.get_form()
if form.is_valid():
return self.form_valid(form)

return super(CreateComment, self).post(request, *args, **kwargs)

def get_success_url(self):
return reverse('comment:Comments', kwargs={'ct': self.kwargs['ct'], 'pk': 
self.kwargs['pk']})

def form_valid(self, form):
data = form.save(commit=False)
data.creator = self.request.user
data.object_id = self.kwargs['pk']
data.content_type_id = self.kwargs['ct']
data.save()
return super(CreateComment, self).form_valid(form)

def get_context_data(self, **kwargs):
context = super(CreateComment, self).get_context_data(**kwargs)
context['paginate_by'] = self.paginate_by
return context

-- 
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/be9e0c75-3da1-4b67-bee7-bc98e0cd13da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: model.FileField

2015-04-27 Thread mangu rajpurohit

>
> Hi James,
>
>
Thanks for suggesting me the page at location  
https://docs.djangoproject.com/en/1.8/topics/http/file-uploads/ 
.
 
I visited that page and as you suggested, there was no need of database in 
between, However, I noted that we have to manually write the file as shown 
in snippet given below(copied from url suggested by you)

def handle_uploaded_file(f):
with open('some/file/name.txt', 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)


So, I mean, Isn't there any way through which this file writing operation takes 
places automatically in django. Moreover, you note that here, filepath is 
hard-coded. I want that it file uploaded by user, must be copied at MEDIA_ROOT 
variable set in settings.py of project.

 
>
>

-- 
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/9b9e962d-84a4-4344-b0a1-452623ac0db4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: model.FileField

2015-04-27 Thread James Schneider
Have you seen this?

https://docs.djangoproject.com/en/1.8/topics/http/file-uploads/

Has an example showing an example exactly as you asked without any models
involved. Also make sure you recognize the difference between
models.FileField and forms.FileField:

https://docs.djangoproject.com/en/1.8/ref/models/fields/#filefield
https://docs.djangoproject.com/en/1.8/ref/forms/fields/#filefield

The former is for definitions in models and the corresponding database
column, and the latter is for display within web forms.

The overlap for naming between forms and models has burned me more than
once.

-James
On Apr 27, 2015 3:14 AM, "mangu rajpurohit" 
wrote:

> Hi,
>
> I am new to django. I am looking for examples for uploading/downloading
> files in django. I found that models.FileField is used in model. So, my
> question is that, is it possible to upload file in django, without
> requiring to create a model, which will keep track of filenames in database.
>
> --
> 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/16371334-b89d-4385-b141-0eb75c1056ec%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/CA%2Be%2BciV9juciG6zDzktMu%3DX-iYj%2BWHMX3pWp-tBY%3D8AtsXNYsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Slowness of the resulting squashed migration

2015-04-27 Thread aRkadeFR

Thanks for the answer.

Right now, I just know that after squashing some migrations,
it created a squashed migrations with CreateModel + AlterField
and AddField after that runs on 5seconds, and now that I put
all the field in the CreateModel without any AlterField or AddField,
it runs on <2secondes.

I had some custom RunPython function in the migrations but
removed it for the squashing.

I will dig a bit more and open a ticket if I can reproduce it :)

Have a good day

On 04/24/2015 09:09 PM, Markus Holtermann wrote:

Hi,

In principle it is possible to write your own or modify existing 
migrations unless they are already applied.


Regarding the additional AddField() operations: in case you have e.g. 
circular references between two models Django cannot add both models 
with their full columns at the same time. Django first adds one model 
without the ForeignKey, then the second model including the FK to the 
first model and finally adds the field to the first model pointing to 
the second model [1]. Bottom line: if you find a way to optimize 
something in your squashed migration, feel free to go ahead. It would 
be helpful if you report this as an enhance to our issue tracker [2] 
so we can include a possible improvement in future Django versions.


/Markus

[1] Have a look at slide 14f 
of https://speakerdeck.com/andrewgodwin/migrations-under-the-hood

[2] https://code.djangoproject.com/

On Friday, April 24, 2015 at 8:14:34 PM UTC+2, aRkadeFR wrote:

Hello,

After working on a project and having around 10 migrations per app,
I wanted to refactor some migrations (of the same app) into only one
and have a faster migrations while testing.

I did squashmigrations on many of the migrations, but the resulting
squased migration is still pretty slow (around 6 seconds to create 4
tables on MySQL 5.5 without any data inserted).

After looking at the migrations, there is some
CreateModel(name='')
and after the table creation some AddField on the same
table/models...

I would like to know if it's safe to change the migrations by
hand? Is
there a reason the squashmigrations didn't refactor into only
CreateModel
without AddField then?

Thanks

aRkadeFR



--
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/553E0EFE.60902%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


model.FileField

2015-04-27 Thread mangu rajpurohit
Hi,

I am new to django. I am looking for examples for uploading/downloading 
files in django. I found that models.FileField is used in model. So, my 
question is that, is it possible to upload file in django, without 
requiring to create a model, which will keep track of filenames in database.

-- 
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/16371334-b89d-4385-b141-0eb75c1056ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.