Re: Forms admin

2015-03-05 Thread Julien Castets
On Thu, Mar 5, 2015 at 6:49 PM, Aurélio Moreira
 wrote:
> Hello guys , I 'm building a system in Django and is my first contact with
> the language , enjoyed the admin, but my tables have many, many fields even
> , I would like to know the following : Are you like me to change the output
> of forms ? I would like to control the layout of the form of each module ,
> it is possible?

Hi,

Give a look to https://github.com/maraujop/django-crispy-forms

-- 
Julien Castets

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


Forms admin

2015-03-05 Thread Aurélio Moreira


Hello guys , I 'm building a system in Django and is my first contact with the 
language , enjoyed the admin, but my tables have many, many fields even , I 
would like to know the following : Are you like me to change the output of 
forms ? I would like to control the layout of the form of each module , it is 
possible?

-- 
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/8f444302-dd6f-47b0-98d6-f03c27fefac2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TemplateSyntaxError with {% cycle "Hello, how are you?" "Fine!" %}

2015-03-05 Thread Carsten Fuchs

Hi Vijay, hi Alasdair,

many thanks for your quick replies!
I've thus just filed a bug: https://code.djangoproject.com/ticket/24451

Am 05.03.2015 um 17:53 schrieb Alasdair Nicol:

I think the reason is that the cycle tag supports an older syntax for
backwards compatibility reasons.


Yes, that was my thought, too, but I was wondering if I was accidentally 
triggering the old syntax in a somehow "correct" manner that I didn't 
quite see...



A work around would be to assign "Hello, how are you" to a variable.


Yes, thanks!


If you use single quotes and render the template, it outputs 'Hello',
not 'Hello, how are you?' as expected.


As expected? Why please? Docs say that with single or double quotes, the 
values are treated as string literals.


Best regards,
Carsten

--
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/54F89104.1080903%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


Re: TemplateSyntaxError with {% cycle "Hello, how are you?" "Fine!" %}

2015-03-05 Thread Alasdair Nicol

Hi Carsten, Vijay

On 05/03/15 16:24, Carsten Fuchs wrote:
> Dear Django fellows,
>
> using Django 1.7.5, I have a problem with commas in string literals in
> the cycle tag, e.g. with
>
>  {% cycle "Hello, how are you?" "Fine!" %}.

I can reproduce the problem with your sample code.

I think the reason is that the cycle tag supports an older syntax for 
backwards compatibility reasons.


{% cycle row1,row2,row3 %}

It looks like this prevents you from using commas in strings when using 
the new syntax.


> This happens with or without {% load cycle from future %}

The future version of the cycle tag applies HTML escaping to its 
variables. So using it or not using it shouldn't have any affect on your 
issue.


A work around would be to assign "Hello, how are you" to a variable.

