Re: get_available_name() got an unexpected keyword argument 'max_length'

2016-09-05 Thread Nelson Fajardo
Thks for the answer, i just founded. (django-storages) I updated Boto but i 
forgot that one!



On Monday, September 5, 2016 at 10:28:43 PM UTC-5, James Schneider wrote:
>
>
> > Hi, wich dependency do you update? I just get the same error, but i cant 
> find it!
> >
> >
>
> Based on Tim's response, any package that has to do with image or file 
> handling would be a prime suspect. You may have a different package with 
> the same issue, so the OP's answer may be different.
>
> -James
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d0f28822-19d2-4d71-8db3-1d1de6979061%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError: view must be a callable or a list/tuple in the case of include(). in urls.py

2016-09-05 Thread James Schneider
On Sep 5, 2016 6:06 AM, "arun kumar"  wrote:
>
> Hi,
>
>I'm working in Django 1.10 and I got the type error  in the below file
at this line " url(r'^$', views.dashboard, name = 'dashboard'),"
>
> from django.conf.urls import include, url
> from . import views
>
> urlpatterns = [
> #preview login view
> #url(r'^login/$',views.user_login, name='login')
>
> # logged - in user dashboard
> url(r'^$', views.dashboard, name = 'dashboard'),
>
> #login / logout urls
> url(r'^login/$', 'django.contrib.auth.views.login', name='login'),
>

Here is where your problem starts. Django 1.10 removed the ability to use
string arguments to refer to views. See the deprecation notice in 1.8:

https://docs.djangoproject.com/en/1.8/ref/urls/#django.conf.urls.url

Import your views and pass them along directly.

-James

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVqSYGyBn0d8zE6FZGuWDCG9P-m_JXtL-83r7U_tNfpTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get_available_name() got an unexpected keyword argument 'max_length'

2016-09-05 Thread James Schneider
> Hi, wich dependency do you update? I just get the same error, but i cant
find it!
>
>

Based on Tim's response, any package that has to do with image or file
handling would be a prime suspect. You may have a different package with
the same issue, so the OP's answer may be different.

-James

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWYAwcHxmKPyF%2B2ZWRa2XKeHWANi%2BOMHWJFFK9so%2ByJOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Serving very large pdf files with django

2016-09-05 Thread Gary Roach

Thanks you all for you contributions

I have decided to break down the pdf files into individual jpg pages and 
serve them that way. I plan on putting each document in its own folder 
and then have the individual pages listed within the folder. I haven't 
worked out the exact retrieval scheme yet but it will probably be 
something like:


Documents
Document 1
;:
;jpg 1
::
:   jpg n
;
Document n

This should work and allow fast recovery.

Thanks again for your help

Gary R


On 09/04/2016 05:37 AM, Avraham Serour wrote:
if you need to server the pdf then it will be downloaded to the user 
computer, even if you are visualizing in browser with js.


What you can do is show screenshots of the pdf pages, then you would 
be serving individual jpgs for each page and not a single 100mb file.


You can create previews for each page using something like imagemagick 
as mentioned before and create a layout to view that using django 
template.




On Sun, Sep 4, 2016 at 9:52 AM, <06use...@gmail.com 
> wrote:


Hello,

Maybe you could use ImageMagick to show one page of the pdf as an
image ? This is what I have implemented on my project : first page
of pdf files can be pre-viewed before user uploads the whole file
(if needed). In your case, pre-viewing could be parametrized to
show page ‘n’ of the pdf file, probably. In my project,
pre-viewing image is generated when pdf file is uploaded and saved
by admin in myproject/media/files directory. Once pdf files are in
media directory, users can preview those pdf files and tnen upload
them, if needed (only first page can be pre-viewed by user. This
is an implementation choice).


http://www.imagemagick.org/script/index.php





Implementation principles/credit can be found here :

http://www.yaconiello.com/blog/auto-generating-pdf-covers/





I am attaching the signals file_post_save file_pre_save, for
information.


Cheers.

Django 1.8
Python 3.4


Note : to install ImageMagick:

sudo apt-get install libmagickwand-dev imagemagick libmagickcore-dev

The convert command allows to convert any page of pdf file into
png image (for instance), eg :

convert -thumbnail 1280 test.pdf[0] test_1280.png
Several parameters exist to tune image quality (in my case, need
to use density, trim and quality).

*models.p**y*

[…]

###

# SIGNALS #

###

from django.db.models.signals import post_save, pre_delete

from django.dispatch import receiver

from myproject.settings import MEDIA_ROOT

import subprocess


# What to do after a File is saved - receiver definition

def file_post_save(sender, instance=False, **kwargs):

# This post save function creates a thumbnail for the File

file = File.objects.get(pk=instance.pk )

command = "convert -density 300 -trim -thumbnail %s %s%s[0]
-quality 100 %s%s" % (file.thumbnail_size, MEDIA_ROOT, file.file,
MEDIA_ROOT, file.thumbnail)