{% with hello="Hello, how are you?"
{% cycle hello "Fine!" %}.
{% endwith %}

On 05/03/15 16:48, Vijay Khemlani wrote:
> Changing the double quotes for single quotes seems to do the trick, 
but I don't know why it works


If you use single quotes and render the template, it outputs 'Hello', 
not 'Hello, how are you?' as expected.


Cheers,
Alasdair

[1] https://docs.djangoproject.com/en/1.7/ref/templates/builtins/#cycle

--
Alasdair Nicol
Developer, MEMSET

mail: alasd...@memset.com
 web: http://www.memset.com/

Memset Ltd., registration number 4504980.
Building 87, Dunsfold Park, Stovolds Hill, Cranleigh, Surrey, GU6 8TB, UK

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


Re: TemplateSyntaxError with {% cycle "Hello, how are you?" "Fine!" %}

2015-03-05 Thread Alasdair Nicol

On 05/03/15 16:53, Alasdair Nicol wrote:

{% with hello="Hello, how are you?"
{% cycle hello "Fine!" %}.
{% endwith %}


Oops, that should have read:

{% with hello="Hello, how are you?" %}
{% cycle hello "Fine!" %}.
{% endwith %}

--
Alasdair Nicol
Developer, MEMSET

mail: alasd...@memset.com
 web: http://www.memset.com/

Memset Ltd., registration number 4504980.
Building 87, Dunsfold Park, Stovolds Hill, Cranleigh, Surrey, GU6 8TB, UK

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


Re: TemplateSyntaxError with {% cycle "Hello, how are you?" "Fine!" %}

2015-03-05 Thread Vijay Khemlani
Changing the double quotes for single quotes seems to do the trick, but I
don't know why it works

On Thu, Mar 5, 2015 at 1:24 PM, Carsten Fuchs  wrote:

> Dear Django fellows,
>
> using Django 1.7.5, I have a problem with commas in string literals in the
> cycle tag, e.g. with
>
> {% cycle "Hello, how are you?" "Fine!" %}.
>
> Please consider (newlines added for clarity):
>
> $ ./manage.py shell
>
> >>> from django.template import *
> >>> t = Template('''{% cycle "Hello, how are you?" "Fine!" %}''')
> >>>
>
> /home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-
> packages/django/template/base.py:290: RemovedInDjango18Warning: 'The
> `cycle` template tag is changing to escape its arguments; the
> non-autoescaping version is deprecated. Load it from the `future` tag
> library to start using the new behavior.
>   compiled_result = compile_func(self, token)
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-
> packages/django/template/base.py", line 132, in __init__
> self.nodelist = compile_string(template_string, origin)
>   File "/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-
> packages/django/template/base.py", line 162, in compile_string
> return parser.parse()
>   File "/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-
> packages/django/template/base.py", line 290, in parse
> compiled_result = compile_func(self, token)
>   File "/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-
> packages/django/template/defaulttags.py", line 648, in cycle
> values = [parser.compile_filter(arg) for arg in args[1:]]
>   File "/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-
> packages/django/template/base.py", line 372, in compile_filter
> return FilterExpression(token, self)
>   File "/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-
> packages/django/template/base.py", line 588, in __init__
> "from '%s'" % (token[upto:], token))
> TemplateSyntaxError: Could not parse the remainder: 'Hello"' from
> '""Hello"'
>
>
> This happens with or without {% load cycle from future %}
>
> A bug? Or am I doing something wrong?
>
> Best regards,
> Carsten
>
> --
> 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/54F8834D.7010403%40cafu.de.
> 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/CALn3ei2m7TaYq2pcPV1%2ByX%2Bv5sec8E4uKz6uyu%2BnDnCpcGTBJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


TemplateSyntaxError with {% cycle "Hello, how are you?" "Fine!" %}

2015-03-05 Thread Carsten Fuchs

Dear Django fellows,

using Django 1.7.5, I have a problem with commas in string literals in 
the cycle tag, e.g. with


{% cycle "Hello, how are you?" "Fine!" %}.

Please consider (newlines added for clarity):

$ ./manage.py shell

>>> from django.template import *
>>> t = Template('''{% cycle "Hello, how are you?" "Fine!" %}''')
>>>

/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-packages/django/template/base.py:290: 
RemovedInDjango18Warning: 'The `cycle` template tag is changing to 
escape its arguments; the non-autoescaping version is deprecated. Load 
it from the `future` tag library to start using the new behavior.

  compiled_result = compile_func(self, token)

Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-packages/django/template/base.py", 
line 132, in __init__

self.nodelist = compile_string(template_string, origin)
  File 
"/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-packages/django/template/base.py", 
line 162, in compile_string

return parser.parse()
  File 
"/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-packages/django/template/base.py", 
line 290, in parse

compiled_result = compile_func(self, token)
  File 
"/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-packages/django/template/defaulttags.py", 
line 648, in cycle

values = [parser.compile_filter(arg) for arg in args[1:]]
  File 
"/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-packages/django/template/base.py", 
line 372, in compile_filter

return FilterExpression(token, self)
  File 
"/home/carsten/.virtualenvs/Ze/local/lib/python2.7/site-packages/django/template/base.py", 
line 588, in __init__

"from '%s'" % (token[upto:], token))
TemplateSyntaxError: Could not parse the remainder: 'Hello"' from '""Hello"'


This happens with or without {% load cycle from future %}

A bug? Or am I doing something wrong?

Best regards,
Carsten

--
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/54F8834D.7010403%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


Zinnia models migration error: InvalidBasesError: Cannot resolve bases for []

2015-03-05 Thread Felipe
I'm having a little trouble integrating a zinnia app into my current 
application.

(project)username@computername:~/project/application$ python manage.py migrate
Operations to perform:
  Synchronize unmigrated apps: bootstrap3
  Apply all migrations: project, activity, zinnia, sessions, auth, badge, 
admin, coupon, contenttypes, sites
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations: Applying zinnia.0001_initial...Traceback (most recent call 
last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/home/username/.virtualenvs/project/local/lib/python3.4/site-packages/django/core/management/__init__.py",
 line 385, in execute_from_command_line
utility.execute()
  File 
"/home/username/.virtualenvs/project/local/lib/python3.4/site-packages/django/core/management/__init__.py",
 line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/username/.virtualenvs/project/local/lib/python3.4/site-packages/django/core/management/base.py",
 line 288, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/home/username/.virtualenvs/project/local/lib/python3.4/site-packages/django/core/management/base.py",
 line 338, in execute
output = self.handle(*args, **options)
  File 
"/home/username/.virtualenvs/project/local/lib/python3.4/site-packages/django/core/management/commands/migrate.py",
 line 161, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
  File 
"/home/username/.virtualenvs/project/local/lib/python3.4/site-packages/django/db/migrations/executor.py",
 line 68, in migrate
self.apply_migration(migration, fake=fake)
  File 
"/home/username/.virtualenvs/project/local/lib/python3.4/site-packages/django/db/migrations/executor.py",
 line 96, in apply_migration
if self.detect_soft_applied(migration):
  File 
"/home/username/.virtualenvs/project/local/lib/python3.4/site-packages/django/db/migrations/executor.py",
 line 140, in detect_soft_applied
apps = project_state.render()
  File 
"/home/username/.virtualenvs/project/local/lib/python3.4/site-packages/django/db/migrations/state.py",
 line 75, in render
"for more" % new_unrendered_models
django.db.migrations.state.InvalidBasesError: Cannot resolve bases for 
[]
This can happen if you are inheriting models from an app with migrations (e.g. 
contrib.auth)
 in an app with no migrations; see 
https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies for more


I'm using python 3.4.0 django 1.7.5 and latest versions of zinnia (0.15.1).

This is the output of my pip freeze: (as I said, its an existing app so I 
have other packages installed for it)


beautifulsoup4==4.3.2Django==1.7.5
django-blog-zinnia==0.15.1
django-bootstrap3==5.1.1
django-braces==1.4.0
django-contrib-comments==1.5
django-mptt==0.6.1
django-tagging==0.3.4
django-xmlrpc==0.1.5
enum34==1.0.4
flake8==2.3.0
ipaddress==1.0.7
ipython==3.0.0
isort==3.9.6
jedi==0.8.1
mccabe==0.3
mots-vides==2015.2.6
natsort==3.5.2
pathlib==1.0.1
pbr==0.10.7
pep8==1.6.2
pep8-naming==0.2.2
pies==2.6.3Pillow==2.7.0
psycopg2==2.6
pyflakes==0.8.1
pyparsing==2.0.3
python3-memcached==1.51
pytz==2014.10
raven==5.2.0
requests==2.5.3
six==1.9.0
stevedore==1.2.0
virtualenv==12.0.7
virtualenv-clone==0.2.5
virtualenvwrapper==4.3.2



I have a feeling this has to do with a model I have in my application which 
has from django.contrib.auth.models import AbstractBaseUser, 
PermissionsMixin, UserManager But I can't imagine not using that in my app. 
Maybe it's time to look for another blog package.


Mi environment seems ok because I install zinnia on a empty app locally, 
and it works fine.

I've created a stackoverflow question to ask for help, in case you'd rather 
answer over there:
http://stackoverflow.com/questions/28796128/django-migrate-with-zinnia-invalidbaseserror-cannot-resolve-bases-for-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/22793f2f-e7ea-45ea-a705-2bef362102c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Rewrite (port) project from PHP (Code Igniter) to Django

2015-03-05 Thread Scot Hacker
On Thursday, March 5, 2015 at 4:28:13 AM UTC-8, Alexey Milogradov wrote:
>
> Hello everyone!
>
> I would like to collect thoughts, articles, posts, code bases, actually 
> any shared experience on how to port existing project from PHP to 
> Python/Django.
>

The specifics of the process are really different for each project, there's 
not much that can be said as a generality, but my advice:

1) Conceptualize  the major pieces of functionality of the site into what 
will become separate Django apps. Create a blank Django project with those 
apps stubbed out.