proc = subprocess.Popen(command,

shell=True,

stdin=subprocess.PIPE,

stdout=subprocess.PIPE,

stderr=subprocess.PIPE,

)

stdout_value = proc.communicate()[0]

post_save.connect(file_post_save, sender=File,
dispatch_uid="file_post_save_uid")

# What to do before a File is deleted - receiver definition

def file_pre_delete(sender, instance=False, **kwargs):

# This pre delete function deletes file and thumbnail from media
directory

file = File.objects.get(pk=instance.pk )

command = "rm %s%s %s%s" % (MEDIA_ROOT, file.file, MEDIA_ROOT,
file.thumbnail)

proc = subprocess.Popen(command,

shell=True,

stdin=subprocess.PIPE,

stdout=subprocess.PIPE,

stderr=subprocess.PIPE,

)

stdout_value = proc.communicate()[0]

pre_delete.connect(file_pre_delete, sender=File,
dispatch_uid="file_pre_delete_uid")

-- 
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 https://groups.google.com/group/django-users
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/e409aafa-3133-47b1-b465-7d74501d0cac%40googlegroups.com

Re: get_available_name() got an unexpected keyword argument 'max_length'

2016-09-05 Thread Nelson Fajardo
Hi, wich dependency do you update? I just get the same error, but i cant 
find it!

thks,

On Wednesday, August 31, 2016 at 6:20:49 AM UTC-5, manolo gomez wrote:
>
> I thought that I've checked all my dependecies, and effectively I forget 
> to update one of them. Now it's working, thank you very much.
>
> El martes, 30 de agosto de 2016, 18:45:23 (UTC+2), Tim Graham escribió:
>>
>> You need to update your own code or one of your dependencies as per 
>> https://docs.djangoproject.com/en/stable/releases/1.8/#support-for-the-max-length-argument-on-custom-storage-classes
>> .
>>
>> If you follow 
>> https://docs.djangoproject.com/en/stable/howto/upgrade-version/ with an 
>> older version of Django (1.8 or 1.9), you should see a helpful deprecation 
>> warning.
>>
>> On Tuesday, August 30, 2016 at 9:39:46 AM UTC-4, manolo gomez wrote:
>>>
>>> Hi,
>>>
>>>I've updated from django 1.8 to 1.10, and now when save a ImageFile 
>>> I'm getting the next error:
>>>   
>>>get_available_name() got an unexpected keyword argument 'max_length'
>>>
>>>   
>>> This is the end of the Traceback:
>>> File "/home/dev/Documents/web/children/views/views.py" in post
>>>
>>>   73. ob.avatar.save(t[0], t[1])
>>>
>>>  File 
>>> "/home/securekids/Documents/enviroments/dev/local/lib/python2.7/site-packages/django/db/models/fields/files.py"
>>>  in save
>>>   91. self.name = self.storage.save(name, content, 
>>> max_length=self.field.max_length)
>>>
>>> File 
>>> "/home/securekids/Documents/enviroments/dev/local/lib/python2.7/site-packages/django/core/files/storage.py"
>>>  in save
>>>   53. name = self.get_available_name(name, max_length=max_length)
>>>
>>>
>>>   I've tried to remove  "max_length=max_length", and then it's working 
>>> fine, but I don't like so much to touch the django core :)
>>>   
>>>Anyone can help me? 
>>>
>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4763fcc0-e292-4913-9d9c-07c675af936a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin login returns 405 Not Allowed

2016-09-05 Thread Peter Laudenslager
PARTIALLY SOLVED!!

The trouble seems to be with memcached.  I commented out references to 
memcached in the nginx configuration, and things started working properly.

I assume the admin page can be used with memcached, but something is wrong 
with my configuration.  Maybe related to the post command?  (so far, the 
rest of my site uses "get" only, other than the admin pages).

below is a snip from the nginx configuration file (in sites-available).   
The memcached lines are commented out:

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;

#set $memcached_key "$uri?$args";
#memcached_pass 127.0.0.1:11211;
#error_page 404 502 504 = @fallback;
}

location @fallback {
proxy_pass http://app_server;
}

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75a599b1-d9a7-4b9e-b4d7-a3c964a3ace5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin login returns 405 Not Allowed

2016-09-05 Thread Peter Laudenslager

>
> Here is the specific error logged by Django's debug logger:


Exception while resolving variable 'is_popup' in template 
'admin/login.html'.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", 
line 907, in _resolve_lookup
(bit, current))  # missing attribute
VariableDoesNotExist: Failed lookup for key [is_popup] in u"[{'False': 
False, 'None': None, 'True': True}, {u'csrf_token': >, 'user': >, 
'perms': , 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 
'WARNING': 30, 'SUCCESS': 25, 'ERROR': 40}, 'messages': 
, u'request': }, {}, {'username': u'', 'app_path': 
u'/admin/login/?next=/admin/', 'available_apps': [], 'site_name': 
'app_server', 'form': , 'title': u'Log in', 'site_header': 
, 'site': 
, 
'next': u'/admin/', 'site_title': , u'LANGUAGE_CODE': 'en-us', 'has_permission': False, 
'site_url': '/', u'LANGUAGE_BIDI': False}]" 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6653fbd4-4903-4ffa-84d7-ecac4d846f1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.core.exceptions.FieldDoesNotExist but the field exists

2016-09-05 Thread Michal Petrucha
On Mon, Sep 05, 2016 at 08:44:55AM -0700, Stefano Tranquillini wrote:
> Hello
> 
> I've a problem syncing the db.
> 
> I run the command: django-admin migrate
> 
> System check identified some issues:
> Operations to perform:
>   Synchronize unmigrated apps: oauth2_provider, 
>   Apply all migrations: admin, Synchronizing apps without 
> migrations:
>   Creating tables...
> Running deferred SQL...
>   Installing custom SQL...Running migrations:
>   No migrations to apply.Traceback (most recent call last):
>   File "/Users/stefano/.virtualenvs/prjrest/bin/django-admin", line 11, in 
> 
> sys.exit(execute_from_command_line())
>   File 
> "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/core/management/__init__.py",
>  line 354, in execute_from_command_line
> utility.execute()
>   File 
> "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/core/management/__init__.py",
>  line 346, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/core/management/base.py",
>  line 394, in run_from_argv
> self.execute(*args, **cmd_options)
>   File 
> "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/core/management/base.py",
>  line 445, in execute
> output = self.handle(*args, **options)
>   File 
> "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>  line 208, in handle
> changes = autodetector.changes(graph=executor.loader.graph)
>   File 
> "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/db/migrations/autodetector.py",
>  line 43, in changes
> changes = self._detect_changes(convert_apps, graph)
>   File 
> "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/db/migrations/autodetector.py",
>  line 165, in _detect_changes
> old_field = self.old_apps.get_model(app_label, 
> old_model_name)._meta.get_field(field_name)
>   File 
> "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/db/models/options.py",
>  line 554, in get_field
> raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, 
> field_name))
> django.core.exceptions.FieldDoesNotExist: CustomerKey has no field named 
> u'customer_key_cipher_text'
> 
> So, it seems that there are not migration, but still django complains for a 
> missing field. 
> 
> However in the model the field is there
> 
> 
> class CustomerKey(models.Model):...
> customer_key_cipher_text = Base64Field(default='')
> 
> Any idea on what's the problem?

According to the stack trace, this error happens when the autodetector
is trying to get the model field from a previous state of the models,
which is determined from the migration history, not the current model
definitions.

Have you by any chance made any changes to any of the existing
migrations? I can imagine that this could happen if one of your
migrations tries to make an AlterField operation on a field that
hasn't been created in any of the preceding migrations.

Good luck,

Michal

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160905155543.GJ6601%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


django.core.exceptions.FieldDoesNotExist but the field exists

2016-09-05 Thread Stefano Tranquillini
Hello

I've a problem syncing the db.

I run the command: django-admin migrate

System check identified some issues:
Operations to perform:
  Synchronize unmigrated apps: oauth2_provider, 
  Apply all migrations: admin, Synchronizing apps without 
migrations:
  Creating tables...