2) Starting with inspectdb,  break up its output into the various models.py 
files of the various apps.

3) Before working on any other part of the site, spend a good long time 
massaging those data models to perfection, using a combination of the 
Django Admin and ./manage.py shell. Work with the ORM to make sure every 
aspect of the data modeling is working exactly as you expect. All data 
relationships should be wired up properly before proceeding. 

4) Take a generated HTML page from the old site and save it base.html in 
your new project. Bring in all the CSS, JS and static media. Once that's 
working, break it up into the template fragments you'll need and get the 
basic interaction workflow of the site working.

The rest is standard Django development and has nothing to do with porting 
per se'.

I personally wouldn't worry about bridge plugins or anything. 

./s

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/960eec33-d0eb-4540-a9a7-df986739b166%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where to post documentation suggestions?

2015-03-05 Thread Tim Graham
Same ticket tracker: https://code.djangoproject.com/newticket

Is there some place where you saw bug reports and feature requests 
mentioned that we should add "documentation updates" so we could have 
prevented your confusion?

On Thursday, March 5, 2015 at 7:33:02 AM UTC-5, Sakari Ellonen wrote:
>
> It took me some time to realize that the names of unittest test methods 
> must start with "test_". It says so in the python unittest documentation, 
> but I think mentioning it in the Django documentation could save someone 
> else a non-negligible amount of time. Just a brief mention here would be 
> sufficient: 
> https://docs.djangoproject.com/en/1.6/topics/testing/overview/#running-tests
>  
>
> However, looking at the documentation, I found a bigger problem. It is not 
> clear to me where to even post suggestions for documentation improvement. 
> Bug reports and feature requests are covered, but I think contributing to 
> documentation is where the widest group of people could participate.
>
> -Sakari
>

-- 
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/5a81f53d-f9ee-4ee8-a9db-bbd700a2ccf7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Where to post documentation suggestions?

2015-03-05 Thread Sakari Ellonen
It took me some time to realize that the names of unittest test methods 
must start with "test_". It says so in the python unittest documentation, 
but I think mentioning it in the Django documentation could save someone 
else a non-negligible amount of time. Just a brief mention here would be 
sufficient: 
https://docs.djangoproject.com/en/1.6/topics/testing/overview/#running-tests 

However, looking at the documentation, I found a bigger problem. It is not 
clear to me where to even post suggestions for documentation improvement. 
Bug reports and feature requests are covered, but I think contributing to 
documentation is where the widest group of people could participate.

-Sakari

-- 
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/5a635f4d-0616-400a-8e51-8fc0802aef77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Rewrite (port) project from PHP (Code Igniter) to Django

2015-03-05 Thread Alexey Milogradov


Hello everyone!

I would like to collect thoughts, articles, posts, code bases, actually any 
shared experience on how to port existing project from PHP to Python/Django.

Platform agnostic advises or thoughts are appreciated as well.

There are my initial quick thoughts and findings on what should be handeled:

   1. Use of legacy database - Djagno's inspectdb 
   
   2. It should be modular porting to start using new code as soon as 
   possible.
   3. In case of modular porting, user session sharing should be handled - 
   PolicyStat's posts about their experience: part 1 
   
   , part 2  and 
their 
   django-php-bridge plugin 
   4. Working with servers - ?
   5. ???

Although I'd like to get as much information as possible, there are 
technologies assumed to be used in my particular case: PHP, Code Igniter -> 
Django, Django REST Framework, Angular.js.

-- 
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/14ba8ea5-d894-4f1d-b7d8-a73e6231bfb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Data migration using RunPython

2015-03-05 Thread aRkadeFR


On 03/05/2015 10:01 AM, Murthy Sandeep wrote:

Thanks,

Two further questions if you don’t mind:

1. I am in the Python interpreter and am working with
one of my db models called SmallGroup.

When I do SmallGroup.objects.all() I get the following message:

File "", line 1, in 
   File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 