Running deferred SQL...
  Installing custom SQL...Running migrations:
  No migrations to apply.Traceback (most recent call last):
  File "/Users/stefano/.virtualenvs/prjrest/bin/django-admin", line 11, in 

sys.exit(execute_from_command_line())
  File 
"/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/core/management/__init__.py",
 line 354, in execute_from_command_line
utility.execute()
  File 
"/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/core/management/__init__.py",
 line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/core/management/base.py",
 line 394, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/core/management/base.py",
 line 445, in execute
output = self.handle(*args, **options)
  File 
"/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
 line 208, in handle
changes = autodetector.changes(graph=executor.loader.graph)
  File 
"/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/db/migrations/autodetector.py",
 line 43, in changes
changes = self._detect_changes(convert_apps, graph)
  File 
"/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/db/migrations/autodetector.py",
 line 165, in _detect_changes
old_field = self.old_apps.get_model(app_label, 
old_model_name)._meta.get_field(field_name)
  File 
"/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-packages/django/db/models/options.py",
 line 554, in get_field
raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, 
field_name))
django.core.exceptions.FieldDoesNotExist: CustomerKey has no field named 
u'customer_key_cipher_text'

So, it seems that there are not migration, but still django complains for a 
missing field. 

However in the model the field is there


class CustomerKey(models.Model):...
customer_key_cipher_text = Base64Field(default='')

Any idea on what's the problem?


PS: the question is also on SO 
http://stackoverflow.com/questions/39333759/django-core-exceptions-fielddoesnotexist-but-the-field-exists


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/96c81cd5-9a49-47ce-90f8-7bab3096c927%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError: view must be a callable or a list/tuple in the case of include(). in urls.py

2016-09-05 Thread 'Abraham Varricatt' via Django users
Not sure what the issue is without more info about the error, but is the 
regular expression for that view correct? Assuming that you want to divert 
folks to the root of your site can you try the following?

url(r'^/$', views.dashboard, name = 'dashboard')


NOTE: if the error still persists, it will help if you include the full 
traceback in your email.

Yours,
Abraham V.



On Monday, September 5, 2016 at 6:36:37 PM UTC+5:30, arun kumar wrote:
>
> Hi,
>
>I'm working in Django 1.10 and I got the type error  in the below file 
> at this line "* url(r'^$', views.dashboard, name = 'dashboard'),*"
>
> *from django.conf.urls import include, url*
> *from . import views*
>
> *urlpatterns = [*
> *#preview login view*
> *#url(r'^login/$',views.user_login, name='login')*
>
> *# logged - in user dashboard*
> *url(r'^$', views.dashboard, name = 'dashboard'),*
>
> *#login / logout urls*
> *url(r'^login/$', 'django.contrib.auth.views.login', name='login'),*
>
> *url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'),*
>
> *
> url(r'^logout-then-login/$','django.contrib.auth.views.logout_then_login', 
> name='logout_then_login')*
>
> *]*
>
> I'm new to Django and stuck because of 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e58d1158-ad6b-47af-8ae9-be77e08e9ee3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django migrations taking all the memory on Django 1.9

2016-09-05 Thread andrea crotti
Thanks Marcus and others, this issue is in general getting worse and worse.

We did some more investigation and we should probably just help out the 
work you are doing.

Do you think it would be possible to apply these changes also on Django 
1.9.9 or it has to be from master/1.10 only?

I also tried another approach:
- use "./manage.py sqlmigrate  " to generate the SQL
- add in the generated SQL the INSERT to django_migrations
- run the SQL manually in the DB

This actually works and could be automated, but I'm quite sure it's not a 
good idea..
But what do you think could go wrong with this approach?

I would say that as long as the dependencies are met and things are done in 
the right order it might be safe enough, but of course we get into muddy 
waters..