119, in __repr__
 return repr(data)
   File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 458, 
in __repr__
 u = six.text_type(self)
TypeError: coercing to Unicode: need string or buffer, SmallGroup found

Does this have something to do with the method `__str__` which I added
to this model in my `models.py`?  I don’t think I did a ‘python manage.py 
migrate’ after
the change though.


There's two problems yeah, you didn't run your migrations, and maybe
you have unicode encoding problem.
Please, check the documentation on migration[1] and unicode[2].



2. If I want to modify or delete entries in the db table SmallGroup are there
methods corresponding to `bulk_create` for doing this?  Something like

Country.objects.using(db_alias).bulk_update(  )

Country.objects.using(db_alias).bulk_delete(  )

?


You have all you need in the documentation [3].
You have the .update and .delete methods on a queryset.


Thanks again in advance.

Sandeep


[1] migrations: https://docs.djangoproject.com/en/1.7/topics/migrations/
[2] unicode with python 2: https://docs.python.org/2/howto/unicode.html
[3] https://docs.djangoproject.com/en/1.7/topics/db/queries/


On 5 Mar 2015, at 19:34, aRkadeFR  wrote:

Hello,

In Django, you can instanciate objects from your model without
persist it to the database. The way you do it is Country(name=..., ...).

In order to create multiple objects at once, you can
call the bulk_create method on the manager with a list
of object to persist.

The using(db_alias) is instanciating the manager.
I won't explain further cause my knowledge of this area
is reduced.

Have a good one

On 03/05/2015 01:20 AM, Murthy Sandeep wrote:

I am working on a data migration for my Django app to populate
the main table in the db with data that will form the mainstay of
the app - this is persistent/permanent data that may added to but
never deleted.

My reference is the Django 1.7 documentation and in particular an
example on page

https://docs.djangoproject.com/en/1.7/ref/migration-operations/#django.db.migrations.operations.RunPython

with a custom method called forward_funcs:

def forwards_func(apps, schema_editor):

# We get the model from the versioned app registry;
# if we directly import it, it'll be the wrong version


Country = apps.get_model("myapp", "Country")
db_alias = schema_editor.connection.alias
Country.objects.using(db_alias).bulk_create([
Country(name="USA", code="us"),
Country(name="France", code="fr"),])

I was wondering if someone could please explain what is happening
here and how this method works - is the argument  to bulk_create a
list of namedtuple objects called Country or are these Country model
objects?

Also could someone please explain what db_alias is?

Sandeep



--
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/54F814FC.9090407%40arkade.info.
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/54F824F6.7040109%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


how pass get parameter django bootstrap pagination

2015-03-05 Thread SHINTO PETER
 {% load bootstrap_pagination %}
  {% bootstrap_paginate object_list range=10 %}

-- 
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/b14a8f31-785b-429b-bd4a-e7518a7b851a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Future for Django, Jobs, Confused :/

2015-03-05 Thread Derek
Good point Andrew -  its certainly true for us.  Another point is that if 
you work for yourself (e.g. doing contract work), then you need to pick a 
tool that you can be productive in, as this is usually more important to 
most smaller clients than using Tool A or Tool B.

On Thursday, 5 March 2015 01:03:54 UTC+2, Andrew Farrell wrote:
>
> One thing to keep in mind is that there are more fields using primarily 
> python than using primarily ruby. A company that that does primarily 
> scientific computing in python may not advertise jobs in Django or Flask. 
> However, when they need to build a web interface for something, they will 
> reach for Django or Flask and so familiarity with that is useful.
>
> On Wed, Mar 4, 2015 at 4:55 PM, Javier Guerra Giraldez  > wrote:
>
>> On Wed, Mar 4, 2015 at 5:40 PM, François Schiettecatte
>>  wrote:
>> > commit to learning a new one every couple of years (or more often if 
>> you can).
>>
>> this.
>>
>> even if I write Python as a requisite when hiring, I expect any new
>> recruit to be able to pick languages as needed.  Of course, that
>> doesn't mean we're jumping all around, just that the languages must be
>> tools not barriers.
>>
>> --
>> 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...@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/CAFkDaoQxLm3s49B73%3D4g5zNQv65und0xvRS%3DgizDWWAw3MdVDQ%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: Data migration using RunPython