On Monday, August 8, 2016 at 2:36:23 PM UTC+1, Tim Graham wrote:
>
> I think that error suggests that you disabled migrations for an app 
> (something_else) that's a dependency of another app that doesn't have 
> migrations disabled (something). That isn't permitted. I guess there's no 
> good solution for your requirements as of now.
>
> On Monday, August 8, 2016 at 6:02:48 AM UTC-4, andrea crotti wrote:
>>
>> Since we also use --keepdb I thought we could simply avoid running all 
>> the migrations, and maybe dynamically even skip all the apps that were not 
>> changed at all. 
>>
>> So I just tried something silly like this:
>>
>>
>> NO_MIGRATIONS = os.environ.get('NO_MIGRATIONS', 'false').lower() in 
>> ('true', '1')
>> if NO_MIGRATIONS:
>> for app in INSTALLED_APPS:
>> if app not in MIGRATION_MODULES:
>> MIGRATION_MODULES[app] = None
>>
>>
>> But I get this error:
>>
>> django.db.migrations.exceptions.NodeNotFoundError: Migration 
>> something.0001_initial dependencies reference nonexistent parent node 
>> ('something_else', u'0001_initial')
>>
>> So I guess it's not as simple (and maybe that ticket is what that's 
>> about, but sadly it's not even merged in master now from my understanding).
>>
>> PS. so to clarify our tests do rely on migrations (and there are some 
>> data migrations too) but since we normally use --keepdb anyway we 
>> definitively not need to run only a few migrations at a time max (and even 
>> then sometimes it takes ages and uses all the RAM).
>>
>> On Saturday, August 6, 2016 at 4:03:50 PM UTC+1, Tim Graham wrote:
>>>
>>> As long as your tests don't rely on any data migrations, you can set 
>>> MIGRATIONS_MODULES['app'] = None for all apps in a test settings file as 
>>> described in 
>>> https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-MIGRATION_MODULES
>>>  
>>> to disable migrations while testing. There's a ticket to make that a bit 
>>> easier: https://code.djangoproject.com/ticket/25388
>>>
>>> On Saturday, August 6, 2016 at 6:07:04 AM UTC-4, andrea crotti wrote:


 Ok great thanks for the answer Markus.
 And yes I can try to help, it's quite a big issue for us..
 Anything else we can do to improve the situation in the meanwhile?

 In general I was wondering why do we need to handle all the "baggage" 
 of supporting backward migrations and doing things 100% properly while 
 running migrations just for tests.

 I think that in general if there was just a way to render all the SQL 
 that needs to be run statically for tests it would be great.

 On Friday, August 5, 2016 at 11:07:56 AM UTC+1, andrea crotti wrote:
>
> We have a very big Django project with > 100 apps and > 300 models.
> We had some massive issues with Django 1.8 and migrations, which would 
> take forever and just take all the computer memory after a while.
>
> Now with Django 1.9 things improved, however we are again back with 
> some extremely bad performances and massive memory usages (up to 8GB of 
> RAM 
> for example), sometimes just to run ONE single migration.
>
> It's not even entirely deterministic though sometimes killing the 
> process and doing it again just works.
>
> I'm attaching the profile graph (done wtith gprof2dot) from running 
> "./manage migrate" and one thing that clearly looks bad is that *render* 
> for example is called 44355 times, which is definitively not normal.
>
> Any idea about about what we can do about this and what could be the 
> problem?
> I have the impression that it's related with the amount of models and 
> how they are interconnected, and mabye some caching would avoid all this 
> extra computation.
>
> Noone else has similar issues?
> 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 https://groups.google.com/group/django-users.
To 

Re: Binding a ModelForm to an existing instance

2016-09-05 Thread Vadim Serdiuk
Hi Carlos. 
At first you should get an article, then put it to the form via instance 
parameter. If article is not found, instance is None. Than if form is 
valid, method 'save' creates new object or updates old one.

if request.method == 'POST':
try: 
article = Article.objects.get(url=form.cleaned_data['url'])
except Article.DoesNotExist:
article = None

form = ArticleForm(request.POST, instance=article)
if form.is_valid():
form.save()
return redirect(reverse('articles:list'))
else:
form = ArticleForm()
return render(request, 'articles/get_article.html', {'form': form})



понедельник, 5 сентября 2016 г., 5:36:29 UTC+3 пользователь Carlos 
Mermingas написал:
>
> I have a ModelForm:
>
> class ArticleForm(forms.ModelForm):
>
> class Meta:
>
> model = Article
>
> fields = ['url',]
>
>
> The Article model has a url field which is unique. I want users to enter a 
> URL. If the Article already exists, it gets reused. Otherwise, a new instance 
> is created.
>
>
> And the corresponding view:
>
>
>  1 @login_required
>
>  2 def get_article(request):
>
>  3if request.method == 'POST':
>
>  4# Should I get a new instance here?
>
>  5form = ArticleForm(request.POST, instance=None)
>
>  6if form.is_valid():
>
>  7article, created = 
> Article.objects.get_or_create(url=form.cleaned_data['url']) 
>
>  9# Some more work goes here
>
> 10return redirect(reverse('articles:list'))
>
> 11else:
>
> 12form = ArticleForm()
>
> 13return render(request, 'articles/get_article.html', {'form': form})
>
>
> The form is validating the uniqueness of the model, which is great. The 
> dilemma I am having is that I would like to bind the form to the existing 
> instance in line 4. But at that point, the form has not been cleaned, so I 
> wouldn't want to hit the database with it.
>
>
> *What's the proper pattern to do this?*
>
>
> Thanks a lot!
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3e94ef19-a973-4ef5-b598-51a90f33aa47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Blank field object just for headings in form object

2016-09-05 Thread Vadim Serdiuk
Ma
I guess you should look at 
fieldsets 
https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#django.contrib.admin.ModelAdmin.fieldsets

воскресенье, 4 сентября 2016 г., 20:34:52 UTC+3 пользователь Shane Fagan 
написал:
>
> Hi,
>
> I asked this question on Stackoverflow but didn't get any answers so 
> hopefully someone can give me an answer here. The Stackoverflow is 
> http://stackoverflow.com/questions/39317812/django-forms-form-header-field To 
> start I'm creating fields on the fly for a question sheet project that 
> takes in admin created questions. The issue is I need to do a heading for 
> sections for walking people through the form. 
>
> Any ideas? I was thinking of creating a field object to use but I didn't 
> get much from the docs since it's pretty much a stub that focuses more on 
> overloading the current fields and doing custom validation..etc. 
>
> Regards,
> Shane
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3e366589-f57a-4426-b330-bab00ffb785e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to design URL pattern to get the field value using request.query_params.get in the view

2016-09-05 Thread Siddharth Ghumre
If I understand it correctly, for this view your url must correspond to

http://www.mysite.com/xyz?year=2015

Here as per standard url protocol, anything you pass after the "?"
(question mark) is passed as a request.query_params to the views.

Hope this helps.
Sid


On Sun, Sep 4, 2016 at 10:03 PM, Afiz S  wrote:

> Hi All,
>
> I have very new to Django. Can anyone tell me how to the data from URL to
> view.
>
> in this below example I am trying to get year param from the URL.
>
> def get_queryset(self):
> queryset = Battles.objects.all()
> year = self.request.query_params.get('year',None)
> if year is not None:
> queryset = queryset.filter(year__exact=year)
> return queryset
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/693bbae5-0ffc-4737-86be-a9cee202e68e%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANtEdp6n%2Bj5Gar-XVcEU%3DhRooy8nOCW_iMBBDCE_BM%2BnOkuDyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


TypeError: view must be a callable or a list/tuple in the case of include(). in urls.py

2016-09-05 Thread arun kumar
Hi,

   I'm working in Django 1.10 and I got the type error  in the below file 
at this line "* url(r'^$', views.dashboard, name = 'dashboard'),*"

*from django.conf.urls import include, url*
*from . import views*

*urlpatterns = [*
*#preview login view*
*#url(r'^login/$',views.user_login, name='login')*

*# logged - in user dashboard*
*url(r'^$', views.dashboard, name = 'dashboard'),*

*#login / logout urls*
*url(r'^login/$', 'django.contrib.auth.views.login', name='login'),*

*url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'),*

*
url(r'^logout-then-login/$','django.contrib.auth.views.logout_then_login', 
name='logout_then_login')*

*]*

I'm new to Django and stuck because of 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e7687a0c-8ba6-40a7-b835-2ac304d6fdf4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Blank field object just for headings in form object

2016-09-05 Thread ludovic coues
do you mind to share the model holding the questions created in admin ?

2016-09-04 19:33 GMT+02:00 Shane Fagan :
> Hi,
>
> I asked this question on Stackoverflow but didn't get any answers so
> hopefully someone can give me an answer here. The Stackoverflow is
> http://stackoverflow.com/questions/39317812/django-forms-form-header-field
> To start I'm creating fields on the fly for a question sheet project that
> takes in admin created questions. The issue is I need to do a heading for
> sections for walking people through the form.
>
> Any ideas? I was thinking of creating a field object to use but I didn't get
> much from the docs since it's pretty much a stub that focuses more on
> overloading the current fields and doing custom validation..etc.
>
> Regards,
> Shane
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8abc46b4-6706-45cc-8942-100bb9ada943%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTYrg29vutxrM2vcibm7K2MA8iVNFLTbwh47PtT5QX_3zA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.