2015-03-05 Thread Murthy Sandeep
Thanks,

Two further questions if you don’t mind:

1. I am in the Python interpreter and am working with
one of my db models called SmallGroup.

When I do SmallGroup.objects.all() I get the following message:

File "", line 1, in 
  File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 119, 
in __repr__
return repr(data)
  File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 458, 
in __repr__
u = six.text_type(self)
TypeError: coercing to Unicode: need string or buffer, SmallGroup found

Does this have something to do with the method `__str__` which I added
to this model in my `models.py`?  I don’t think I did a ‘python manage.py 
migrate’ after
the change though.

2. If I want to modify or delete entries in the db table SmallGroup are there
methods corresponding to `bulk_create` for doing this?  Something like

Country.objects.using(db_alias).bulk_update(  )

Country.objects.using(db_alias).bulk_delete(  )

?

Thanks again in advance.

Sandeep

> On 5 Mar 2015, at 19:34, aRkadeFR  wrote:
> 
> Hello,
> 
> In Django, you can instanciate objects from your model without
> persist it to the database. The way you do it is Country(name=..., ...).
> 
> In order to create multiple objects at once, you can
> call the bulk_create method on the manager with a list
> of object to persist.
> 
> The using(db_alias) is instanciating the manager.
> I won't explain further cause my knowledge of this area
> is reduced.
> 
> Have a good one
> 
> On 03/05/2015 01:20 AM, Murthy Sandeep wrote:
>> I am working on a data migration for my Django app to populate
>> the main table in the db with data that will form the mainstay of
>> the app - this is persistent/permanent data that may added to but
>> never deleted.
>> 
>> My reference is the Django 1.7 documentation and in particular an
>> example on page
>> 
>> https://docs.djangoproject.com/en/1.7/ref/migration-operations/#django.db.migrations.operations.RunPython
>> 
>> with a custom method called forward_funcs:
>> 
>> def forwards_func(apps, schema_editor):
>> 
>> # We get the model from the versioned app registry;
>> # if we directly import it, it'll be the wrong version
>> 
>> 
>> Country = apps.get_model("myapp", "Country")
>> db_alias = schema_editor.connection.alias
>> Country.objects.using(db_alias).bulk_create([
>> Country(name="USA", code="us"),
>> Country(name="France", code="fr"),])
>> 
>> I was wondering if someone could please explain what is happening
>> here and how this method works - is the argument  to bulk_create a
>> list of namedtuple objects called Country or are these Country model
>> objects?
>> 
>> Also could someone please explain what db_alias is?
>> 
>> Sandeep
>> 
>> 
> 
> --
> 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/54F814FC.9090407%40arkade.info.
> 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/FB970506-5557-4EC1-90C2-A5918C36FC3F%40sandeepmurthy.is.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Data migration using RunPython

2015-03-05 Thread aRkadeFR

Hello,

In Django, you can instanciate objects from your model without
persist it to the database. The way you do it is Country(name=..., ...).

In order to create multiple objects at once, you can
call the bulk_create method on the manager with a list
of object to persist.

The using(db_alias) is instanciating the manager.
I won't explain further cause my knowledge of this area
is reduced.

Have a good one

On 03/05/2015 01:20 AM, Murthy Sandeep wrote:

I am working on a data migration for my Django app to populate
the main table in the db with data that will form the mainstay of
the app - this is persistent/permanent data that may added to but
never deleted.

My reference is the Django 1.7 documentation and in particular an
example on page

https://docs.djangoproject.com/en/1.7/ref/migration-operations/#django.db.migrations.operations.RunPython

with a custom method called forward_funcs:

def forwards_func(apps, schema_editor):

# We get the model from the versioned app registry;
# if we directly import it, it'll be the wrong version


Country = apps.get_model("myapp", "Country")
db_alias = schema_editor.connection.alias
Country.objects.using(db_alias).bulk_create([
Country(name="USA", code="us"),
Country(name="France", code="fr"),])

I was wondering if someone could please explain what is happening
here and how this method works - is the argument  to bulk_create a
list of namedtuple objects called Country or are these Country model
objects?

Also could someone please explain what db_alias is?

Sandeep




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