Performance regression when moving from 3.1 to 3.2 (same with 4)

2022-09-01 Thread Marc Parizeau
Hi,

I am seing a sharp increase in execution time for some of my queries when 
moving from Django 3.1 to 3.2. And the performance hit appears to be the 
same for Django 4.

My backend is Postgres 14.2. 

My Django project has forums for different types of content. The forum app 
consists essentially of 5 tables:

   1. a Post table that contains forum posts (essentially a text field);
   2. a Thread table where rows point to a specific content and post;
   3. a FollowUp table where rows point to a specific thread and post;
   4. a ThreadEntry table where rows point to a thread, a user, and the 
   last seen thread post for this user;
   5. a FollowUpEntry table where rows point to a followup, a user, and the 
   last seen followup post for this user.

Here is an example query that executes 2 times slower on 3.2 than on 3.1:
Content.objects.all().annotate(
  has_unread_posts=Greatest(
# a content is unread if at least one condition is true
Exists(
  # a thread has never been read (has no user entry)
  Thread.objects.filter(
content=OuterRef('pk'),
  ).exclude(threadentry__user=user)
),
Exists(
  # a thread entry is not up-to-date
  ThreadEntry.objects.filter(
thread__content=OuterRef('pk'),
user=user,
  ).exclude(post=F('thread__post'))
),
Exists(
  # a followup has no user entry
  FollowUp.objects.filter(
thread__content=OuterRef('pk')
  ).exclude(followupentry__user=user)
),
Exists(
  # a followup entry is not up-to-date
  FollowUpEntry.objects.filter(
followup__thread__content=OuterRef('pk'),
user=user,
  ).exclude(post=F('followup__post'))
),
  )
).filter(
  has_unread_posts=True,
).order_by(
  'course__uid',
  '-version__start',
).select_related(
  'course',
  'version',
)

Course and Version are other tables related to Content.

I want to know with this query, for each of the user's content, whether or 
not there is something new in the corresponding forum.  There is something 
new if any one of the following condition is true:

   1. there exists a thread for which the user has no thread entry (an 
   entry is added when the thread is first read by the user);
   2. there exists a user thread entry for which the last read post is not 
   up to date with the current thread post (the thread owner has modified the 
   post since);
   3. there exists a followup for which the user has no followup entry (an 
   entry is added when the followup is first read by the user);
   4. there exists a user followup entry for which the last read post is 
   not up to date with the followup post (the followup owner has modified the 
   post since).

On my machine, just by changing the Django version using pip, and nothing 
else, this query takes about 1 second of execution on Django 3.1.14, and a 
little more than 2 seconds on Django 3.2.15, so about a 2x increase. Here 
are the current table sizes for these execution times:

   1. Content: 33
   2. Thread: ~30K
   3. FollowUp: ~46K
   4. ThreadEntry: ~1.3M
   5. FollowUpEntry: ~4.5M
   6. Post: ~103K

Am I the only one observing such performance regressions with Django 3.2? 
On other more complex queries that contain subqueries inside subqueries, I 
have seen up to 30x execution time increases. 

Did something major happen in SQL generation from 3.1 to 3.2?

Am I doing something wrong? How can this happen?

Any help on understanding what is going on with Django 3.2 would be much 
appreciated.

Best regards,

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54287aec-dcf2-4179-b939-f099876e05a9n%40googlegroups.com.


Re: Newbie looking for some help with Postgres <> Django connection

2020-11-09 Thread Marc Johnson
Hi David,

Thanks again for the input. I havent quite figured it out yet but I
appreciate the help!

Best,
Marc

On Thu, Nov 5, 2020 at 8:02 AM David Nugent  wrote:

>
>
> On 5 Nov 2020, at 04:11, Marc Johnson  wrote:
>
> Hi David,
>
> Thanks again for the feedback. When I remove the 'ENGINE' variable I get
> the error saying settings.DATABASES is improperly configured, as shown in
> the snapshot attached below.
>
> But when I add the ENGINE variable, like listed below, I get an 'Internal
> Server Error':
>
> DATABASES = {
> 'default': dj_database_url.config(env='DATABASE_URL',
> conn_max_age=1800),
> 'ENGINE': 'django.db.backends.postgresql',
> }
>
> My db settings in my docker-compose.yml file are also provided below:
>
>   db:
> image: postgres:11
> volumes:
>   - postgres_data:/var/lib/postgresql/data/
> environment:
>   - "DATABASE_URL=
> postgresql://postgres:P#ssw0rd@postgres:5432/ndc_data"
>   - "POSTGRES_HOST_AUTH_METHOD=trust"
>   - "POSTGRES_PASSWORD=P#ssw0rd"
>   - "POSTGRES_USER=postgres"
>   - "POSTGRES_DB=ndc_data"
>   - "POSTGRES_HOST=postgres"
> networks:
>   - default
>
> How am I screwing this up so royally!? I did not expect this connection to
> involve so much troubleshooting.
>
>
>
> It shouldn't. Note that env='DATABASE_URL' is entirely redundant and can
> be omitted.
>
> In any case, check the source code for dj_database_url.config to
> troubleshoot this, but ENGINE definitely isn't needed here. As you'll see
> from the source, the url scheme determines the engine used.
>
> Did you validate that DATABASE_URL is set correctly in the container
> environment?
> I suspect this may be the issue here, although the docker-compose.yml
> looks fine.
>
> Regards,
> /d
>
>
>

-- 
M: +1-646-541-2108
W: marcjohnson.info <https://www.marcjohnson.info/>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACH3BCSBvDA3k74kn0XLv%3DeD%3DmqrSX16jTHPxTLRVCqH8Jk4Yg%40mail.gmail.com.


Re: Newbie looking for some help with Postgres <> Django connection

2020-11-03 Thread Marc Johnson
Hi David,

Thanks for the feedback!

I'm checking out dj_database_url and have a few follow up questions I was
hoping you (or someone) could help me with.

1. Since this app is dockerized, I have my existing env vars in my
docker-compose-prod.yml file. Is that where I should list DATABASE_URL?
Like:






*db:image: postgres:11volumes:  -
postgres_data:/var/lib/postgresql/data/environment:-
DATABASE_URL=postgresql://:@:/
- *2. Does the below formatting look correct to you from my settings.py? I
am running into issues with the env var DATABASE_URL and getting this
error:  Environment variable "{}" not set'





*DATABASES = {'default': dj_database_url.config(env("DATABASE_URL"),
default="postgres://postgres@db/postgres", conn_max_age=1800),'ENGINE':
'django.db.backends.postgresql',}*
3. I am also getting this error when running locally. Do you have any
advice for troubleshooting?

web_1  | [2020-11-03 16:35:59 +] [7] [ERROR] Error handling request
/NDCs/

web_1  | Traceback (most recent call last):

web_1  |   File
"/usr/local/lib/python3.8/site-packages/gunicorn/workers/sync.py", line
134, in handle

web_1  | self.handle_request(listener, req, client, addr)

web_1  |   File
"/usr/local/lib/python3.8/site-packages/gunicorn/workers/sync.py", line
175, in handle_request

web_1  | respiter = self.wsgi(environ, resp.start_response)

web_1  |   File
"/usr/local/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line
131, in __call__

web_1  | signals.request_started.send(sender=self.__class__,
environ=environ)

web_1  |   File
"/usr/local/lib/python3.8/site-packages/django/dispatch/dispatcher.py",
line 177, in send

web_1  | return [

web_1  |   File
"/usr/local/lib/python3.8/site-packages/django/dispatch/dispatcher.py",
line 178, in 

web_1  | (receiver, receiver(signal=self, sender=sender, **named))

web_1  |   File
"/usr/local/lib/python3.8/site-packages/django/db/__init__.py", line 46, in
reset_queries

web_1  | for conn in connections.all():

web_1  |   File
"/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 229, in
all

web_1  | return [self[alias] for alias in self]

web_1  |   File
"/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 229, in


web_1  | return [self[alias] for alias in self]

web_1  |   File
"/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 211, in
__getitem__

web_1  | self.ensure_defaults(alias)

web_1  |   File
"/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 176, in
ensure_defaults

web_1  | conn.setdefault('ATOMIC_REQUESTS', False)

web_1  | AttributeError: 'str' object has no attribute 'setdefault'

Many thanks in advance for any insights.

Best,
Marc

On Sat, Oct 31, 2020 at 11:45 PM David Nugent  wrote:

> It's been a while since I used heroku, but iirc it just uses a formatted
> pg url.
>
> Install the module dj-database-url and use this in settings instead of the
> default DATABASES layout, something like:
>
>
> DATABASES = {
> 'default':
> dj_database_url.config(os.environ['DATABASE_URL'], conn_max_age=1800)
> }
>
>
> Then set DATABASE_URL in the heroku (and your development) environment.
> This setting will be of the form:
>
> DATABASE_URL=postgresql://:@:/
>
>
> Again, its been a while but I also seem to recall that the DATABASE_URL is
> provided to your app automagically(?) a part of the provisioning so does
> not need to be explicitly set there.  Using the dj_database_url module in
> your settings above is the key.
>
>
>
>

-- 
M: +1-646-541-2108
W: marcjohnson.info <https://www.marcjohnson.info/>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACH3BCQi2f7uybMPb%3DXXmLuczNwX3%2Bi-enyS-4Lmk_%2Ba7etYbw%40mail.gmail.com.


Newbie looking for some help with Postgres <> Django connection

2020-10-31 Thread Marc Johnson
Hi All,

I'm looking for tips/resources for a problem I'm facing with my Django app: 
https://ndcportal.herokuapp.com/ 

I'm attempting to connect my Dockerized Django app with a PostgreSQL db. 
The postgres db is already populated, and I can access the data via 
pgadmin, but I cannot figure out the appropriate settings in my 
docker-compose.yml & settings.py files to make the postgres db populate my 
django app. 

I've reviewed multiple tutorials/blog posts, including Will Vincents Docker 
& PostgreSQL tutorial 
<https://learndjango.com/tutorials/django-docker-and-postgresql-tutorial>, 
but I feel like I'm missing one or two final & crucial steps. 

When I change my DB settings for Postgres, & I bring up the app via Docker, 
I continue running into this OperationalError: 



*message:django.db.utils.OperationalError: could not connect to server: 
Connection refused Is the server running on host "db" (172.29.0.2) and 
accepting TCP/IP connections on port 5433?*

Any tips/resources/feedback would be greatly appreciated. Thanks in advance.

Best,
Marc

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5b11f9df-d246-4b25-b9b6-8a67193f413en%40googlegroups.com.


Re: Django MySQL database backup and restore to new server

2020-05-05 Thread marc bellazzini
SOLVED

# after more extensive googling .

ORIGINAL SERVER
- cd to your web project directory
- python manage.py dumpdata > db.json

NEW SERVER
- sftp db.json file to new server web project directory
- python manage.py migrate
- python manage.py shell
-- >> from django.contrib.contenttypes.models import ContentType
-- >> ContentType.objects.all().delete()
-- >> quit()
- sftp db.json file to new server web project directory
- python manage.py loaddata db.json


On Monday, May 4, 2020 at 4:53:29 PM UTC-5, marc bellazzini wrote:
>
> Hello, 
>
> I have Django 2.x running on an old Ubuntu server with a MySQL database. I 
> have installed a new Ubuntu 20.04 server on another machine with Django 3.x 
> and MySQL. I would like to backup the old Django/mysql database and restore 
> it on the new server. What is the best practice for doing this? 
>
> Thanks
>
> Marc
>  
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e7d52ea3-e82d-4813-a70d-ca31e90343c1%40googlegroups.com.


Re: Django MySQL database backup and restore to new server

2020-05-05 Thread marc bellazzini
SOLVED

# after more extensive googling I found a solution myself. I hope this 
helps someone else

ORIGINAL SERVER
- cd to your web project directory 
- python manage.py dumpdata > db.json
- python manage.py migrate
- python manage.py shell 
-- >> from django.contrib.contenttypes.models import ContentType
-- >> ContentType.objects.all().delete()
-- >> quit()

NEW SERVER
- sftp db.json file to new server web project directory
- python manage.py loaddata db.json


On Monday, May 4, 2020 at 4:53:29 PM UTC-5, marc bellazzini wrote:
>
> Hello, 
>
> I have Django 2.x running on an old Ubuntu server with a MySQL database. I 
> have installed a new Ubuntu 20.04 server on another machine with Django 3.x 
> and MySQL. I would like to backup the old Django/mysql database and restore 
> it on the new server. What is the best practice for doing this? 
>
> Thanks
>
> Marc
>  
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fad24ded-8316-4f71-9a30-7cb10907f956%40googlegroups.com.


Django MySQL database backup and restore to new server

2020-05-04 Thread marc bellazzini
Hello, 

I have Django 2.x running on an old Ubuntu server with a MySQL database. I 
have installed a new Ubuntu 20.04 server on another machine with Django 3.x 
and MySQL. I would like to backup the old Django/mysql database and restore 
it on the new server. What is the best practice for doing this? 

Thanks

Marc
 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d02ce001-cf6c-4cc9-811b-d9d72946c296%40googlegroups.com.


wss (secure websocket) with Django Channels and Daphne webserver

2020-01-19 Thread Marc Mültin
Hello there, 

Who is fit in Django Channels and TLS handshakes? I am really stuck with 
configuring an SSL Context for the TLS server for secure websockets, which 
I thought is enabled through Django Channels. 

I posted my question on Stackoverflow: 
https://stackoverflow.com/questions/58881264/wss-secure-websocket-with-django-channels-and-daphne-webserver
If you can help me out or point me to someone who can, I'd appreciate the 
help very much. 

Best, 
Marc

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bee8aa9a-790f-4ab3-95ab-21639e240384%40googlegroups.com.


Re: Dynamic creation of models

2018-02-06 Thread Marc
This is an interesting article against document databases, I am sure though 
that there are equally valid arguments for
http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/

On Tuesday, February 6, 2018 at 1:14:41 PM UTC, Marc wrote:
>
> Thank you Jani, for taking the time to respond. We are currently at the 
> design stage so are considering all options. We have used document 
> databases (MongoDB) for other projects and in those cases it turned out to 
> not be good fit. I agree that at first glance a document database does 
> feels like a good fit, but I want to explore all options. The organisation 
> is asking for quite ambitious requirements (moon on a stick), they are 
> going to have to make compromises I am sure. A good compromise does seem to 
> be the JOSN column data type in both PostgreSQL and MySQL, I believe that 
> both Ruby on Rails and Django have support
>
> On Tuesday, February 6, 2018 at 12:14:59 PM UTC, Jani Tiainen wrote:
>>
>> Hi,
>> Since you're uploading more like documents than similary structured data, 
>> why not to use more proper tool, like document database (ArangoDB would get 
>> my vote) instead of trying to do what Django is not designed for and 
>> doesn't support well with concepts like "dynamic models".
>>
>> We do similar thing with certain uploadable reports and it works pretty 
>> fine.
>>
>> On 6.2.2018 13.35, Marc wrote:
>>
>> Hello
>>
>>  
>>
>> Currently working on a project to allow researchers to upload data files 
>> into a repository. The system will only handle the import, validation and 
>> transformation of the data, so that it meets the required standards. When a 
>> file is upload the for the first time the user has to be able to define the 
>> structure of the destination based on the csv/xls. This includes key field, 
>> data types, foreign keys etc. There is no requirement for the data to be 
>> displayed or edited once in the repository by this system, currently. We 
>> are currently planning on using PostgreSQL as the database.
>>
>>  
>>
>> Our organisation already has another system, with a similar requirement, 
>> that is partially written by an external contractor in Ruby on Rails. The 
>> dynamic creation of the tables is no problem but it is the dynamic creation 
>> of the models and controllers that is proving difficult and is the reason 
>> why this other project is not finished. 
>>
>>  
>>
>> Reading through the forums it looks like Django may offer a better 
>> solution through meta-programming. 
>> https://code.djangoproject.com/wiki/DynamicModels This does look like 
>> quite an old article though. 
>>
>>  
>>
>> The other solution would be to have one table that holds all the records 
>> for all the imported files and have a JSONB (in PostgreSQL) to hold the 
>> columns that differ between files. This means that we would not be able to 
>> represent the relationships between files though. Ideally the organisation 
>> would like the data in a relational form to make subsequent analysis with 
>> other tools easier.
>>
>>  
>>
>> Above all it is important that the system is robust and maintainable. Any 
>> solution will of course be tested by creating a proof of concept first.
>>
>>  
>>
>> Is it still possible to dynamically create the models in the latest 
>> versions of Django (1.11 and 2.02)? 
>>
>>  
>>
>> Thank you
>>
>> Marc
>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/d707e803-3dbf-43e6-95a8-13869043c280%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/d707e803-3dbf-43e6-95a8-13869043c280%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> -- 
>> Jani Tiainen
>>
>>

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


Re: Dynamic creation of models

2018-02-06 Thread Marc
Thank you Jani, for taking the time to respond. We are currently at the 
design stage so are considering all options. We have used document 
databases (MongoDB) for other projects and in those cases it turned out to 
not be good fit. I agree that at first glance a document database does 
feels like a good fit, but I want to explore all options. The organisation 
is asking for quite ambitious requirements (moon on a stick), they are 
going to have to make compromises I am sure. A good compromise does seem to 
be the JOSN column data type in both PostgreSQL and MySQL, I believe that 
both Ruby on Rails and Django have support

On Tuesday, February 6, 2018 at 12:14:59 PM UTC, Jani Tiainen wrote:
>
> Hi,
> Since you're uploading more like documents than similary structured data, 
> why not to use more proper tool, like document database (ArangoDB would get 
> my vote) instead of trying to do what Django is not designed for and 
> doesn't support well with concepts like "dynamic models".
>
> We do similar thing with certain uploadable reports and it works pretty 
> fine.
>
> On 6.2.2018 13.35, Marc wrote:
>
> Hello
>
>  
>
> Currently working on a project to allow researchers to upload data files 
> into a repository. The system will only handle the import, validation and 
> transformation of the data, so that it meets the required standards. When a 
> file is upload the for the first time the user has to be able to define the 
> structure of the destination based on the csv/xls. This includes key field, 
> data types, foreign keys etc. There is no requirement for the data to be 
> displayed or edited once in the repository by this system, currently. We 
> are currently planning on using PostgreSQL as the database.
>
>  
>
> Our organisation already has another system, with a similar requirement, 
> that is partially written by an external contractor in Ruby on Rails. The 
> dynamic creation of the tables is no problem but it is the dynamic creation 
> of the models and controllers that is proving difficult and is the reason 
> why this other project is not finished. 
>
>  
>
> Reading through the forums it looks like Django may offer a better 
> solution through meta-programming. 
> https://code.djangoproject.com/wiki/DynamicModels This does look like 
> quite an old article though. 
>
>  
>
> The other solution would be to have one table that holds all the records 
> for all the imported files and have a JSONB (in PostgreSQL) to hold the 
> columns that differ between files. This means that we would not be able to 
> represent the relationships between files though. Ideally the organisation 
> would like the data in a relational form to make subsequent analysis with 
> other tools easier.
>
>  
>
> Above all it is important that the system is robust and maintainable. Any 
> solution will of course be tested by creating a proof of concept first.
>
>  
>
> Is it still possible to dynamically create the models in the latest 
> versions of Django (1.11 and 2.02)? 
>
>  
>
> Thank you
>
> Marc
> -- 
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/d707e803-3dbf-43e6-95a8-13869043c280%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/d707e803-3dbf-43e6-95a8-13869043c280%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> -- 
> Jani Tiainen
>
>

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


Dynamic creation of models

2018-02-06 Thread Marc
 

Hello

 

Currently working on a project to allow researchers to upload data files 
into a repository. The system will only handle the import, validation and 
transformation of the data, so that it meets the required standards. When a 
file is upload the for the first time the user has to be able to define the 
structure of the destination based on the csv/xls. This includes key field, 
data types, foreign keys etc. There is no requirement for the data to be 
displayed or edited once in the repository by this system, currently. We 
are currently planning on using PostgreSQL as the database.

 

Our organisation already has another system, with a similar requirement, 
that is partially written by an external contractor in Ruby on Rails. The 
dynamic creation of the tables is no problem but it is the dynamic creation 
of the models and controllers that is proving difficult and is the reason 
why this other project is not finished. 

 

Reading through the forums it looks like Django may offer a better solution 
through meta-programming. https://code.djangoproject.com/wiki/DynamicModels 
This does look like quite an old article though. 

 

The other solution would be to have one table that holds all the records 
for all the imported files and have a JSONB (in PostgreSQL) to hold the 
columns that differ between files. This means that we would not be able to 
represent the relationships between files though. Ideally the organisation 
would like the data in a relational form to make subsequent analysis with 
other tools easier.

 

Above all it is important that the system is robust and maintainable. Any 
solution will of course be tested by creating a proof of concept first.

 

Is it still possible to dynamically create the models in the latest 
versions of Django (1.11 and 2.02)? 

 

Thank you

Marc

-- 
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/d707e803-3dbf-43e6-95a8-13869043c280%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ModelAdmin Media JS file order issue in Django 2.0

2017-12-10 Thread Marc R
because they are specific to only a few models, particularly the loading 
scripts, and options, etc.  this worked great in Django 1.11

On Sunday, 10 December 2017 09:36:56 UTC-5, Etienne Robillard wrote:
>
> Why don't you simply put the javascripts into your base template without 
> using Python ? 
>
> Etienne
>
> Le 2017-12-10 à 09:30, Marc R a écrit :
>
> I have this in my model: 
>
> class Media:
> js = (
>* '/static/plugins/codemirror/lib/codemirror.js',*
> '/static/plugins/codemirror/mode/htmlmixed/htmlmixed.js',
> '/static/plugins/codemirror/addon/fold/foldcode.js',
> '/static/plugins/codemirror/addon/fold/foldgutter.js',
> '/static/plugins/codemirror/addon/fold/brace-fold.js',
> '/static/plugins/codemirror/addon/fold/indent-fold.js',
> '/static/plugins/codemirror/addon/fold/comment-fold.js',
> '/static/plugins/codemirror/addon/fold/xml-fold.js',
> '/static/plugins/codemirror/addon/comment/comment.js',
> '/static/plugins/codemirror/addon/edit/matchbrackets.js',
> '/static/plugins/codemirror/addon/edit/matchtags.js',
> '/static/plugins/codemirror/mode/javascript/javascript.js',
> '/static/plugins/codemirror/mode/xml/xml.js',
> '/static/plugins/codemirror/mode/htmlmixed/htmlmixed.js',
> '/static/plugins/codemirror/addon/display/fullscreen.js',
> '/static/js/admin/syslog/syslog_change_form.min.js'
> )
>
> which used to work as it was included in the model admin page in the order 
> it appears. However, now in Django 2.0, it appears in this order:
>  src="/static/plugins/codemirror/addon/fold/foldcode.js">
>  src="/static/plugins/codemirror/addon/fold/foldgutter.js">
>  src="/static/plugins/codemirror/addon/fold/brace-fold.js">
>  src="/static/plugins/codemirror/addon/fold/indent-fold.js">
>  src="/static/plugins/codemirror/addon/fold/comment-fold.js">
>  src="/static/plugins/codemirror/addon/fold/xml-fold.js">
>  src="/static/plugins/codemirror/addon/comment/comment.js">
>  src="/static/plugins/codemirror/addon/edit/matchbrackets.js">
>  src="/static/plugins/codemirror/addon/edit/matchtags.js">
>  src="/static/plugins/codemirror/mode/javascript/javascript.js">
>  src="/static/plugins/codemirror/mode/xml/xml.js">
> * src="/static/plugins/codemirror/lib/codemirror.js">*
>  src="/static/plugins/codemirror/mode/htmlmixed/htmlmixed.js">
>  src="/static/plugins/codemirror/addon/display/fullscreen.js">
>  src="/static/js/admin/syslog/syslog_change_form.min.js">
>
> The issue is that the First file MUST be first as the remainder rely upon 
> it!  I'd rather not override a template file as if i change the admin 
> backend with a package i'd like this to "just work" as it did in Django 1.11
> Is this a bug in the new way that Django includes these files (docs say 
> they made a change in how this is done, clearly it broke something that 
> worked!).
>
> 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...@googlegroups.com .
> To post to this group, send email to django...@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/5ad93160-05c2-4251-84ad-6f8a1574b675%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/5ad93160-05c2-4251-84ad-6f8a1574b675%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> -- 
> Etienne robillardtka...@yandex.com 
> https://www.isotopesoftware.ca/
>
>

-- 
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/8493b435-1574-4187-88f6-7f45f5dbaba6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ModelAdmin Media JS file order issue in Django 2.0

2017-12-10 Thread Marc R
I have this in my model:

class Media:
js = (
   * '/static/plugins/codemirror/lib/codemirror.js',*
'/static/plugins/codemirror/mode/htmlmixed/htmlmixed.js',
'/static/plugins/codemirror/addon/fold/foldcode.js',
'/static/plugins/codemirror/addon/fold/foldgutter.js',
'/static/plugins/codemirror/addon/fold/brace-fold.js',
'/static/plugins/codemirror/addon/fold/indent-fold.js',
'/static/plugins/codemirror/addon/fold/comment-fold.js',
'/static/plugins/codemirror/addon/fold/xml-fold.js',
'/static/plugins/codemirror/addon/comment/comment.js',
'/static/plugins/codemirror/addon/edit/matchbrackets.js',
'/static/plugins/codemirror/addon/edit/matchtags.js',
'/static/plugins/codemirror/mode/javascript/javascript.js',
'/static/plugins/codemirror/mode/xml/xml.js',
'/static/plugins/codemirror/mode/htmlmixed/htmlmixed.js',
'/static/plugins/codemirror/addon/display/fullscreen.js',
'/static/js/admin/syslog/syslog_change_form.min.js'
)

which used to work as it was included in the model admin page in the order 
it appears. However, now in Django 2.0, it appears in this order:











**




The issue is that the First file MUST be first as the remainder rely upon 
it!  I'd rather not override a template file as if i change the admin 
backend with a package i'd like this to "just work" as it did in Django 1.11
Is this a bug in the new way that Django includes these files (docs say 
they made a change in how this is done, clearly it broke something that 
worked!).

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5ad93160-05c2-4251-84ad-6f8a1574b675%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Does imports of related models affect cascade deletion?

2015-07-30 Thread Marc Aymerich
On Thu, Jul 30, 2015 at 3:38 PM, Markus Amalthea Magnuson
<markus.magnu...@gmail.com> wrote:
> Hey,
>
> I stumbled upon a piece of code and a comment that says this:
>
> Deleting a model object that has related objects will only cascade delete
> those objects if their models have been imported.
>
> Is this true? I have not found it in the documentation and would like to add
> a reference to the code comment so others won't be as confused as I am.

Is this models module called models.py and does it live inside a
Django application listed in INSTALLED_APPS?


-- 
Marc

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


Annotations with nested Sums

2015-07-10 Thread Marc Aymerich
Hi,
I need to do some annotations that require a nested sumation,
I have Bills that have Lines that in turn have Sublines: Bill -> Line -> SubLine
In order to calculate the total bill price I need to add all sublines
of every line, and then all lines of a bill.

queryset.annotate(
total=Sum(F('lines__total') + Sum(F('lines__sublines__total')))
)

But I get an AttributeError: 'CombinedExpression' object has no attribute 'name'

Is there any other way to perform this calculation (adding two levels
of nested totals)?.


thanks!
-- 
Marc

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


Re: What is the ideal web server to use with Django?

2015-05-15 Thread Marc Aymerich
On Fri, May 15, 2015 at 10:33 AM, Tom Evans <tevans...@googlemail.com> wrote:
> On Thu, May 14, 2015 at 4:18 PM, Marc Aymerich <glicer...@gmail.com> wrote:
>> On Thu, May 14, 2015 at 11:26 AM, Tom Evans <tevans...@googlemail.com> wrote:
>>> On our app servers we typically use Apache with worker MPM and
>>> mod_wsgi, although we have a few nginx+uwsgi sites, and I would dearly
>>> love some time to play around with a circusd + chausette + celery
>>> setup.
>>
>>
>> Hi Tom,
>> never heard about circusd and chaussette, but it sounds interesting.
>>
>> I believe the advantage of this setup pays when you have several
>> independent low-traffic applications, because you don't want all of
>> them to have preforked wsgi worker processes, not even the master
>> process. I think uwsgi can do that (emperor mode, cheaper subsystem),
>> but circusd will allow you to do the same which celery (celery needs
>> at least one master per pool). Is this the main point? I'm asking
>> because I can only find just a couple of blogposts and the
>> documentation is concise, neither mention the real tangible advantage
>> over traditional deployments.
>>
>
> There are few very cool things I like about circusd + chaussette,
> chausette allows you to run over a unix socket, and this allows
> circusd to easily spin up a new backend (with different code) and
> transfer requests to that unix socket, whilst leaving the old backend
> still running.
>
> This means zero downtime when doing a code upgrade, and instant
> failback to the old application if for some reason you don't like what
> was pushed.
>
> The second thing is that circusd is a process manager like
> supervisord, but it allows for dynamic operation - you can run celery
> worker processes underneath it, and spin up/spin down worker processes
> as you see fit to allow for load.
>
> The third is that circusd is accessed by a web interface, which allows
> for simple day to day use and also simplifies how admins and sysadmins
> can interact with it. Its very easy for our sysadmins to control
> things they can just fire http requests at.
>

thanks Tom, that is really cool, I really appreciated your comments on this!


-- 
Marc

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


Re: What is the ideal web server to use with Django?

2015-05-14 Thread Marc Aymerich
On Thu, May 14, 2015 at 11:26 AM, Tom Evans <tevans...@googlemail.com> wrote:
>
> On Thu, May 14, 2015 at 4:36 AM, reduxionist <jonathan.barr...@gmail.com> 
> wrote:
> > The question you asked Tom was "Doesn't Apache create new process for each
> > request [thus eating memory when serving large amounts of static files
> > during traffic peaks]?", and the reason that Tom correctly answers "No" is
> > that as far as "serving large amounts of static files" goes you should be
> > using mpm-worker (multi-threaded Apache) which most definitely does not
> > spawn a new process for each request.
> >
> > The reason for those search results is that mpm-prefork does, however, spawn
> > a process per request,
>
> No, really, it does not. It only spawns a new process when there are
> no available workers to process an incoming request, and you have not
> reached the maximum number of workers that you have configured it to
> start. You can configure it to start all the worker processes you want
> when it starts up, and never to kill them off, and it will never spawn
> a new process.
>
> Apache processes are small, unless you do daft things like embed your
> web application in each worker process (mod_php style). This is the
> main complaint "Apache is eating all my memory" - it isn't, your web
> application you've embedded into Apache is eating all your memory.
>
> All of this is irrelevant for django, because with Apache you should
> use mod_wsgi in daemon mode, which separates out your web application
> processes from the web server.
>
> > but it is only needed for non-thread-safe
> > environments (most notoriously mod_php) and you shouldn't have to use it as
> > long as you've been a good coder and avoided global state in your Django app
> > (e.g. keep request-specific shared-state thread-local).
> >
> > I think the reason a lot of people seem to run mpm-prefork is just that it's
> > the default multi-processing module for Apache on most (all?) *nix platforms
> > and they don't know any better.
>
> Quite. We run a pair of Apache 2.4 reverse proxies in front of all of
> our (400+) domains, serving around 40 million requests per day,
> providing SSL termination and static file serving. We use event MPM
> and we have it scaled to support a peak of 2048 simultaneous
> connections. Load on the server never goes above 0.2, memory usage
> never goes above 1GB for the entire OS + applications, the rest of the
> RAM is used by the OS to cache the aforementioned static files.
>
> On our app servers we typically use Apache with worker MPM and
> mod_wsgi, although we have a few nginx+uwsgi sites, and I would dearly
> love some time to play around with a circusd + chausette + celery
> setup.


Hi Tom,
never heard about circusd and chaussette, but it sounds interesting.

I believe the advantage of this setup pays when you have several
independent low-traffic applications, because you don't want all of
them to have preforked wsgi worker processes, not even the master
process. I think uwsgi can do that (emperor mode, cheaper subsystem),
but circusd will allow you to do the same which celery (celery needs
at least one master per pool). Is this the main point? I'm asking
because I can only find just a couple of blogposts and the
documentation is concise, neither mention the real tangible advantage
over traditional deployments.


>
> The choice of web server is, these days, irrelevant. If it uses too
> much memory or can't handle enough users, it is never the fault of the
> web server, but instead of your application and/or configuration.
> Which is why I return to my original advice:
>
> > I am new to Django. I am building a app which will have to handle several
> > concurrent requests. Which web server is suitable for this?
>
> Any and all.
>
> Leave the fanboyism to the phone guys.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAFHbX1KEVRM6WU7OCcLRSkJhpMS%2BfHpd7%2BWo7LO8XcEt8_f0Nw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.




-- 
Marc

-- 
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 

Re: Ensure an object is saved even when the atomic bock rollsback

2015-05-08 Thread Marc Aymerich
On Fri, May 8, 2015 at 6:43 PM, Marc Aymerich <glicer...@gmail.com> wrote:

>
>
> On Fri, May 8, 2015 at 5:50 PM, Carl Meyer <c...@oddbird.net> wrote:
>
>> Hi Marc,
>>
>> On 05/08/2015 07:15 AM, Marc Aymerich wrote:
>> > I'm using atomic requests, but one of my views needs to save a model
>> > regardless of wheter the current transaction rolls back or not.
>> >
>> > I'm confused about how to proceed with the current autocommit behaviour.
>> > Do I need to use a different db connection? or perhaps there is some way
>> > of telling django to ignore autocommit for some particular block ?
>>
>> You'd need to use a different db connection, since what you're trying to
>> do violates the very nature of a database transaction. If you were just
>> trying to run some raw SQL, you could establish the separate connection
>> yourself manually, but if you're trying to save a Django model, you'll
>> probably need a second connection defined in your DATABASES setting.
>>
>> Possible alternatives:
>>
>> - If you're using a task queuing system (like Celery or rq), queue a
>> task to perform the save; you can do this without making it conditional
>> on the transaction committing, as long as your task queue is using a
>> store other than your primary database (e.g. Redis or RabbitMQ). Usually
>> when people do this it's unintentional and a bug (they really wanted the
>> task to execute only if the current transaction committed), but in your
>> case it could be a feature.
>>
>
> Yep, the thing is that I need to have this instance saved before handling
> it to a worker process, the worker process uses it and if something goes
> wrong on the main thread then the worker has an object that does not exists
> on the database. Now I realize that I can just catch the IntegrityError and
> re-save the object on the worker thread ;)
>
> obj.pk = None
> obj.save()
>

unfortunately this will not work in my case, because I need the object.id
to not change :(


> - Switch from ATOMIC_REQUESTS to explicit use of transaction.atomic() in
>> your views, so that you can place this "no matter what" save in its own
>> transaction.
>
>
> I've been doing something on those lines, but now I have this corner case
> which I have surouding code that needs to be wrapped up in a transaction :(
>
> For the record, after exploring django.db I realize of 2 more alternative
> ways of dealing with this situation:
>
> 1) because the connection pool is a local thread object, you can just
> fireup a separate thread, so it will have fresh connections :)
>
> t = threading.Thread(target=backend.create_log, args=args)
> t.start()
> log = t.join()
>
> 2) because a new connection is created for each settings.DATABASES, it is
> easy to have new connections with a fake database. I've also created a
> context manager for that
>


So my best option so far is to make that query on a separate connection,
and between worker threads (preferable than celery in this case) and moking
the database settings... the later is hacky but much faster :)

>>> from threading import Thread
>>> from django import db
>>> from django.conf import settings as djsettings
>>> class fresh_connection(object):
... def __init__(self, origin, target):
... self.origin = origin
... self.target = target
...
... def __enter__(self):
... djsettings.DATABASES[self.target] =
djsettings.DATABASES[self.origin]
... # Because db.connections.datases is a cached property
... self.old_connections = db.connections
... db.connections = db.utils.ConnectionHandler()
...
... def __exit__(self, type, value, traceback):
... db.connections[self.target].close()
... djsettings.DATABASES.pop(self.target)
... db.connections = self.old_connections
...
>>> def do_query(using='default'):
... Account.objects.using(using).get(pk=1)
...
>>> from datetime import datetime
>>> now = datetime.now()
>>> for i in range(1, 100):
... t = Thread(target=do_query)
... t.start()
... t.join()
...
>>> print((datetime.now()-now).total_seconds())
1.449795
>>>
>>> now = datetime.now()
>>> for i in range(1, 100):
... with fresh_connection('default', 'other_default'):
... do_query(using='other_default')
...
>>> print((datetime.now()-now).total_seconds())
0.106981



-- 
Marc

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


Re: Ensure an object is saved even when the atomic bock rollsback

2015-05-08 Thread Marc Aymerich
On Fri, May 8, 2015 at 5:50 PM, Carl Meyer <c...@oddbird.net> wrote:

> Hi Marc,
>
> On 05/08/2015 07:15 AM, Marc Aymerich wrote:
> > I'm using atomic requests, but one of my views needs to save a model
> > regardless of wheter the current transaction rolls back or not.
> >
> > I'm confused about how to proceed with the current autocommit behaviour.
> > Do I need to use a different db connection? or perhaps there is some way
> > of telling django to ignore autocommit for some particular block ?
>
> You'd need to use a different db connection, since what you're trying to
> do violates the very nature of a database transaction. If you were just
> trying to run some raw SQL, you could establish the separate connection
> yourself manually, but if you're trying to save a Django model, you'll
> probably need a second connection defined in your DATABASES setting.
>
> Possible alternatives:
>
> - If you're using a task queuing system (like Celery or rq), queue a
> task to perform the save; you can do this without making it conditional
> on the transaction committing, as long as your task queue is using a
> store other than your primary database (e.g. Redis or RabbitMQ). Usually
> when people do this it's unintentional and a bug (they really wanted the
> task to execute only if the current transaction committed), but in your
> case it could be a feature.
>

Yep, the thing is that I need to have this instance saved before handling
it to a worker process, the worker process uses it and if something goes
wrong on the main thread then the worker has an object that does not exists
on the database. Now I realize that I can just catch the IntegrityError and
re-save the object on the worker thread ;)

obj.pk = None
obj.save()


- Switch from ATOMIC_REQUESTS to explicit use of transaction.atomic() in
> your views, so that you can place this "no matter what" save in its own
> transaction.


I've been doing something on those lines, but now I have this corner case
which I have surouding code that needs to be wrapped up in a transaction :(

For the record, after exploring django.db I realize of 2 more alternative
ways of dealing with this situation:

1) because the connection pool is a local thread object, you can just
fireup a separate thread, so it will have fresh connections :)

t = threading.Thread(target=backend.create_log, args=args)
t.start()
log = t.join()

2) because a new connection is created for each settings.DATABASES, it is
easy to have new connections with a fake database. I've also created a
context manager for that

from django import db
from django.conf import settings as djsettings

class fresh_connection(object):
def __init__(self, origin, target):
self.origin = origin
self.target = target

def __enter__(self):
djsettings.DATABASES[self.target] =
djsettings.DATABASES[self.origin]
# Because db.connections.datases is a cached property
db.connections = db.utils.ConnectionHandler()

def __exit__(self, type, value, traceback):
db.connections[self.target].close()
djsettings.DATABASES.pop(self.target)


with fresh_connection('default', 'other_default'):
log = backend.create_log(*args, using='other_default')
log._state.db = 'default'


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



-- 
Marc

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


Ensure an object is saved even when the atomic bock rollsback

2015-05-08 Thread Marc Aymerich
HI,

I'm using atomic requests, but one of my views needs to save a model
regardless of wheter the current transaction rolls back or not.

I'm confused about how to proceed with the current autocommit behaviour. Do
I need to use a different db connection? or perhaps there is some way of
telling django to ignore autocommit for some particular block ?

Thanks!
-- 
Marc

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


Re: Django, JavaScript, Python, HTML : Print on html a variable running on python file

2015-04-20 Thread Marc Patermann

Beatrice,

Beatrice Galvani schrieb (16.04.2015 17:34 Uhr):

Hi, I'm using Django 1.7.2, Python 3.4.

My trouble is: I have a simple function in some directory written in 
python (e.g. a counter since 0 to 10); I would like to see these numbers 
on my monitor on the HTML page.. I know how start the function but I am 
not able to print the variables!  

My formatted question is *HERE on Stack Overflow 
<http://stackoverflow.com/questions/29624611/django-javascript-co-print-on-html-a-variable-running-on-python-file>.*


I hope someone can help me , I do not know how to proceed.

noramlly you have a template for an URL.
The template is generated by a view.
Views are python functions.
- You should call your python function from a view, the function must
  return your variable to the view function.
- The view should return your variable to the template.
- The template should be able to display your variable.


Marc

--
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/5534B816.3050507%40ofd-z.niedersachsen.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ANNOUNCE] Django 1.8 released

2015-04-03 Thread Marc Aymerich
On Wed, Apr 1, 2015 at 10:46 PM, Tim Graham <timogra...@gmail.com> wrote:

> Django 1.8, the next long-term support release, is now available:
>
> https://www.djangoproject.com/weblog/2015/apr/01/release-18-final/
>
> With the release of Django 1.8, Django 1.6 has reached end-of-life. As
> such, Django 1.6.11 is the final release of the 1.6 series. Django 1.7 will
> continue to receive security updates until the release of Django 1.9 (planned
> for October 2015 <https://code.djangoproject.com/wiki/Version1.9Roadmap>).
> Django 1.4 (the previous LTS) will receive security updates for another six
> months (ending October 1, 2015) to give time for users to upgrade to Django
> 1.8 LTS
>


Outstanding work guys !!
just upgraded my +40 apps project to 1.8 and everything went really
smoothly :)

-- 
Marc

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


Re: Running middleware within ATOMIC_REQUESTS transaction

2015-03-12 Thread Marc Aymerich
On Tue, Mar 10, 2015 at 5:38 PM, Marc Aymerich <glicer...@gmail.com> wrote:

>
>
> On Tue, Mar 10, 2015 at 5:15 PM, Marc Aymerich <glicer...@gmail.com>
> wrote:
>
>>
>>
>> On Tue, Mar 10, 2015 at 5:12 PM, Marc Aymerich <glicer...@gmail.com>
>> wrote:
>>
>>> Hi,
>>> I have a middleware that performs some operations at the end of each
>>> request.
>>>
>>> What I have found is that middlewares do not run inside the
>>> ATOMIC_REQUESTS transaction. But I want the ATOMIC_REQUESTS transaction to
>>> rollback if an exception is being raised on my middleware.
>>>
>>> Any idea on how to solve this?
>>>
>>
>> Well, I supose I can grab the TransactionMiddleware from the previous
>> release and use that instead of ATOMIC_REQUESTS :)
>>
>>
>> https://github.com/django/django/blob/stable/1.7.x/django/middleware/transaction.py
>>
>
>
> Not that easy, it seems that now all transactions are aborted by the
> middleware :( I'll keep looking
>

Stupid mistake, I was loading the wrong module xDD,

it works like a charm, sorry for all this noise ;)

-- 
Marc

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


Re: Running middleware within ATOMIC_REQUESTS transaction

2015-03-10 Thread Marc Aymerich
On Tue, Mar 10, 2015 at 5:15 PM, Marc Aymerich <glicer...@gmail.com> wrote:

>
>
> On Tue, Mar 10, 2015 at 5:12 PM, Marc Aymerich <glicer...@gmail.com>
> wrote:
>
>> Hi,
>> I have a middleware that performs some operations at the end of each
>> request.
>>
>> What I have found is that middlewares do not run inside the
>> ATOMIC_REQUESTS transaction. But I want the ATOMIC_REQUESTS transaction to
>> rollback if an exception is being raised on my middleware.
>>
>> Any idea on how to solve this?
>>
>
> Well, I supose I can grab the TransactionMiddleware from the previous
> release and use that instead of ATOMIC_REQUESTS :)
>
>
> https://github.com/django/django/blob/stable/1.7.x/django/middleware/transaction.py
>


Not that easy, it seems that now all transactions are aborted by the
middleware :( I'll keep looking




> --
>
Marc

-- 
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%2BDCN_tKn4wojnnzE%2B9CLvCKO8aPnEbB93J4HX%3DP02g9oOO%2BVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running middleware within ATOMIC_REQUESTS transaction

2015-03-10 Thread Marc Aymerich
On Tue, Mar 10, 2015 at 5:12 PM, Marc Aymerich <glicer...@gmail.com> wrote:

> Hi,
> I have a middleware that performs some operations at the end of each
> request.
>
> What I have found is that middlewares do not run inside the
> ATOMIC_REQUESTS transaction. But I want the ATOMIC_REQUESTS transaction to
> rollback if an exception is being raised on my middleware.
>
> Any idea on how to solve this?
>

Well, I supose I can grab the TransactionMiddleware from the previous
release and use that instead of ATOMIC_REQUESTS :)

https://github.com/django/django/blob/stable/1.7.x/django/middleware/transaction.py

-- 
Marc

-- 
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%2BDCN_tiBFumLxEOgwHx1%2B-OKmN-M4M%2B0totbe--2D%3DYHuny_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Running middleware within ATOMIC_REQUESTS transaction

2015-03-10 Thread Marc Aymerich
Hi,
I have a middleware that performs some operations at the end of each
request.

What I have found is that middlewares do not run inside the ATOMIC_REQUESTS
transaction. But I want the ATOMIC_REQUESTS transaction to rollback if an
exception is being raised on my middleware.

Any idea on how to solve this?

Thanks!
-- 
Marc

-- 
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%2BDCN_vcGpq-i-pUEpcNNqyXw%3DKyLTO97xFUrv%2BhwgJ%2B68qySA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: my mysite/templates/admin/base_site.html is ignored (tutorial unclear?)

2015-02-12 Thread Marc Moncrief
I've been going through the tutorial and had the same problem. The docs say
 "Create a templates directory in your project directory. "
I don't know if this will apply to you, but I thought that meant to put it 
in the poll directory. They mean to put it in the mysite directory. I made 
that change and my template changes started to be applied.



On Monday, November 17, 2014 at 5:15:59 AM UTC+11, Andreas Ka wrote:
>
> I am working through 
> https://docs.djangoproject.com/en/1.7/intro/tutorial02
> so far all went fine - but now *templates changes just don't work.*
>
>
>
> I think there must be a flaw in that tutorial, something missing,
> or something different in django 1.7.1 ?
>
> https://docs.djangoproject.com/en/1.7/intro/tutorial02/#customize-the-admin-look-and-feel
>
>
> my versions:
>
> python -c "import django; print(django.get_version())"
> 1.7.1
>
> python --version
> Python 2.7.3
>
>
>
> *SYMPTOM:*
>
> my changes in 
> mysite/templates/admin/base_site.html   
> are simply ignored.
>
>
>
> These are my files:
>
> mysite# tree
> .
> ├── db.sqlite3
> ├── manage.py
> ├── mysite
> │   ├── __init__.py
> │   ├── settings.py
> │   ├── urls.py
> │   └── wsgi.py
> ├── polls
> │   ├── admin.py
> │   ├── __init__.py
> │   ├── migrations
> │   │   ├── 0001_initial.py
> │   │   └── __init__.py
> │   ├── models.py
> │   ├── tests.py
> │   └── views.py
> └── templates
> └── admin
> └── base_site.html
>
>
>
> mysite/settings.py:
>
> TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
>
>
> *Whatever I do, the page*
> *http://myserver:8000/admin/polls/question/ 
> *
> *still keeps the old title 'Django administration'*
>
>
> I want to understand how templates work, because I need them for my real 
> project.
>
> Thanks a lot!
>
>
>
-- 
The information contained in this e-mail message and any accompanying files 
is or may be confidential. If you are not the intended recipient, any use, 
dissemination, reliance, forwarding, printing or copying of this e-mail or 
any attached files is unauthorised. This e-mail is subject to copyright. No 
part of it should be reproduced, adapted or communicated without the 
written consent of the copyright owner. If you have received this e-mail in 
error please advise the sender immediately by return e-mail or telephone 
and delete all copies. Fairfax Media does not guarantee the accuracy or 
completeness of any information contained in this e-mail or attached files. 
Internet communications are not secure, therefore Fairfax Media does not 
accept legal responsibility for the contents of this message or attached 
files.

-- 
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/3adb35af-b768-47fd-8196-8373d39c6991%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python: Assign variable in if statement?

2014-11-30 Thread Marc Aymerich
On Sun, Nov 30, 2014 at 12:30 PM, ThomasTheDjangoFan
<stefan.eichholz.ber...@googlemail.com> wrote:
> Hi guys,
>
> coming from php I am wondering if there is a way to do something like this
> in Python/Django:
>
> if variable = get_a_value_from_function():
>   new_stuff = variable
>
> Of course I can use
>
> variable = get_a_value_from_function()
> if variable:
>   new_stuff = variable
>
> But is there a shortcut similar to php?

perhaps something like:

new_stuff = get_a_value_from_function() or get_a_value_from_other_function()


-- 
Marc

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


Need something like the removed Q.add_to_query method

2014-10-16 Thread marc
Hey,

I have a complex filter system for selecting data. Short said: I need a 
possibility in the Django ORM to create a query like this:

SELECT * FROM table 
INNER JOIN attributes 
WHERE (attributes.id IN (
SELECT id FROM attributes 
WHERE (attributes.key = 'k1' AND attributes.value = 'val') 
))
AND (attributes.id IN (
SELECT id FROM attributes 
WHERE (attributes.key = 'k2' AND attributes.value = 'another val')
))

In ORM i would expect something like Q(Q() & Q()) but this does not 
surrount the parantheses. 

The query should return only rows which has both (or more)  matching 
key-value pairs in *attributes*.
I read that in 1.5 there was a possibility to override the Q() object to 
achieve this. 

Is there any other way without writing raw SQL?

Thanks in advance,
Marc

-- 
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/efbbadfd-5f18-4794-80b1-f8c5c301b0a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


AppConfig where to execute initialization queries?

2014-10-06 Thread Marc Aymerich
Hi,
I have been bitten by unexpected behaviors when running tests because on
AppConfig.ready() I was initializing some stuff that depends on DB stored
data. Reading the django docs I've found a warning that specifically
suggests not to do this [1]. But then I wonder where this kind of
initialization logic should go? any suggestion?

[1]
https://docs.djangoproject.com/en/1.7/ref/applications/#django.apps.AppConfig.ready

Although you can access model classes as described above, avoid interacting
with the database in your ready()
<https://docs.djangoproject.com/en/1.7/ref/applications/#django.apps.AppConfig.ready>implementation.
This includes model methods that execute queries (save()
<https://docs.djangoproject.com/en/1.7/ref/models/instances/#django.db.models.Model.save>
, delete()
<https://docs.djangoproject.com/en/1.7/ref/models/instances/#django.db.models.Model.delete>,
manager methods etc.), and also raw SQL queries via django.db.connection.
Your ready()
<https://docs.djangoproject.com/en/1.7/ref/applications/#django.apps.AppConfig.ready>
method
will run during startup of every management command. For example, even
though the test database configuration is separate from the production
settings, manage.py test would still execute some queries against your
*production* database!

-- 
Marc

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


Re: django 1.7 Groups

2014-09-15 Thread marc
Hi,

changing the base Group model is not very easy. 

My suggestion is to create a ManyToMany relation on your Company model.

class Company(models.Model):

groups = models.ManyToManyField("auth.Group")

The design allows in theory many companies to have the same group, but this 
you can check on code side.

Cheers

Am Freitag, 12. September 2014 20:49:40 UTC+2 schrieb John Rodkey:
>
> How can I modify the auto generated auth groups to include a foreign key? 
>  We wish to add a foreign key to show group ownership to a company table.
>
> For example, Company A could create a librarians group and assign users.
>
> Company B could create a brokers group and assign users
>
>

-- 
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/f8cb50aa-18a7-40a7-9941-4cb1c402c2f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: HttpResponse methods difference

2014-08-28 Thread marc
As you see in: 
https://github.com/django/django/blob/master/django/http/response.py#L370 
all three methods have different usecases.

.write(string) <- adds content
.tell() <- returns the length of content
.flush() <- just passing, does nothing (since at lease v1.5)

Cheers

Am Donnerstag, 28. August 2014 02:48:16 UTC+2 schrieb Yarick Antonov:
>
> What the difference between HttpResponse.Write() 
> ,
>  
> HttpResponse.flush() 
> 
>  
> and HttpResponse.tell() 
> 
>  
> methods?
>
> 
>

-- 
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/961ac065-bb0e-408f-82be-9e1f05ce76a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django manage.py commands not displaying

2014-08-27 Thread marc
Can you please post the content of your manage.py?

Cheers

Am Dienstag, 26. August 2014 15:28:43 UTC+2 schrieb RSS:
>
> sorry my bad English
>
> i`m working on hosting
>
> project structure:
> --myenv
> --rsskg.ru
> public_html
> --virtaulenv-1.9
>
> $ cd projects.ru/public_html
> $ source ~/myenv/bin/activate 
> $ ./manage.py
> ...Available subcommands:
> here nothing
>
> $ django-admin.py
> Available subcommands:
> [django]
> ...
> It`s Ok
>
> Why this?
>

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


Re: building a xenserver web client

2014-08-01 Thread marc
Openstack is huge. I'll prefer a lightweight solution, maybe just HTML/CSS 
(if there is already a good Soap client for JS). But this should be 
compatible to most of the API features provided by xen.

Am Donnerstag, 31. Juli 2014 17:39:53 UTC+2 schrieb cmawe...@gmail.com:
>
> You mentioned "full featured". Check out 
> https://github.com/openstack/horizon if you haven't.
>
> On Thursday, July 31, 2014 9:55:43 AM UTC-4, ma...@tubeards.com wrote:
>>
>> Hi,
>>
>> is anyone interested in co-building a full featured web client for 
>> xenserver instances? 
>> Since version 6.2 the update procedures are really a pain which is one of 
>> my reasons to think about an (maintained) opensource client.
>>
>> Ideas are welcome.
>> Cheers
>>
>

-- 
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/8214660c-6a6a-4b78-b21c-afa51a959090%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


building a xenserver web client

2014-07-31 Thread marc
Hi,

is anyone interested in co-building a full featured web client for 
xenserver instances? 
Since version 6.2 the update procedures are really a pain which is one of 
my reasons to think about an (maintained) opensource client.

Ideas are welcome.
Cheers

-- 
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/9e7a3689-9b5e-4dba-865c-f46b6c047c9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Static Files not Loading

2014-07-30 Thread marc
Hi,

STATIC_PATH should be STATIC_ROOT.

Cheers

Am Mittwoch, 30. Juli 2014 17:10:17 UTC+2 schrieb Steven Williams:
>
> -BEGIN PGP SIGNED MESSAGE- 
> Hash: SHA1 
>
> Hi, 
>
> I just asked around on IRC and no one was able to help me. Also the 
> entries on StackOverflow are not that helpful in my situation either. 
>
> Right now I am unable to access my static content in my project. Going 
> to 127.0.0.1:8000/static/rango.jpg yields a 404 error message. This is 
> a development environment where I am just learning the framework using 
> Tango with Django. My system is running Fedora 20 with Django 1.6 
> installed. 
>
> This is my settings.py paste https://dpaste.de/pU40 
>
> Any help would be greatly appreciated. 
>
> - -- 
> Steven Williams 
> My PGP Key 
> http://pgp.mit.edu/pks/lookup?op=get=0xCACA6C74669A54FA 
> -BEGIN PGP SIGNATURE- 
> Version: GnuPG v1 
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ 
>
> iQIcBAEBAgAGBQJT2QqDAAoJEMrKbHRmmlT63vUP/RQ7jyVgXLc0EYoJKE84Tfg4 
> 84IqEaXHgT709J2ChZYpQjRLpsm/7IYbJt/JDXQzW4+E67AMOwqjHyPzlLWUaaD2 
> auqbCLmebeUXB8Et8r0k8eATU9cW+edmRrcoVi2ZmO/dXR+NqEZigGq4nPfFjUac 
> lFYpfYlxKmFT8vht/er3ftR5ADC4MLohG42W48NIyHe//tTijDFj5ZBV6Zb94Y3p 
> 46me03yXimSQVpdq7ZPMGe5zVo+TL/QoEpZlipGglo1+3WPzK37ZkW7YRv1l6tb/ 
> thBx2lRAWHoOpQdtOjklYZaXJtf/yKVF+E831N8BTuPKbQu3gHVms7nxB3fKu/hs 
> VJ1CH3aSslw1ndZLX2Ll4CVCjnk33QrAu+ruu+lexOsLDG/SLupLpakcAMhqW3BZ 
> yxWSl+s/RypL21VsNv6wQC2JT/DKZrCWxtL6/yOE6/OnvOtzh3f8YwtwiQGmAsT7 
> tjd5pU/Qh4mgv4P6aL5STpVws5RMgVVSV/p25RYYtDnLf47MrNZNv+0c4DUrrKSj 
> xlYeIwm0M8mGQR8nBg8NPCOhcRrrh79zjKMrB7cm6r9M+UBxZINyeG9NelsD7Zb/ 
> jaXtvbOqoHYVzbci81skpQPxtgf6c6wjrgwckVcWaXRFnXZWisFJH6sjjDAS5jW2 
> GW8Y3CmUlEiJR5RUG7gp 
> =fRvw 
> -END PGP SIGNATURE- 
>

-- 
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/9e08cc43-65e2-47cb-98ea-3b73dc490d0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: internationalization (i18n)

2014-07-30 Thread marc
Here's a list of locales in Django: 
https://github.com/django/django/tree/master/django/conf/locale

Am Mittwoch, 30. Juli 2014 14:47:03 UTC+2 schrieb ma...@tubeards.com:
>
> Hi,
>
> have a look at: http://www.i18nguy.com/unicode/language-identifiers.html
>
> The localization in django is based on region and language codes, some of 
> them are the same (like 'de') and some split (like 'en-us'). For 'mr' 
> you'll need to add the area code of india iirc.
>
> Cheers
>
> Am Mittwoch, 30. Juli 2014 14:31:37 UTC+2 schrieb Supriya Sawant:
>>
>>
>> Hello,
>>
>>   I am using internationalization feature in djnago framework.
>>
>>   In my setting.py I have following languages set:
>>
>> LANGUAGES = (
>> ('de', ugettext('German')),('en', ugettext('English')),('mr', 
>> ugettext('Marathi')),('mwr', ugettext('Marwari')),('mun', ugettext\
>> ('Munda')),('ne', ugettext('Nepali')),('ori', ugettext('Oriya')),('pi', 
>> ugettext('Pali')),('pa', ugettext('Panjabi')),('raj', ugette\
>> xt('Rajasthani')),('sa', ugettext('Sanskrit')),('sat', 
>> ugettext('Santali')),('sd', ugettext('Sindhi')),('ta', 
>> ugettext('Tamil')),('t\
>> e', ugettext('Telugu')),('ur', ugettext('Urdu')),('as', 
>> ugettext('Assamese')),('awa', ugettext('Awadhi')),('ber', 
>> ugettext('Bengali'\
>> )),('bho', ugettext('Bhojpuri')),('bh', ugettext('Bihari')),('bra', 
>> ugettext('Braj')),('gon', ugettext('Gondi')),('dra', ugettext('D\
>> ravidian')),('gu', ugettext('Gujarati')),('en', 
>> ugettext('English')),('him', ugettext('Himachali')),('hi', 
>> ugettext('Hindi')),('kn',\
>>  ugettext('Kannada')),('ks', ugettext('Kashmiri')),('kha', 
>> ugettext('Khasi')),('kok', ugettext('konkani')),('kru', ugettext('Kurukh'\
>> )),('lah', ugettext('Lahnda')),('lus', ugettext('Lushai')),('mag', 
>> ugettext('Magahi')),('mai', ugettext('Maithili')),('mi', ugettext\
>> ('Malayalam')),('mni', ugettext('Manipuri')),('fr', 
>> ugettext('French')),('ja', ugettext('Japanese')),('da', 
>> ugettext('Danish')),('es\
>> ', ugettext('Spanish')),('it', ugettext('Italian')),('ru', 
>> ugettext('Russian')),
>>
>> I  have created th po file .
>>
>> but while runserver I am getting following error:
>>
>> raise KeyError("Unknown language code %s." % lang_code)
>> KeyError: u'Unknown language code mr.'
>>
>> what would be the reason.
>>
>

-- 
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/20a3ac7f-3976-4e1a-b2a9-8377440794b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: internationalization (i18n)

2014-07-30 Thread marc
Hi,

have a look at: http://www.i18nguy.com/unicode/language-identifiers.html

The localization in django is based on region and language codes, some of 
them are the same (like 'de') and some split (like 'en-us'). For 'mr' 
you'll need to add the area code of india iirc.

Cheers

Am Mittwoch, 30. Juli 2014 14:31:37 UTC+2 schrieb Supriya Sawant:
>
>
> Hello,
>
>   I am using internationalization feature in djnago framework.
>
>   In my setting.py I have following languages set:
>
> LANGUAGES = (
> ('de', ugettext('German')),('en', ugettext('English')),('mr', 
> ugettext('Marathi')),('mwr', ugettext('Marwari')),('mun', ugettext\
> ('Munda')),('ne', ugettext('Nepali')),('ori', ugettext('Oriya')),('pi', 
> ugettext('Pali')),('pa', ugettext('Panjabi')),('raj', ugette\
> xt('Rajasthani')),('sa', ugettext('Sanskrit')),('sat', 
> ugettext('Santali')),('sd', ugettext('Sindhi')),('ta', 
> ugettext('Tamil')),('t\
> e', ugettext('Telugu')),('ur', ugettext('Urdu')),('as', 
> ugettext('Assamese')),('awa', ugettext('Awadhi')),('ber', 
> ugettext('Bengali'\
> )),('bho', ugettext('Bhojpuri')),('bh', ugettext('Bihari')),('bra', 
> ugettext('Braj')),('gon', ugettext('Gondi')),('dra', ugettext('D\
> ravidian')),('gu', ugettext('Gujarati')),('en', 
> ugettext('English')),('him', ugettext('Himachali')),('hi', 
> ugettext('Hindi')),('kn',\
>  ugettext('Kannada')),('ks', ugettext('Kashmiri')),('kha', 
> ugettext('Khasi')),('kok', ugettext('konkani')),('kru', ugettext('Kurukh'\
> )),('lah', ugettext('Lahnda')),('lus', ugettext('Lushai')),('mag', 
> ugettext('Magahi')),('mai', ugettext('Maithili')),('mi', ugettext\
> ('Malayalam')),('mni', ugettext('Manipuri')),('fr', 
> ugettext('French')),('ja', ugettext('Japanese')),('da', 
> ugettext('Danish')),('es\
> ', ugettext('Spanish')),('it', ugettext('Italian')),('ru', 
> ugettext('Russian')),
>
> I  have created th po file .
>
> but while runserver I am getting following error:
>
> raise KeyError("Unknown language code %s." % lang_code)
> KeyError: u'Unknown language code mr.'
>
> what would be the reason.
>

-- 
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/56de9898-9119-45fc-8abe-dd2f0ed91bfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to ride submit_line.html

2014-07-30 Thread marc
Hi,

have a look there: 
http://stackoverflow.com/questions/8442724/django-admin-disable-editing-and-remove-save-butttons-for-a-specific-model

Guess it is the right way to go.

Cheers

Am Mittwoch, 30. Juli 2014 13:32:18 UTC+2 schrieb Akshay Mukadam:
>
> How can we override the submit_line.html to disable the save buttons in 
> django admin site
>
> I have tried in following ways:
> 1-> Using Javascript
> 2->
> https://github.com/django/django/blob/master/django/contrib/admin/templatetags/admin_modify.py#L23
>  
> by overriding these link
>
> But I want to change it using change_view method
> how can I achieve that 
>
> Thank you 
> For Help
>

-- 
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/c12e72bb-5e59-48d7-827d-f65e4fe4fc4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: (ModelForm) confusion

2014-07-30 Thread marc
Hi,

you are calling 'is_valid' in your view, which should be an method call:

a_valid = aform.is_valid*()*
m_valid = mform.is_valid*()*
p_valid = pform.is_valid*()*


There where a few hooks in your view, for example: you check for 
'is_valid()' but there is no code to execute after. I've changed it a bit:

http://pastie.org/9431548

Am Mittwoch, 30. Juli 2014 08:59:15 UTC+2 schrieb Kamal Kaur:
>
> Greetings! 
>
> What I have done: 
> There are four tables, from which I have generated ModelForms. Getting 
> the WorkerDetails from one side, adding the salary and attendance 
> things from the other side as the view says. If there is at least one 
> row added in WorkerDetail table, then it directly asks to add the 
> salary and attendance things. Everything is being added perfectly but 
> I have to add that "ForeignKey" thing in every form. 
>
> Aim: 
> To design a page like this: 
> http://tinypic.com/r/feor5h/8 
>
> Query: 
> What I need to do to display forms like this and get the foreign key 
> attribute directly from the displayed list? Is what I have done right? 
> Is there some better approach to get this desired layout? 
>
> Required code: 
> models.py: http://pastie.org/9430952 
> forms.py : http://pastie.org/9430955 
> views.py : http://pastie.org/9430962 
>
>
>
> -- 
> Kamaljeet Kaur 
> I'm not what I'm compared to others, I'm what I'm compared to my 
> yesterday. 
>

-- 
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/83469e1b-9824-426e-8141-97465ef47202%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to create migration with Error - One or more models did not validate:

2014-07-30 Thread marc
Hi,

you've added a relation to the AssetPollingConfig model which is not 
defined. 

Cheers

Am Mittwoch, 30. Juli 2014 13:34:52 UTC+2 schrieb Subodh Nijsure:
>
> Hello, 
>
> I have following model definition and when I try to create a migration 
> using command,  'python manage.py schemamigration asset_mgmt 
> --initial' I am getting following error: 
>
> CommandError: One or more models did not validate: 
> asset_mgmt.alarmtable: 'polling_config' has a relation with model 
> AssetPollingConfig, which has either not been installed or is 
> abstract. 
>
> I have other classes that extend the TimeStampedModel and I don't see 
> this error, can someone point me towards reason I am getting this 
> error? 
>
>
> class TimeStampedModel(models.Model): 
> created = models.DateTimeField(auto_now_add=True) 
> modified = models.DateTimeField(auto_now=True) 
> class Meta: 
> abstract = True 
>
> class AssetPollingInfo(TimeStampedModel): 
> id = models.AutoField(primary_key=True) 
> alarm_text = models.CharField(max_length=800,blank=True,null=True) 
> asset_id = models.ForeignKey('AssetInfo') 
> thresholds = models.ForeignKey('ThresholdInfo') 
> dispatch = models.ForeignKey('AlarmDispatchInfo') 
> class Meta: 
> ordering = ['-id'] 
> def __unicode__(self): 
> return str(self.id) 
>
> class AlarmTable(TimeStampedModel): 
> id = models.AutoField(primary_key=True) 
> polling_config = models.ForeignKey('AssetPollingConfig') 
> alarm_text = models.CharField(max_length=800,blank=False,null=False) 
> event_type = models.SmallIntegerField(blank=False,null=False) 
> trigger_point = models.IntegerField(blank=True,null=True) 
> class Meta: 
> ordering = ['-id'] 
> def __unicode__(self): 
> return str(self.id) 
>
>
> -Subodh 
>

-- 
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/5a541fa1-208f-40ce-92f7-89546872d8d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: update a field of a related table on form save

2014-07-30 Thread marc
Hi Brad,

i would register a 'post_save' signal 
(https://docs.djangoproject.com/en/dev/ref/signals/#post-save) on the first 
model and then, just hit the save method on the Application model, this 
will automaticly update the time.

Cheers,
Marc

Am Mittwoch, 30. Juli 2014 03:26:21 UTC+2 schrieb Brad Rice:
>
> I have three tables. The first one is application which has a flag for if 
> an app has been submitted as well as created date and modified date. The 
> other two tables relate to the application table. I have two forms that get 
> update those tables. What I want to do is update the application modified 
> date from the save on the other forms.
>
> I have this in the Application model
> modified= models.DateTimeField(auto_now_add=True)
>
> but since it is the other tables I am saving to, I'm not sure how to 
> update that field whenever the other two tables update.
>
> My view for one of the forms looks like this:
>
> class AnswersUpdate(UpdateView):
> model = Answers
> form_class = AnswersForm
> slug_field = 'created_by'
> template_name = 'requestform/applicant_form.html'
>
> @method_decorator(login_required(login_url='/accounts/login/'))
> def dispatch(self, *args, **kwargs):
> return super(AnswersUpdate, self).dispatch(*args, **kwargs)
>
> def get_object(self, queryset=None):
> return Answers.objects.get(created_by=self.request.user)
>
> def form_valid(self, form):
> obj = form.save(commit=False)
> obj.created_by = self.request.user
> obj.save()
> a = Application.objects.get(created_by=self.request.user)
>## how do I save to the Application here?
> return HttpResponseRedirect(reverse('requestform:app_check', 
> kwargs={'app_id': obj.id}))
>
> Any help would be appreciated.
>
>

-- 
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/08d28a7e-7e95-4b3e-9117-b8573c2bba45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django package to convert Less to CSS

2014-07-30 Thread marc
Hi,

are you using a virtualenv? Your lessc installation seems to point to a 
ruby one. (/Library/Ruby/Gems/2.0.0/gems/

less-2.4.0/bin/lessc) 

Be shure to have the correct path, try `which lessc` to see where it points 
to.


Cheers

Marc


Am Mittwoch, 30. Juli 2014 04:08:47 UTC+2 schrieb Chen Xu:
>
> I tried this, but I got errors like:
>
> /Library/Ruby/Gems/2.0.0/gems/less-2.4.0/bin/lessc:100:in `read': No such 
> file or directory - 
> /Users/xuchen81/Desktop/hw-kkworld/assets/less/kk-less/_global.css 
> (Errno::ENOENT)
>
> from /Library/Ruby/Gems/2.0.0/gems/less-2.4.0/bin/lessc:100:in ` (required)>'
>
> from /usr/bin/lessc:23:in `load'
>
> from /usr/bin/lessc:23:in `'
>
> Where I think  "/_global.css" is supposed to be generated. However, it 
> says no such file.
>
>
> Thanks
>
>
> On Tue, Jul 29, 2014 at 9:12 PM, carlos <croch...@gmail.com > 
> wrote:
>
>> https://pypi.python.org/pypi/lesscss
>>
>> Cheers
>>
>>
>> On Tue, Jul 29, 2014 at 3:27 PM, Chen Xu <xuch...@gmail.com 
>> > wrote:
>>
>>> Hi, Everyone
>>> I am wondering is there a good django package that can convert less file 
>>> into css file?
>>>
>>>
>>> Thanks
>>>
>>>
>>> -- 
>>> ⚡ Chen Xu ⚡ 
>>>
>>> -- 
>>> 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/CACac-qbgdcFCkQHUfcV1hh2GNbkZ95j6tjfJ0f%2B1BXExgomRhw%40mail.gmail.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/CACac-qbgdcFCkQHUfcV1hh2GNbkZ95j6tjfJ0f%2B1BXExgomRhw%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> 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...@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/CAM-7rO1vTyuSdh%3DxvpD1nBPuEUJpdUxupLPQCMbb6F3p6mP8rw%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/django-users/CAM-7rO1vTyuSdh%3DxvpD1nBPuEUJpdUxupLPQCMbb6F3p6mP8rw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> ⚡ Chen Xu ⚡ 
>

-- 
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/96766eeb-0082-4e49-82f6-9abe6f605a3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 - What are you most excited about?

2014-07-30 Thread marc
Hi,

aggree in all points Russel, these features are also my favourite ones.


   - html email support in different places and the password reset mail 
   template makes life much easier. 

Greetings, Marc

Am Mittwoch, 30. Juli 2014 06:54:21 UTC+2 schrieb Russell Keith-Magee:
>
> Hi Ryan,
>
> On Wed, Jul 30, 2014 at 9:31 AM, Ryan Blunden <ryan.b...@gmail.com 
> > wrote:
>
>> Hi everyone,
>>
>> I'm giving a lightening talk at the San Francisco Django meetup tomorrow 
>> night about some of the awesome new features in Django 1.7.
>>
>> I wanted to highlight not just what *I think* are the best new features, 
>> but what members of the community are most excited about.
>>
>> Would be great to hear from the Django core contributors too.
>>
>  
> Well, the release notes pretty much highlight the things that the core 
> team think are big news. For me, the biggest of those are:
>
>  * Schema migration - obviously
>
>  * App loading - because we finally have somewhere to put signal 
> registrations.
>
>  * The new checks framework - because it's a big internal cleanup, and 
> opens lots of possibilities for the future
>
>  * Converting custom query sets into managers - because this is repetitive 
> work that we've been doing since 0.96
>
>  * Custom managers on reverse relations - because it's an obvious thing to 
> want once you have custom managers.
>
> Yours,
> Russ Magee %-)
>
>

-- 
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/60d1bc1c-b8a8-4dff-b69a-119b33838fc5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Different objects returned when filtering with a ValuesListQuerySet

2014-07-28 Thread Marc Kirkwood
Yeah that's what I was thinking it could be. cheers Russ.

-- 
Legal status: Any views or opinions are solely those of the sender and do 
not necessarily represent those of SF Software Ltd unless expressly stated 
in the body of the text of the email, this email is not intended to form a 
binding contract.

Confidentiality: this communication may contain information that is 
confidential and/or privileged and is for the exclusive use of the intended 
recipient(s). Any form of distribution, copying or use of this 
communication by anyone else is strictly prohibited. If you have received 
this communication in error, please reply to this message or telephone +44 
(0)845 310 1788 and delete this communication and destroy any copies. 

Security: this communication has been created and sent in the knowledge 
that internet e-mail is not secure. We strongly advise you to understand 
and to be aware of the lack of security when e-mailing us. If you 
communicate with us via e-mail, we will assume that you accept the security 
risk and that you authorise us to communicate with you in the same format. 
The sender therefore does not accept liability for any errors or omissions 
in the contents of this message, which arise as a result of e-mail 
transmission. 

Warning: Although we take reasonable precautions to ensure no viruses are 
present in this email, we cannot accept responsibility for any loss or 
damage arising from the use of this email or attachments. 

-
In compliance with Directive on Disclosure, The Companies Regulations 2006, 
effective 01 January 2007 talktopebble.co.uk,schoolfund.co.uk, 
schoolfundfinder.co.uk, easyusbooks.co.uk, clubfund.co.uk are domain names 
registered to SF Software Limited.

SF Software Limited is a company registered in England and Wales with 
company number: 05580540. Our trading name is Pebble our trading address 
and registered office is: Media Exchange Three, Coquet Street, Newcastle 
upon Tyne, NE1 2QB
VAT Registration number is: GB 873 5186 95

-- 
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/f327ed97-ee2f-4ca8-9045-d8bcebd170a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Different objects returned when filtering with a ValuesListQuerySet

2014-07-25 Thread Marc Kirkwood


When filtering a queryset with a *ValuesListQuerySet* instance in Django 
1.6, different objects to that shown in the apparent list seem to be 
returned by the iterator.

An illustration of a head-scratching debug session is shown below:

(Pdb) latest

*[4, 1]*

(Pdb) keys.filter(pk__in=latest).values_list('pk')

*[(3,), (1),)]*

(Pdb) keys.filter(pk__in=[4, 1]).values_list('pk')
*[(4,), (1),)]*

Can anyone explain this behaviour to me? When I fully convert it with 
*list(latest)*, normal service resumes.
I have a suspicion that it's because of the Postgres-aware *order_by()* and 
*distinct()* chain, in the queryset that *latest* was produced from.

Thanks,

Marc.

-- 
Legal status: Any views or opinions are solely those of the sender and do 
not necessarily represent those of SF Software Ltd unless expressly stated 
in the body of the text of the email, this email is not intended to form a 
binding contract.

Confidentiality: this communication may contain information that is 
confidential and/or privileged and is for the exclusive use of the intended 
recipient(s). Any form of distribution, copying or use of this 
communication by anyone else is strictly prohibited. If you have received 
this communication in error, please reply to this message or telephone +44 
(0)845 310 1788 and delete this communication and destroy any copies. 

Security: this communication has been created and sent in the knowledge 
that internet e-mail is not secure. We strongly advise you to understand 
and to be aware of the lack of security when e-mailing us. If you 
communicate with us via e-mail, we will assume that you accept the security 
risk and that you authorise us to communicate with you in the same format. 
The sender therefore does not accept liability for any errors or omissions 
in the contents of this message, which arise as a result of e-mail 
transmission. 

Warning: Although we take reasonable precautions to ensure no viruses are 
present in this email, we cannot accept responsibility for any loss or 
damage arising from the use of this email or attachments. 

-
In compliance with Directive on Disclosure, The Companies Regulations 2006, 
effective 01 January 2007 talktopebble.co.uk,schoolfund.co.uk, 
schoolfundfinder.co.uk, easyusbooks.co.uk, clubfund.co.uk are domain names 
registered to SF Software Limited.

SF Software Limited is a company registered in England and Wales with 
company number: 05580540. Our trading name is Pebble our trading address 
and registered office is: Media Exchange Three, Coquet Street, Newcastle 
upon Tyne, NE1 2QB
VAT Registration number is: GB 873 5186 95

-- 
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/0ce13f3c-9e46-4575-beba-d79205e97b80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.core.exceptions.AppRegistryNotReady

2014-07-08 Thread Marc Aymerich
On Tue, Jul 8, 2014 at 12:54 PM, Frank Bieniek <
frank.bien...@produktlaunch.de> wrote:

> Hi Marc,
>
> this should fix it:
>
>  File "/home/orchestra/django-orchestra/orchestra/apps/accounts/models.py",
>> line 9, in Account
>> user = models.OneToOneField(get_user_model(),
>> related_name='accounts')
>>
> change it to:
>
> user = models.OneToOneField(settings.AUTH_USER_MODEL,
> related_name='accounts')
>
> Simply do not use get_user_model() in model definitions.
>

Good fix Frank,
thank you very much!!


-- 
Marc

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


django.core.exceptions.AppRegistryNotReady

2014-07-08 Thread Marc Aymerich
Hi,
Wanted to try 1.7 and I'm hit by an exception that don't know how to solve
:)

running current 1.7.x branch, here full runserver output:

orchestra@orchestra:~/panel$ python manage.py runserver 0.0.0.0:
/usr/local/lib/python2.7/dist-packages/djcelery/managers.py:77:
RemovedInDjango18Warning: `ExtendedManager.get_query_set` method should be
renamed `get_queryset`.
  class ExtendedManager(models.Manager):

/usr/local/lib/python2.7/dist-packages/djcelery/managers.py:108:
RemovedInDjango18Warning: commit_manually is deprecated in favor of
set_autocommit.
  @transaction.commit_manually

Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 385, in execute_from_command_line
utility.execute()
  File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 354, in execute
django.setup()
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line
21, in setup
apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
line 106, in populate
app_config.import_models(all_models)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line
190, in import_models
self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
  File
"/home/orchestra/django-orchestra/orchestra/apps/accounts/models.py", line
8, in 
class Account(models.Model):
  File
"/home/orchestra/django-orchestra/orchestra/apps/accounts/models.py", line
9, in Account
user = models.OneToOneField(get_user_model(), related_name='accounts')
  File
"/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py",
line 136, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
line 187, in get_model
self.check_ready()
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
line 119, in check_ready
raise AppRegistryNotReady()
django.core.exceptions.AppRegistryNotReady


My impression is that breaks when loading a model that has a reference to
custom user model:

user = models.OneToOneField(get_user_model(), related_name='accounts')


Any idea?
-- 
Marc

-- 
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%2BDCN_vWsJ7j1BKGbuNpOPD%3DqHCffD8829Bu8N6zpfPua-k7%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Inlines in admin

2014-04-07 Thread Marc Aymerich
On Mon, Apr 7, 2014 at 3:04 PM, Emanuel  wrote:
> Hi all!
>
> I'm have the following models:
>
> Class A(models.Model):
>  pass
>
>
> Class Z(models.Model):
> pass
>
>
> Class B(models.Model):
>   a = models.ForeignKey(a)
>   z = models.ForeignKey(Z)
>
>def __unicode__(self):
>   return self.z
>
>
> Class C(models.Model):
>  b = models.ForeignKey(B)
>
>
> I Want in the admin add A,B and C objects.
>
> I know how to put inline objects of B in A. Everything works as expected.
> But I want to create new C's in the same page. Something like having C as an
> Inline of B, beeing B an Inline of A. It could appear all in popups...

nested inlines are not currently supported. A work around can be using
a readonly field on B inline that points to a B change view with C
inlines


class BInline(admin.TabularInline):
model = B
readonly_fields = ('c_link',)

def c_link(self, instance):
  if not instance.pk:
return ''
  url = reverse('admin:app_c_change', args=(instance.pk,))
  popup = 'onclick="return showAddAnotherPopup(this);"'
  return '%s' % (url, popup, instance)
 c_link.allow_tags=True


class CInline(admin.TabularInline):
 model = C


class AModelAdmin(admin.ModelAdmin):
 inlines = [BInline]


class BModelAdmin(admin.ModelAdmin):
inlines = [Cinline]

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


Annotate concat() of two fields

2014-03-29 Thread Marc Aymerich
Hi, I want to annotate the concatenation of two string fields, something like

Domain.objects.annotate(annotation=F('field1')+F('field2'))

however it is not possible to use F expressions on annotate().

I'm trying to accomplish the same thing using extra() however I don't
know how to do it right, :(

I have the following Domain model:

class Domain(models.Model):
name = models.CharField(max_length=256, unique=True)
top = models.ForeignKey('domains.Domain', null=True)

which top being a self referencing field,

I want an annotation with the concatenation of  "obj.top.name + obj.name"

What I have so far is something like

Domain.objects.select_related('top').extra(select={
'structured_name': 'CONCAT(T2.name, domains_domain.name)'
})

Notice that I'm using T2 which is the JOIN table, But this doesn't
always work, because it depends on the total number of joins performed
by the queryset, (so the name changes to T4, etc)

What would be the right way of doing this concat() annotation?

thanks!!
-- 
Marc

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


Anybody out there installed and run DjangoBB?

2014-02-20 Thread Marc Garcia
Hi,

I'm new in Django and I'm planning create a website using a forum. After 
some googles I've noticed that the most updated and best choice for my 
purpose is DjangoBB.

I looked the official manual http://djangobb.org/wiki/QuickInstall but I'm 
stacked because I have to set up a database and I have no Idea which tables 
/ rows I have to create

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/88582514-a256-4f9e-bd34-8c85b7fd9183%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


platform for mainstream enterprise applications

2014-02-19 Thread Marc Model
 

I am a Django newbie.

I expect that Django could be a good platform to build a force.com like 
application platform: a platform where business experts can define business 
data models, authorization rules (which user role can access or edit what 
parts of a model in what state) and workflow rules. 

I wander if there are already initiatives out there to build this type of 
platform, or components of it? 

For instance I found on the internet some discussion around dynamic models 
(classes) exploiting meta-programming facilities of Django. That could be 
the foundation of such platform.

Thanks for any referral.

Marc

-- 
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/d099d61a-ea08-4710-8ba9-beb6a19102c9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: AssertionError: u'ns.example.com.' == 'ns.example.com.' ?

2014-02-12 Thread Marc Aymerich
On Wed, Feb 12, 2014 at 8:01 PM, Larry Martell <larry.mart...@gmail.com> wrote:
> On Wed, Feb 12, 2014 at 1:56 PM, Marc Aymerich <glicer...@gmail.com> wrote:
>> I'm running my Django app tests and I'm getting a random and very
>> annoying assertion error
>>
>> ==
>> FAIL: test_rest_dns_delete
>> (orchestra.apps.dns.zones.tests.functional_tests.tests.RESTBind9MasterBackendTest)
>> --
>> Traceback (most recent call last):
>>   File 
>> "/home/orchestra/django-orchestra/orchestra/apps/dns/zones/tests/functional_tests/tests.py",
>> line 212, in test_rest_dns_delete
>> self.validate_delete()
>>   File 
>> "/home/orchestra/django-orchestra/orchestra/apps/dns/zones/tests/functional_tests/tests.py",
>> line 86, in validate_delete
>> self.assertNotEqual('%s.' % self.zone.name_server, soa[4])
>> AssertionError: u'ns.example.com.' == 'ns.example.com.'
>>
>> --
>>
>> WTF is wrong with it?
>> The thing is that I don't always get the error, just like 1/4 of the
>> times, and a manual assertion like this never fails !
>>
>> self.assertEqual(u'ns.example.com.', 'ns.example.com.')
>>
>>
>> Any clue?
>>
>> Thank you guys!
>
> In your test output you have assertNotEqual and in your manual
> assertion you have assertEqual.

omg, this is shameful ;)
I definitively need to have some rest!

Thanks guys !

-- 
Marc

-- 
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%2BDCN_u7RMeSJX8whvkNufyUDj7LKCC40yZqYqsjvK-P%3DBpOsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


AssertionError: u'ns.example.com.' == 'ns.example.com.' ?

2014-02-12 Thread Marc Aymerich
I'm running my Django app tests and I'm getting a random and very
annoying assertion error

==
FAIL: test_rest_dns_delete
(orchestra.apps.dns.zones.tests.functional_tests.tests.RESTBind9MasterBackendTest)
--
Traceback (most recent call last):
  File 
"/home/orchestra/django-orchestra/orchestra/apps/dns/zones/tests/functional_tests/tests.py",
line 212, in test_rest_dns_delete
self.validate_delete()
  File 
"/home/orchestra/django-orchestra/orchestra/apps/dns/zones/tests/functional_tests/tests.py",
line 86, in validate_delete
self.assertNotEqual('%s.' % self.zone.name_server, soa[4])
AssertionError: u'ns.example.com.' == 'ns.example.com.'

--

WTF is wrong with it?
The thing is that I don't always get the error, just like 1/4 of the
times, and a manual assertion like this never fails !

self.assertEqual(u'ns.example.com.', 'ns.example.com.')


Any clue?

Thank you guys!


-- 
Marc

-- 
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%2BDCN_upBZoac0_UUWN2ivdga%2BwWkmwwkwZHx12UBhVb5qpS-A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django error

2014-01-10 Thread Marc Westberg
Please forgive me for a newbie problem
I installed Django, i can do "python -c "import django; 
print(django.get_version())"  and get a return of "1.6.1". When I try any 
command after  django-admin.py. Such as django-admin.py check 
or django-admin.py shell, I get only the help menu.
 I installed python and Django on a non prod laptop and I can use 
all django-admin.py. 

Any Ideas, 
All help is appreciated,
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/6a145097-d56e-4271-98ba-59a50cc86855%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django ORM & DB backend coupling

2013-12-24 Thread Marc Aymerich
On Tue, Dec 24, 2013 at 4:15 PM, Rakan Alhneiti
<rakan.alhne...@gmail.com> wrote:
> Hello all,
>
> I was discussing the topic with a couple of my friends that Django's ORM is
> / is not tightly coupled with databases in general. My point of view was
> that django is not tightly coupled because you can write custom DB backends
> to deal with other sources of data such as a Restful API service while still
> taking advantage of the ORM.
> However, looking at the current architecture & implementation, i guess i can
> say that it is coupled because writing a custom backend would require you to
> write database-specific classes such as the DatabaseWrapper, Operations,
> Features .. etc.
>
> Is wiring Django's ORM with a Restful API service rather than MySQL or
> Postgresql a good idea? or the better one would be writing ORMs from scratch
> that are API-based rather than database-driven?
>
> Please share with me your thoughts on this topic.

You may want to take a look at a recent discussion at django-dev about
this subject

https://groups.google.com/forum/#!msg/django-developers/zlLCJ5HC3c8/7eFdmdUSDbsJ


-- 
Marc

-- 
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%2BDCN_vDwyBGnMGjgmD5D8U5m_-xaxd1LtqWgurUUQ-Dfte8jA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django ORM & DB backend coupling

2013-12-24 Thread Marc Aymerich
On Tue, Dec 24, 2013 at 4:15 PM, Rakan Alhneiti
<rakan.alhne...@gmail.com> wrote:
> Hello all,
>
> I was discussing the topic with a couple of my friends that Django's ORM is
> / is not tightly coupled with databases in general. My point of view was
> that django is not tightly coupled because you can write custom DB backends
> to deal with other sources of data such as a Restful API service while still
> taking advantage of the ORM.
> However, looking at the current architecture & implementation, i guess i can
> say that it is coupled because writing a custom backend would require you to
> write database-specific classes such as the DatabaseWrapper, Operations,
> Features .. etc.
>
> Is wiring Django's ORM with a Restful API service rather than MySQL or
> Postgresql a good idea? or the better one would be writing ORMs from scratch
> that are API-based rather than database-driven?

I actually ended up implementing a "REST ORM" from scratch, but
heavily inspired by Django's ORM. I managed to spend a couple of weeks
on it, but now the project is dead. You may want to take a look at it
anyway:

http://confine-orm.readthedocs.org/
http://redmine.confine-project.eu/projects/confine-orm/repository

The main difference with Django is that resource schema is not
predefined, but discovered while browsing the API. Also the API for
what it was developed for did not support filtering, so it does
client-side filtering with heavy use of concurrency.

Don't really know how much you'll need to sacrifice in order to fit a
REST service within a Django ORM backend. It could be fun to do it,
but leveraging all its potential seems quite difficult at first look,
I would say it's not worth the trouble :)

-- 
Marc

-- 
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%2BDCN_s3pb_%3D07vTb96qZANjBb30UZKnt7hB-fmhPuCD8PZxXg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: RestFul with Class Based Views best practice

2013-10-29 Thread Marc Aymerich
On Tue, Oct 29, 2013 at 8:45 PM, pywebdesign <pywebdes...@gmail.com> wrote:

> Hi,
>
> I am trying to find/develop a best way to name and organize Views class to
> be consistent and flexible.
>
> I am working on a project witch involve an model called Song. It's kind of
> a midi song in a database with attibutes about authors, name ... to make it
> simple.
>
> Now I want web pages that permit to create a new song, edit a song, delete
> it or simply view it.
> I also want a list page that list song by authors, by instrument (a
> typical search and return a list). the idea is to make the list editable
> via ajax. people change something on a list and it saves it to the browser
> when done without quitting the list. Very useful to modify many list at the
> same time.
> There is also a page to create/upload 5 song at a time.
>
> I was searching the best structure for my Class Based View. Right now I
> came up with this one:
>
> class SongForm
> def get_new_song
> def post_new_song
>
> def get_modify_song
> def put_song
>
> def get_delete_song
> def delete_song
>
> class SongListForm
> def get_list_song(search infos)
>
> class SongView
> get_Song
>
>
> ok that's about it. It look wrong, one big class and to very small one. I
> would like some pointer to some best practice to create this kind of CRUD
> as RESTFUL.
>


Hi, what i'd do if I want to be restful is create two views, one for
listing and creating songs and another for reading, updating and deleting
existing songs

class SongList
   # url /songs/
   def get: list songs
   def post: create new song

class Song
   # url /songs/
   def get
   def put
   def patch
   def delete

I think with these two views you can cover all use-cases you've described :)

-- 
Marc

-- 
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%2BDCN_utdjJ39dY7kgE4-Nx7WXRpfVpe-Lo2V4CZsoUcJrn-SA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Accessing related objects on model.clean()

2013-10-17 Thread Marc Aymerich
On Wed, Oct 16, 2013 at 11:52 PM, Marc Aymerich <glicer...@gmail.com> wrote:
> Yep,
> I'm writing some validation logic for a model that is being used in an
> admin inline form
>
> The model looks like this
>
> class Child(models.Model):
>  parent = models.ForeignKey(Parent)
>
>  def clean(self):
>   super().clean()
>   if self.parent.surname != self.surname:
>   raise ValidationError
>
> The problem is that on the "Parent add admin view" I get a
> Parent.DoesNotExist error when I'm saving new Parent and Childs. That
> is because when child.clean() is called child.parent_id is None, so
> self.parent fails, it looks like self.parent is created afterwards and
> is not available at that time.

yep this was something related with my application ! it is indeed
possible to access related objects on model clean, sorry for the
noise!

-- 
Marc

-- 
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%2BDCN_ucGB4yM%3Dqr5NkBT8Dk1Wmd1zkzeXaFQ%3DofSpvnwJFWAw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Accessing related objects on model.clean()

2013-10-16 Thread Marc Aymerich
Yep,
I'm writing some validation logic for a model that is being used in an
admin inline form

The model looks like this

class Child(models.Model):
 parent = models.ForeignKey(Parent)

 def clean(self):
  super().clean()
  if self.parent.surname != self.surname:
  raise ValidationError

The problem is that on the "Parent add admin view" I get a
Parent.DoesNotExist error when I'm saving new Parent and Childs. That
is because when child.clean() is called child.parent_id is None, so
self.parent fails, it looks like self.parent is created afterwards and
is not available at that time.

How can I validate a new child object based on its parent information?
I'm surprised not finding any information regarding this issue :)



Thanks!

-- 
Marc

-- 
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%2BDCN_tcJgmi1tZGTROPkqF0rAtEcx-gRtRnBFrVWE_v%2Bp-wLg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Retrieving json stored in TextField as json

2013-10-10 Thread Marc Aymerich
On Thu, Oct 10, 2013 at 6:02 PM, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Thursday, 10 October 2013 10:08:18 UTC+1, Marc Aymerich wrote:
>>
>> Hi Rafael, thanks !
>> I forgot to mention that I was already using django-jsonfield
>> https://github.com/bradjasper/django-jsonfield
>> and now I've tried with django-json-field but with the same unfortunate
>> result:
>>
>> TimeSerie.objects.filter(type='cpu').values('value')
>> [{'value':
>> '{"scheduled":2,"total":864,"15min":0.38,"1min":0.3,"5min":0.48}'},
>> {'value':
>> '{"scheduled":2,"total":859,"15min":0.34,"1min":0.23,"5min":0.32}'},
>> {'value':
>> '{"scheduled":2,"total":849,"15min":0.33,"1min":0.51,"5min":0.32}'}]
>>
>> did I missed something?
>>
>
> You need to show how you are storing this value in the first place.

yep, here we go

class TimeSerie(models.Model):
type = models.CharField(max_length=64)
value = JSONField()
date = models.DateTimeField(auto_now_add=True)


# This is how the value is stored
value = json.loads(run(self.cmd, display=False).stdout)
TimeSerie.objects.create(type=self.name, value=value)


# And this is how it looks like using ValuesQuerySet vs accessing the
object value

>>> TimeSerie.objects.filter(pk=4769).values('value')
[{'value': 
'{"used":5358516,"cached":3191544,"free":2729444,"real-used":2044016,"shared":0,"real-free":6043944,"total":8087960,"buffers":122956}'}]

>>> TimeSerie.objects.filter(pk=4769)[0].values
{u'used': 5358516, u'cached': 3191544, u'free': 2729444, u'real-used':
2044016, u'shared': 0, u'real-free': 6043944, u'total': 8087960,
u'buffers': 122956}

One is an string and the other is a dict.

And here using raw sql
=# select value from monitor_timeserie where id=4769;
value
--
 
{"used":5358516,"cached":3191544,"free":2729444,"real-used":2044016,"shared":0,"real-free":6043944,"total":8087960,"buffers":122956}
(1 row)


it's a json field acctually
=# \d+ monitor_timeserie;
  Table
"public.monitor_timeserie"
 Column |   Type   |
Modifiers| Storage  | Stats target |
Description
+--++--+--+-
 id | integer  | not null default
nextval('monitor_timeserie_id_seq'::regclass) | plain    |
 |
 type   | character varying(64)| not null
 | extended |  |
 value  | json | not null
 | extended |  |
 date   | timestamp with time zone | not null
 | plain|  |
Indexes:
"monitor_timeserie_pkey" PRIMARY KEY, btree (id)
"monitor_timeserie_date_4395efb9" btree (date, type)
Has OIDs: no


-- 
Marc

-- 
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%2BDCN_urOzXqLBL6DfeVc3kTHQEz2xXsuiaP1Btr8S-ygAZFbg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Retrieving json stored in TextField as json

2013-10-10 Thread Marc Aymerich
Hi Rafael, thanks !
I forgot to mention that I was already using django-jsonfield
https://github.com/bradjasper/django-jsonfield
and now I've tried with django-json-field but with the same unfortunate result:

TimeSerie.objects.filter(type='cpu').values('value')
[{'value': '{"scheduled":2,"total":864,"15min":0.38,"1min":0.3,"5min":0.48}'},
{'value': '{"scheduled":2,"total":859,"15min":0.34,"1min":0.23,"5min":0.32}'},
{'value': '{"scheduled":2,"total":849,"15min":0.33,"1min":0.51,"5min":0.32}'}]

did I missed something?


On Thu, Oct 10, 2013 at 1:16 AM, Rafael Durán Castañeda
<rafadurancastan...@gmail.com> wrote:
> I'm using django-json-field [1] for solving the same problem.
>
> [1] https://github.com/derek-schaefer/django-json-field
>
> HTH
> El 09/10/2013, a las 16:01, Marc Aymerich <glicer...@gmail.com> escribió:
>
>> Hi,
>> I'm storing large volumes of json data in a TextFields, Then I have a
>> view that converts this text data into JSON, but this silly operation
>> requires a considerable amount of resources for a large dataset.
>>
>> It would be nice if I'm able to retrieve native JSON directly from the 
>> database.
>>
>> As you can see value is "almost" json, the only problem is that is
>> wrapped around quotes :)
>>
>>>>> TimeSerie.objects.filter(type='cpu').values('value')
>> [{'value': 
>> '{"scheduled":2,"total":864,"15min":0.38,"1min":0.3,"5min":0.48}'},
>> {'value': 
>> '{"scheduled":2,"total":859,"15min":0.34,"1min":0.23,"5min":0.32}'},
>> {'value': 
>> '{"scheduled":2,"total":849,"15min":0.33,"1min":0.51,"5min":0.32}'},
>> {'value': '{"scheduled":2,"total":814,"15min":0.3,"1min":0.2,"5min":0.25}'},
>> {'value': 
>> '{"scheduled":2,"total":817,"15min":0.25,"1min":0.14,"5min":0.17}'},
>> {'value': 
>> '{"scheduled":2,"total":815,"15min":0.22,"1min":0.18,"5min":0.14}'}]
>>
>> Any suggestion in how I can speed this up by avoiding to convert each
>> element to json by iterating on the query results?
>>
>> I'm using psotgresql 9.3 with native json support, not sure if it is
>> relevant or not :)
>>
>> --
>> Marc
>>
>> --
>> 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%2BDCN_vTbC0-yOt7cuToYLZSOD%2B%3DZCubLOjgkpu-MyB1VxbGMA%40mail.gmail.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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/646FABCC-B4DB-4EE7-BC54-B0C5A2C7C25F%40gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Marc

-- 
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%2BDCN_uq3OEKEEBrQnFGrDnvWTE0_G9UWG4k-EXPyz36H4rTDw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Retrieving json stored in TextField as json

2013-10-09 Thread Marc Aymerich
Hi,
I'm storing large volumes of json data in a TextFields, Then I have a
view that converts this text data into JSON, but this silly operation
requires a considerable amount of resources for a large dataset.

It would be nice if I'm able to retrieve native JSON directly from the database.

As you can see value is "almost" json, the only problem is that is
wrapped around quotes :)

>>> TimeSerie.objects.filter(type='cpu').values('value')
[{'value': '{"scheduled":2,"total":864,"15min":0.38,"1min":0.3,"5min":0.48}'},
{'value': '{"scheduled":2,"total":859,"15min":0.34,"1min":0.23,"5min":0.32}'},
{'value': '{"scheduled":2,"total":849,"15min":0.33,"1min":0.51,"5min":0.32}'},
{'value': '{"scheduled":2,"total":814,"15min":0.3,"1min":0.2,"5min":0.25}'},
{'value': '{"scheduled":2,"total":817,"15min":0.25,"1min":0.14,"5min":0.17}'},
{'value': '{"scheduled":2,"total":815,"15min":0.22,"1min":0.18,"5min":0.14}'}]

Any suggestion in how I can speed this up by avoiding to convert each
element to json by iterating on the query results?

I'm using psotgresql 9.3 with native json support, not sure if it is
relevant or not :)

-- 
Marc

-- 
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%2BDCN_vTbC0-yOt7cuToYLZSOD%2B%3DZCubLOjgkpu-MyB1VxbGMA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Templatetag variable resolution choices (Python literals)

2013-07-01 Thread Marc Kirkwood
OK, so I've got a template tag and a corresponding Node class. In order to 
check the value of two template variables in the Node.render method, I'm 
using the template.Variable class as specified in the docs. However, I'm 
wondering if there is any point to this, given the extra lines of code that 
are required to instantiate the class in the Node.__init__ method, then 
resolve each of the two variables within separate try-except blocks in case 
of a template.VariableDoesNotExist error. Given that both the variables are 
Python literals (boolean and list) and context.get('name', default) works 
as expected without the extra boilerplate, I'm wondering why it's not a 
documented way of doing this.

In summary, the following types of variable lookup give identical results 
when dealing with Python literals -- except that using the context directly 
removes the need for the try-except block and also eliminates the Django 
template.Variable checking code, which is redundant in this case:


class ExampleNode(template.Node):
def __init__(self):
self.a1 = template.Variable('a_variable')

def render(self, context):
try:
a1 = self.a1.resolve(context)
except template.VariableDoesNotExist:
a1 = False

a2 = context.get('a_variable', False)


I'll add once again that these variables are simply set in a view context 
as Python literals.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANNOUNCE: Django 1.6 beta 1 released

2013-06-28 Thread Marc Aymerich
On Fri, Jun 28, 2013 at 3:48 PM, Jacob Kaplan-Moss <ja...@jacobian.org> wrote:
> Hi folks --
>
> I'm pleased to announce that we've just released Django 1.6 beta 1,
> the second in our series of preview releases leading up to Django 1.6
> (due in August).
>
> More information can be found on our blog:
>
>
> https://www.djangoproject.com/weblog/2013/jun/28/django-16-beta-1-released/
>
> And in the release notes:
>
> https://docs.djangoproject.com/en/dev/releases/1.6/
>

Wow, lots of cool changes for the next release!
thank you guys for all the great effort !!


-- 
Marc

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Sending emails, models or views?

2013-06-19 Thread Marc Aymerich
Yep,
I'm more or less convinced that the logic needed for sending an email
should go into models. But what about the action (method call) of
sending the email? what layer should be responsible for triggering an
email notification? models or views? This is something I keep
wondering myself for a long time ...

for example, imagine we have a simple Ticket model with two methods,
update() and notify_owner()

class Ticket(models.Model):
def update(self):
self.updated_on = now()
self.save()

def notify_owner(self, msg):
send_mail(self.owner, msg)


now we want to notify the owner each time a Ticket is updated, shall
we include a self.notify_owner('updated!') call on the update()
method, so we make sure of that? or maybe it is better to do this on
the view each time ticket.update() is called?

There are some pros and cons,
In the views we have access to the request object which some times is
handy because we need some request info to include on the mail.
Including the call into the model we make sure that each time we will
send an email notification and DRY is good, but is this behavior
correct? maybe we only want to notify under certain circumstances...

So anyone has thought about this? any rule of thumb? maybe it totally
depends on the use case? does this question even make sense? :)

Thanks for your answers!
-- 
Marc

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Passing filter parameters to admin's add view

2013-05-26 Thread Marc R
Sorry, didn't read to the bottom of your post :)

Why would there be a better way than overriding the default template?  that 
is the most efficient way and the power of frameworks.

On Saturday, May 25, 2013 11:53:00 AM UTC-4, Branko Majic wrote:
>
> Hello all, 
>
> I've posted a similar question a couple of months ago, but received no 
> answer. I'm repeating the question now, but hopefully making it a bit 
> clearer on what I desire to achieve. 
>
> Is there any way to have the admin app pass the currently set filter 
> (GET prameters) to the "add view"? 
>
> For example, let's say that the following page is open: 
>
> http://localhost:8000/admin/conntrackt/entity/?project__id__exact=1 
>
> By default the page will contain the "Add item" link as: 
>
> http://localhost:8000/admin/conntrackt/entity/add/ 
>
> What I'm interested in doing would be to have this link instead as: 
>
> http://localhost:8000/admin/conntrackt/entity/add/?project__id__exact=1 
>
> The idea is to take advantage of the current filter in the list view in 
> admin in order to limit the foreign key fields when adding a new 
> entity. 
>
> I've already implemented this by overriding the admin's 
> change_list.html template, but I'd be a bit surprised that there isn't 
> a better way to perform this. 
>
> Best regards 
>
> -- 
> Branko Majic 
> Jabber: bra...@majic.rs  
> Please use only Free formats when sending attachments to me. 
>
> Бранко Мајић 
> Џабер: bra...@majic.rs  
> Молим вас да додатке шаљете искључиво у слободним форматима. 
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Passing filter parameters to admin's add view

2013-05-26 Thread Marc R
override the template and change it accordingly (you can grab djangos as a 
starting point).  Google for django admin template override.


On Saturday, May 25, 2013 11:53:00 AM UTC-4, Branko Majic wrote:
>
> Hello all, 
>
> I've posted a similar question a couple of months ago, but received no 
> answer. I'm repeating the question now, but hopefully making it a bit 
> clearer on what I desire to achieve. 
>
> Is there any way to have the admin app pass the currently set filter 
> (GET prameters) to the "add view"? 
>
> For example, let's say that the following page is open: 
>
> http://localhost:8000/admin/conntrackt/entity/?project__id__exact=1 
>
> By default the page will contain the "Add item" link as: 
>
> http://localhost:8000/admin/conntrackt/entity/add/ 
>
> What I'm interested in doing would be to have this link instead as: 
>
> http://localhost:8000/admin/conntrackt/entity/add/?project__id__exact=1 
>
> The idea is to take advantage of the current filter in the list view in 
> admin in order to limit the foreign key fields when adding a new 
> entity. 
>
> I've already implemented this by overriding the admin's 
> change_list.html template, but I'd be a bit surprised that there isn't 
> a better way to perform this. 
>
> Best regards 
>
> -- 
> Branko Majic 
> Jabber: bra...@majic.rs  
> Please use only Free formats when sending attachments to me. 
>
> Бранко Мајић 
> Џабер: bra...@majic.rs  
> Молим вас да додатке шаљете искључиво у слободним форматима. 
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Is there a way to tell an instance was saved without checking instalce.pk or doing a db lookup?

2013-05-26 Thread Marc R
What are you trying to accomplish?

I believe the doc's talk about this some; but in short,  you can only check 
the pk if its a new object; otherwise the pk would be set (if you retrieved 
the object from the database, or saved before).

I would assume (as i've not run into the issue yet) that on a save() to the 
object, if it fails you'll get an exceptions thrown.

On Saturday, May 25, 2013 4:01:29 PM UTC-4, Sergiy wrote:
>
> To check if the instance was saved one might do something like this:
>
> def is_instance_saved(instance):
> if instance.pk is None:
> return False
> # in case pk was set manually
> try:
> instance.__class__.objects.get(pk=instance.pk)
> except ObjectDoesNotExist:
> return False
> return True
>
> I wonder if the instance already knows whether it was saved or not 
> (through some sort of private attribute).
>
> Thanks
> Sergiy
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




another ifchanged question, triggers on first call, not what I want

2013-05-26 Thread Marc R
I'm trying to insert breaks when a row value in a specific column of data 
changes; however, it is triggering on the very first call to "ifchanged".

For example:

{% for row in report %}
{% ifchanged row.column2 %}  {% endifchanged %}
...print other data...
{% endfor %}
 
The very first line is a "" with the above sample.

Although technically the ifchanged, did change (from Null/None, to some 
value), I don't believe the assignment should count as an actual change.

Is there a way around this behaviour?

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Admin module - modify SQL Query used for Edit and Save Models

2013-05-03 Thread Marc
Thanks. I understood and that doesn't work for my project as python/django
can't handle the returned bytes I need to use.
my project requires that the values are stored using the result of
aes_encrypt from MySQL because other systems not made in python expect that
and cannot be changed at this stage.
On 2013-05-03 9:50 AM, "Shawn Milochik" <sh...@milochik.com> wrote:

> On Fri, May 3, 2013 at 8:37 AM, Marc <war...@gmail.com> wrote:
>
> So Tom: i can't use those methods Shawn pointed out?  What I was hoping I
>> can do is override the code that builds the SQL query.
>> Further looking I think thats correct; as I did get a module working I
>> found and played with which uses those methods and they don't seem to
>> manipulate the query that is built by django, just the value passed.
>>
>> What isn't obvious in the Doc's Shawn is what is passed into and what is
>> expected to be returned. The docs are not clear at all about that at all.
>>
>>
>>
>>
> Sorry for the confusion. To be clear, I am suggesting that you make your
> own Field subclass, instead of using, for example, a CharField or
> TextField. The third link in that e-mail gave a working example of one. It
> should be very easy. It doesn't change the SQL at all -- it converts
> automatically between the plain text and encrypted value using those two
> functions named in the docs.
>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/6BQxdM04Hi0/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Admin module - modify SQL Query used for Edit and Save Models

2013-05-03 Thread Marc
I really think django should add an easy way to override what django uses
to build the query for each Field and make it part of the Field settings,
for example:
models.CharField(override_sql_newupdate='AES_ENCRYPT(fieldname,key)',
override_sql_select='AES_DECRYPT(fieldname,key)',...

would be very handy as then you could use all sorts of the powerful
features in a DB.
I get that it may then make the use of an ORM less "useful", but it sure
would be easier than having to always due RAW sql calls on the object to
get the same result.


On Fri, May 3, 2013 at 8:37 AM, Marc <war...@gmail.com> wrote:

> So Tom: i can't use those methods Shawn pointed out?  What I was hoping I
> can do is override the code that builds the SQL query.
> Further looking I think thats correct; as I did get a module working I
> found and played with which uses those methods and they don't seem to
> manipulate the query that is built by django, just the value passed.
>
> What isn't obvious in the Doc's Shawn is what is passed into and what is
> expected to be returned. The docs are not clear at all about that at all.
>
>
>
> On Fri, May 3, 2013 at 8:12 AM, Tom Evans <tevans...@googlemail.com>wrote:
>
>> On Fri, May 3, 2013 at 12:46 PM, Shawn Milochik <sh...@milochik.com>
>> wrote:
>> >
>> https://docs.djangoproject.com/en/1.5/howto/custom-model-fields/#converting-database-values-to-python-objects
>> >
>> https://docs.djangoproject.com/en/1.5/howto/custom-model-fields/#converting-python-objects-to-query-values
>> >
>> > Have a look at these two methods of a custom field. You can pretty
>> easily
>> > make your own.
>> >
>> > You can use this as an example (see the EncryptedCharField class):
>> >
>> > http://djangosnippets.org/snippets/2489/
>> >
>>
>> This deals with decrypting in python an encrypted value retrieved from
>> the database (and vice-versa). The OP wants to decrypt the value in
>> the database, which afaict is not possible easily.
>>
>> Cheers
>>
>> Tom
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/6BQxdM04Hi0/unsubscribe?hl=en
>> .
>> To unsubscribe from this group and all its topics, 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Admin module - modify SQL Query used for Edit and Save Models

2013-05-03 Thread Marc
So Tom: i can't use those methods Shawn pointed out?  What I was hoping I
can do is override the code that builds the SQL query.
Further looking I think thats correct; as I did get a module working I
found and played with which uses those methods and they don't seem to
manipulate the query that is built by django, just the value passed.

What isn't obvious in the Doc's Shawn is what is passed into and what is
expected to be returned. The docs are not clear at all about that at all.


On Fri, May 3, 2013 at 8:12 AM, Tom Evans  wrote:

> On Fri, May 3, 2013 at 12:46 PM, Shawn Milochik 
> wrote:
> >
> https://docs.djangoproject.com/en/1.5/howto/custom-model-fields/#converting-database-values-to-python-objects
> >
> https://docs.djangoproject.com/en/1.5/howto/custom-model-fields/#converting-python-objects-to-query-values
> >
> > Have a look at these two methods of a custom field. You can pretty easily
> > make your own.
> >
> > You can use this as an example (see the EncryptedCharField class):
> >
> > http://djangosnippets.org/snippets/2489/
> >
>
> This deals with decrypting in python an encrypted value retrieved from
> the database (and vice-versa). The OP wants to decrypt the value in
> the database, which afaict is not possible easily.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/6BQxdM04Hi0/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Admin module - modify SQL Query used for Edit and Save Models

2013-05-03 Thread Marc
Thanks, i'll play with that and see what I can come up with.
Docs are good, but sometimes really hard to read/find what you need :)


On Fri, May 3, 2013 at 7:46 AM, Shawn Milochik  wrote:

>
> https://docs.djangoproject.com/en/1.5/howto/custom-model-fields/#converting-database-values-to-python-objects
>
> https://docs.djangoproject.com/en/1.5/howto/custom-model-fields/#converting-python-objects-to-query-values
>
> Have a look at these two methods of a custom field. You can pretty easily
> make your own.
>
> You can use this as an example (see the EncryptedCharField class):
>
> http://djangosnippets.org/snippets/2489/
>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/6BQxdM04Hi0/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Admin module - modify SQL Query used for Edit and Save Models

2013-05-03 Thread Marc R
Anyone? I would really like to know who I can modify the query as its being 
built so that for a specific field I can set the "field" to 
AES_DECRTYP(fieldname,key) on a select and AES_ENCRYPT(fieldname,key) on 
insert/update

On Sunday, 28 April 2013 20:21:48 UTC-4, Marc R wrote:
>
> I have a model where I have used AES_ENCRYPT(value, key) to save data in a 
> MySQL database.  It is set as a varbinary field.
>
> So the issue is; when trying to edit the model in Django, it does not 
> render a widget for the field.
>
> I've tried the aesfield from github but that does some funky thing with 
> HEX and tagging the type of encryption used.  Not what I want, as the 
> database already has 8300 records and other applications that access it 
> using queries like
> select field1, field2, AES_DECRYPT(field3, 'key') from ...
>
> So I can't change how the data is stored or I'll break the other 
> applications.
>
> How can I setup customer "SELECT' and "SAVE" (insert, update), queries for 
> a model in django?
> Or am I stuck creating my own form and processing and related CRUD 
> operations for this Model?
>
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Admin module - modify SQL Query used for Edit and Save Models

2013-04-28 Thread Marc R
I have a model where I have used AES_ENCRYPT(value, key) to save data in a 
MySQL database.  It is set as a varbinary field.

So the issue is; when trying to edit the model in Django, it does not 
render a widget for the field.

I've tried the aesfield from github but that does some funky thing with HEX 
and tagging the type of encryption used.  Not what I want, as the database 
already has 8300 records and other applications that access it using 
queries like
select field1, field2, AES_DECRYPT(field3, 'key') from ...

So I can't change how the data is stored or I'll break the other 
applications.

How can I setup customer "SELECT' and "SAVE" (insert, update), queries for 
a model in django?
Or am I stuck creating my own form and processing and related CRUD 
operations for this Model?

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ManyToMany relationship and raw sql queries

2013-04-27 Thread Marc R
did you use Bookmark.objetcs.all().select_related() ?

As this will create a join query... at least for your model you show in the 
message I have found that for very complex joins, you need to use raw 
query and not a Model.

On Thursday, April 25, 2013 10:44:28 AM UTC-4, Matthieu Bouron wrote:
>
> On Thursday, April 11, 2013 5:39:57 PM UTC+2, Tom Evans wrote:
>>
>> On Thu, Apr 11, 2013 at 3:42 PM, Matthieu Bouron 
>>  wrote: 
>> > Hello, 
>> > 
>> > Is there a way to handle many-to-many relationship with raw sql queries 
>> ? 
>> > I have the following model: 
>> > 
>> > from django.db import models 
>> > 
>> > class Tag(models.Model): 
>> > name = models.CharField(max_length=512, unique=True) 
>> > 
>> > class Bookmark(models.Model): 
>> > link = models.CharField(max_length=512) 
>> > title = models.CharField(max_length=512) 
>> > tags = models.ManyToManyField(Tag) 
>> > added_at = models.DateField() 
>> > 
>> > Using Bookmark.objetcs.all() will result in a subquery for each row of 
>> the 
>> > bookmark table which is not acceptable for performance reasons. 
>> > First question is there a way to fetch all the content with a single 
>> query ? 
>> > Second question is it possible to use raw sql queries. I tried the 
>> > following: 
>> > 
>> > bookmarks = Bookmark.objects.raw( 
>> > 'SELECT * FROM bookmarkmanager_bookmark b ' 
>> > 'LEFT JOIN bookmarkmanager_bookmark_tags bt ON (
>> b.id = 
>> > bt.bookmark_id) ' 
>> > 'LEFT JOIN bookmarkmanager_tag t ON (bt.tag_id = 
>> t.id)' 
>> > ) 
>> > 
>> > But when i tried to access the tags attribute on a bookmark i get the 
>> > following exception: 
>> > 
>> > ValueError: "" needs to have a value for 
>> field 
>> > "bookmark" before this many-to-many relationship can be used. 
>> > 
>> > Thanks in advance, 
>> > Matthieu 
>> > 
>>
>> Are you tied to raw SQL queries? Django itself supports traversing M2M 
>> relationships in a sane manner if you tell it to do so: 
>>
>>
>> https://docs.djangoproject.com/en/1.5/ref/models/querysets/#prefetch-related 
>>
>
> Thanks.
> Another problem remains ... performances are horrible even if i use 
> values().
> I have 1000 rows in base, executing from a script (db sqlite):
>   - 800ms to fetch all the objects (traversing m2m with prefetch_related).
>   - 200ms to fetch all the row from bookmark table without traversing the 
> m2m relationship).
>
> Are my results expected ?
> Are there any plan on improving django orm performance ?
>
> Matthieu
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django Admin - BooleanField issue

2013-04-27 Thread Marc R
That seems to have worked... I used 1 and 0 as the database is set for a 
tinyint to store the value (so needs to be 1 or 0).  That said, 
django/python seems to figure that out when saving the value.

Thanks; wouldn't have thought to try that.

On Saturday, 27 April 2013 14:46:14 UTC-4, Andrew Boltachev wrote:
>
> Hi. May be you need
>
> active = models.BooleanField(choices=((True,'yes'),(False,'no')))
>
> ?
>
> - With regards, Andrei
>
>
> 2013/4/27 Marc R <war...@gmail.com >
>
>> I've setup a boolean field and get it to display correctly using this in 
>> my model:
>> active = models.BooleanField(choices=((1,'yes'),(0,'no')))
>>
>> However, when I edit a record in the Django Admin, the select field 
>> always shows "yes" regardless of the database value.
>>
>> Saving "yes" or "no" stores the correct 1 or 0; is there a bug in the 
>> edit form?  Or did I miss a setting?
>>
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django Admin - BooleanField issue

2013-04-27 Thread Marc R
I've setup a boolean field and get it to display correctly using this in my 
model:
active = models.BooleanField(choices=((1,'yes'),(0,'no')))

However, when I edit a record in the Django Admin, the select field always 
shows "yes" regardless of the database value.

Saving "yes" or "no" stores the correct 1 or 0; is there a bug in the edit 
form?  Or did I miss a setting?

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django inline formsets, force initial data to be saved.

2013-03-05 Thread Marc Aymerich
On Tue, Mar 5, 2013 at 4:43 PM, Marc Aymerich <glicer...@gmail.com> wrote:

>
>
> On Tue, Mar 5, 2013 at 3:11 AM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
>
>>
>>
>> On Mon, Mar 4, 2013 at 10:31 PM, Marc Aymerich <glicer...@gmail.com>wrote:
>>
>>> Hi,
>>> I've spend several hours trying to figure out how to save inlines with
>>> initial data in them.
>>>
>>> basically I have a very simple model with 2 fields:
>>>
>>> class DirectIface(models.Model):
>>> parent = models.ForeignKey('nodes.Node')
>>> name = models.CharField(max_lenght=64)
>>>
>>> And what I'm doing is defining a formset with initial data in it:
>>>
>>>  class DirectIfaceInlineFormSet(BaseInlineFormSet):
>>> def __init__(self, *args, **kwargs):
>>> kwargs['initial'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
>>> super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)
>>>
>>>
>>> In this case 2 Direct ifaces with names eth1 and eth2.
>>>
>>> The problem is that those ifaces doesn't get stored when I hit the save
>>> button, that's because has_changed == False.
>>> So is there a way to tell Django to save formsets with only initial data
>>> ?
>>>
>>
>> Sure - just provide the initial data as actual data. If, instead of using
>> 'initial', you pass the same content as 'data', the form will be saveable.
>>
>
> Jops, just tried
>
>
> class DirectIfaceInlineFormSet(BaseInlineFormSet):
> def __init__(self, *args, **kwargs):
> kwargs['data'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
> super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)
>
> but I'm getting an AttributeError "'list' object has no attribute 'get'"
> when i'm rendering the form.
>


yeah, finally I did something like

class DirectIfaceInlineFormSet(BaseInlineFormSet):
def __init__(self, *args, **kwargs):
if not kwargs['instance'].pk:
kwargs['data'] = {
'direct_ifaces-TOTAL_FORMS': u'3',
'direct_ifaces-INITIAL_FORMS': u'0',
'direct_ifaces-MAX_NUM_FORMS': u'',
'direct_ifaces-0-name': u'eth0',
'direct_ifaces-1-name': u'eth1',
'direct_ifaces-2-name': u'eth2',}
else:
self.extra = 1
super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)

that it works :)




-- 
Marc

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django inline formsets, force initial data to be saved.

2013-03-05 Thread Marc Aymerich
On Tue, Mar 5, 2013 at 3:11 AM, Russell Keith-Magee <russ...@keith-magee.com
> wrote:

>
>
> On Mon, Mar 4, 2013 at 10:31 PM, Marc Aymerich <glicer...@gmail.com>wrote:
>
>> Hi,
>> I've spend several hours trying to figure out how to save inlines with
>> initial data in them.
>>
>> basically I have a very simple model with 2 fields:
>>
>> class DirectIface(models.Model):
>> parent = models.ForeignKey('nodes.Node')
>> name = models.CharField(max_lenght=64)
>>
>> And what I'm doing is defining a formset with initial data in it:
>>
>>  class DirectIfaceInlineFormSet(BaseInlineFormSet):
>> def __init__(self, *args, **kwargs):
>> kwargs['initial'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
>> super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)
>>
>>
>> In this case 2 Direct ifaces with names eth1 and eth2.
>>
>> The problem is that those ifaces doesn't get stored when I hit the save
>> button, that's because has_changed == False.
>> So is there a way to tell Django to save formsets with only initial data ?
>>
>
> Sure - just provide the initial data as actual data. If, instead of using
> 'initial', you pass the same content as 'data', the form will be saveable.
>

Jops, just tried

class DirectIfaceInlineFormSet(BaseInlineFormSet):
def __init__(self, *args, **kwargs):
kwargs['data'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)

but I'm getting an AttributeError "'list' object has no attribute 'get'"
when i'm rendering the form.

http://dpaste.com/1013099/

What i've missed ?
Thanks again !




-- 
Marc

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django inline formsets, force initial data to be saved.

2013-03-05 Thread Marc Aymerich
On Tue, Mar 5, 2013 at 3:11 AM, Russell Keith-Magee <russ...@keith-magee.com
> wrote:

>
>
> On Mon, Mar 4, 2013 at 10:31 PM, Marc Aymerich <glicer...@gmail.com>wrote:
>
>> Hi,
>> I've spend several hours trying to figure out how to save inlines with
>> initial data in them.
>>
>> basically I have a very simple model with 2 fields:
>>
>> class DirectIface(models.Model):
>> parent = models.ForeignKey('nodes.Node')
>> name = models.CharField(max_lenght=64)
>>
>> And what I'm doing is defining a formset with initial data in it:
>>
>>  class DirectIfaceInlineFormSet(BaseInlineFormSet):
>> def __init__(self, *args, **kwargs):
>> kwargs['initial'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
>> super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)
>>
>>
>> In this case 2 Direct ifaces with names eth1 and eth2.
>>
>> The problem is that those ifaces doesn't get stored when I hit the save
>> button, that's because has_changed == False.
>> So is there a way to tell Django to save formsets with only initial data ?
>>
>
> Sure - just provide the initial data as actual data. If, instead of using
> 'initial', you pass the same content as 'data', the form will be saveable.
>

Thank you Russ, you've saved my day ! :)




-- 
Marc

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django inline formsets, force initial data to be saved.

2013-03-04 Thread Marc Aymerich
Hi,
I've spend several hours trying to figure out how to save inlines with
initial data in them.

basically I have a very simple model with 2 fields:

class DirectIface(models.Model):
parent = models.ForeignKey('nodes.Node')
name = models.CharField(max_lenght=64)

And what I'm doing is defining a formset with initial data in it:

class DirectIfaceInlineFormSet(BaseInlineFormSet):
def __init__(self, *args, **kwargs):
kwargs['initial'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)


In this case 2 Direct ifaces with names eth1 and eth2.

The problem is that those ifaces doesn't get stored when I hit the save
button, that's because has_changed == False.
So is there a way to tell Django to save formsets with only initial data ?

Thanks !

-- 
Marc

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: FastCGI Recipe for shared hosting

2013-03-03 Thread Marc Aymerich
On Sun, Mar 3, 2013 at 5:33 PM, Tim Johnson <t...@akwebsoft.com> wrote:

> * Tim Johnson <t...@akwebsoft.com> [130302 14:30]:
> > * Tom Evans <tevans...@googlemail.com> [130301 06:44]:
> > > Apache httpd with mod_fastcgi:
> > >
> > > RewriteCond %{REQUEST_URI} !^/media
> > > RewriteCond %{REQUEST_URI} !^/
> > > # repeat for any other directories you want httpd to serve
> > > RewriteRule ^/(.*)$ /app.fcgi/$1 [QSA,L]
> > > FastCGIExternalServer /path/to/your/htdocs/app.fcgi -socket
> > > /path/to/your/webapp/run/app.socket
> > The following :
> > ##
> > RewriteCond %{REQUEST_URI} !^/media
> > RewriteCond %{REQUEST_URI} !^/
> > RewriteRule ^/(.*)$ /app.fcgi/$1 [QSA,L]
> > FastCGIExternalServer app.fcgi -socket app.socket
> > ##
> > When applied to http://www.lyxx.com/freestuff/002.html (htaccess
> > validator) generates an error on the last line.
> >
> > Tom are you using the FastCGIExternalServer in .htaccess or in
> > httpd.conf?
> >
>  Bear in mind that I do not have access to httpd.conf on this shared
>  ---
>  hoster and in
>  https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/ I
>  read wherre FastCGIExternalServer is referred to as an addition to
>  httpd.conf.
>
>   Clearly, a red herring, and clearly django could do better with
>   documentation and support for shared servers.
>   (very frustrated) Drupal makes it so easy! No excuses now,
>   with the talent in the django, it is doable.
>   I may check back in a few days after I cool down, in the meantime,
>   I know how to integrate my python own framework with drupal.


https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache


-- 
Marc

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django Shopping Cart

2013-02-27 Thread Marc Aymerich
On Wed, Feb 27, 2013 at 10:02 PM, vijay shanker <deont...@gmail.com> wrote:

> hey, i want to write a shopping cart app, please provide some inputs,
> useful information, suggestions etc for doing it right .
> thanks
>


have you looked at django-oscar?

-- 
Marc

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Automating deployments

2013-02-01 Thread Marc Aymerich
Hi,
I'm thinking about the best way to provide automatic deployment for
the Django project I'm working on. Its a pretty big one and has lots
of dependencies, lots of SO packages, Celeryd and other daemons, SO
tweaks... and also several people will need to have installed it on
their servers (they are sysadmins, not Django developers), Therefore I
want to automate as much as possible the installation and updating
processes, to minimize their pain and also because of having
homogeneity.

As I've been a sysadmin myself for many years I've already written
some bash scripts that automates all the deployment. But in order to
make it more 'natural' I'm planning to integrate those scripts within
the Django project as management commands.

To illustrate my ultimate goal this is how I imagine the workflow:

sudo pip install django-my_project
my_project-admin.sh clone project_name path

sudo python manage.py installrequirements
sudo python manage.py setuppostgres
python manage.py syncdb
python manage.py migrate
python manage.py createsuperuser

sudo python manage.py setupapache
python manage.py collectstatic
sudo python manage.py setupceleryd
sudo python manage.py createtincserver
python manage.py updatetincd
sudo python manage.py setupfirmware
python manage.py loaddata firmwareconfig

sudo python manage.py restartservices


Any thought on this? How do you automate your deployments? I heard
about fabric lots of times but never used it. Will fabric be helpful
in my case? Does it has any advantage for writing my own scripts? Or
maybe there are already some existing tools for automating deployment
of most common services like Apache, celeryd ..,?

Many thanks!
br
-- 
Marc

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Implementing a monitoring system with django.

2012-12-14 Thread Marc Aymerich
On Wed, Dec 12, 2012 at 12:23 PM, Tom Evans <tevans...@googlemail.com> wrote:
> On Mon, Dec 10, 2012 at 7:41 PM, Marc Aymerich <glicer...@gmail.com> wrote:
>> Hi,
>> I'm considering to implement a simple monitorization system that
>> basically gathers some data from a set of nodes (<1000 nodes). The
>> gathered data should be stored in order to let users perform some
>> queries and maybe also generate some graphs.
>>
>> I'm looking for advice in what components are best suited for each of
>> the following parts:
>>
>> 1) Storage: maybe something nonsql like MongoDB? or perhaps RRD?
>> 2) Data gathering: celery periodic tasks?
>> 3) Graphs: rrd? or some java script framework for graphing?
>>
>> thanks for your comments!!
>
> Any reason not to use something like Nagios or Cacti? We use Nagios at
> $JOB, it's great.
>

Hi Tom,
We already have developed a web interface for controlling those nodes
in Django, so I think that it would be easy to run our own monitoring
system than integrate Nagios into our existing interface.


-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Implementing a monitoring system with django.

2012-12-13 Thread Marc Aymerich
On Wed, Dec 12, 2012 at 7:59 AM, ephan <epha...@gmail.com> wrote:
> Depending on what you need for the graphs,have a look at flot,jqplot or
> rapheal.js(heavy).There is also high charts althought there are some
> licensing issues you may want to avoid.
>
> If you get stuck with the charts,let me know..am running some.

Thanks Ephan,
those graphs looks really nice! I'm looking into them.

> On Tuesday, December 11, 2012 11:09:06 PM UTC+2, Marc Aymerich wrote:
>>
>> On Tue, Dec 11, 2012 at 4:32 PM, Bill Freeman <ke1...@gmail.com> wrote:
>> >
>> >
>> > On Mon, Dec 10, 2012 at 2:41 PM, Marc Aymerich <glic...@gmail.com>
>> > wrote:
>> >>
>> >> Hi,
>> >> I'm considering to implement a simple monitorization system that
>> >> basically gathers some data from a set of nodes (<1000 nodes). The
>> >> gathered data should be stored in order to let users perform some
>> >> queries and maybe also generate some graphs.
>> >>
>> >> I'm looking for advice in what components are best suited for each of
>> >> the following parts:
>> >>
>> >> 1) Storage: maybe something nonsql like MongoDB? or perhaps RRD?
>> >> 2) Data gathering: celery periodic tasks?
>> >> 3) Graphs: rrd? or some java script framework for graphing?
>> >>
>> >> thanks for your comments!!
>> >
>> >
>> > While this may be a fine opportunity to learn about some of these
>> > techniques
>> > (NoSQL, celery), unless I misunderstand the potential bandwidths
>> > involved,
>> > the problem fits more pedestrian stuff pretty well.
>> >
>> > If I were doing this I'd use PostgreSQL and a cron (or equivalent on
>> > your
>> > OS) triggered django management command to gather the data and stuff it
>> > into
>> > the models.  Certainly django can provide display of the data to the
>> > user.
>> >
>> > For graphing, I've used YUI (yahoo) tools in the past (I'm sure that
>> > google
>> > has competitive offerings), but it required that the user have Flash.
>> > While
>> > pretty much everyone has Flash, I'd rather go for HTML5 or SVG (and a
>> > few
>> > people may have browsers that don't do these).  Maybe modern frameworks
>> > can
>> > be had that detect the browser's capabilities and respond accordingly.
>> > (The
>> > YUI stuff was driven by a table of data in the DOM, and that approach
>> > allows
>> > the support decision to be deferred to the browser side.)  Depending on
>> > load
>> > and update rate, you could also generate png or jpg files on the fly in
>> > a
>> > view that IMG tags in your HTML refer to, which works even if the user
>> > has
>> > javascript disabled, but loads the server a bit.  You would probably
>> > want to
>> > encode a timestamp or generation sequence into the generated image path
>> > name, so that you wouldn't have to worry about cacheing, including in
>> > the
>> > browser, keeping you from showing a fresh image when the user refreshes
>> > the
>> > page.
>> >
>>
>> Hi bill thanks for your feedback!
>> You're right, maybe I can start using a traditional RDBMS like
>> postgres and switch when things starts getting slow, if even it really
>> happens at all.
>>
>> By the way, I've been looked at some nosql storage backends, and
>> couchdb seems the more appropriate option for storing time-series data
>> in django.
>>
>> regarding the graph stuff, the project is somehow related with
>> opensource and openeverything, so flash is not really an option. I'll
>> look at some js framework.
>>
>> thanks again!
>> --
>> Marc
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/pxDyxFeEwBoJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Implementing a monitoring system with django.

2012-12-11 Thread Marc Aymerich
On Tue, Dec 11, 2012 at 4:32 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>
>
> On Mon, Dec 10, 2012 at 2:41 PM, Marc Aymerich <glicer...@gmail.com> wrote:
>>
>> Hi,
>> I'm considering to implement a simple monitorization system that
>> basically gathers some data from a set of nodes (<1000 nodes). The
>> gathered data should be stored in order to let users perform some
>> queries and maybe also generate some graphs.
>>
>> I'm looking for advice in what components are best suited for each of
>> the following parts:
>>
>> 1) Storage: maybe something nonsql like MongoDB? or perhaps RRD?
>> 2) Data gathering: celery periodic tasks?
>> 3) Graphs: rrd? or some java script framework for graphing?
>>
>> thanks for your comments!!
>
>
> While this may be a fine opportunity to learn about some of these techniques
> (NoSQL, celery), unless I misunderstand the potential bandwidths involved,
> the problem fits more pedestrian stuff pretty well.
>
> If I were doing this I'd use PostgreSQL and a cron (or equivalent on your
> OS) triggered django management command to gather the data and stuff it into
> the models.  Certainly django can provide display of the data to the user.
>
> For graphing, I've used YUI (yahoo) tools in the past (I'm sure that google
> has competitive offerings), but it required that the user have Flash.  While
> pretty much everyone has Flash, I'd rather go for HTML5 or SVG (and a few
> people may have browsers that don't do these).  Maybe modern frameworks can
> be had that detect the browser's capabilities and respond accordingly.  (The
> YUI stuff was driven by a table of data in the DOM, and that approach allows
> the support decision to be deferred to the browser side.)  Depending on load
> and update rate, you could also generate png or jpg files on the fly in a
> view that IMG tags in your HTML refer to, which works even if the user has
> javascript disabled, but loads the server a bit.  You would probably want to
> encode a timestamp or generation sequence into the generated image path
> name, so that you wouldn't have to worry about cacheing, including in the
> browser, keeping you from showing a fresh image when the user refreshes the
> page.
>

Hi bill thanks for your feedback!
You're right, maybe I can start using a traditional RDBMS like
postgres and switch when things starts getting slow, if even it really
happens at all.

By the way, I've been looked at some nosql storage backends, and
couchdb seems the more appropriate option for storing time-series data
in django.

regarding the graph stuff, the project is somehow related with
opensource and openeverything, so flash is not really an option. I'll
look at some js framework.

thanks again!
-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Implementing a monitoring system with django.

2012-12-10 Thread Marc Aymerich
Hi,
I'm considering to implement a simple monitorization system that
basically gathers some data from a set of nodes (<1000 nodes). The
gathered data should be stored in order to let users perform some
queries and maybe also generate some graphs.

I'm looking for advice in what components are best suited for each of
the following parts:

1) Storage: maybe something nonsql like MongoDB? or perhaps RRD?
2) Data gathering: celery periodic tasks?
3) Graphs: rrd? or some java script framework for graphing?

thanks for your comments!!
-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is there a recommended pattern for creating "replaceable" apps?

2012-11-20 Thread Marc Aymerich
On Tue, Nov 20, 2012 at 4:35 AM, Russell Keith-Magee
<russ...@keith-magee.com> wrote:
>
> On Tue, Nov 20, 2012 at 6:28 AM, Chris Cogdon <ch...@cogdon.org> wrote:
>>
>> Hi folks!
>>
>> I'm creating an application to manage an art show (with art pieces to view
>> and sell, silent and voice auctions, and a sales process). To have this
>> work, it of course needs to keep track of people (including names,
>> addresses, email, etc). But to make this more useful to anyone, I want to
>> include the ability to replace the included "Person" model with another,
>> should the implementor so choose.
>>
>> What I've done so far is to split the Person model into another app
>> (called Peeps) and removed all but a few necessary linkages between the
>> Artshow and Peeps app. It was reasonably simple, but a few things seem
>> "dirty" so I'm wondering if anyone else has a more experienced or
>> authoritative suggestion for this.
>
>
> Ok… so… In Django 1.5, yes there is… unofficially.
>
> Now - I must stress -- everything I'm about to say is 100% undocumented, and
> 100% experimental. If it breaks, you get to keep all the shiny pieces :-)
> I'm only mentioning it because I (personally) need people to experiment in
> this space in order to prove to the core team that the feature is safe for
> public consumption.
>
> With that caveat in place:
>
> In Django 1.5 (i.e., the current development branch), we've added the
> ability to add swappable User models. This means you can replace Django's
> builtin User model with any User model you want -- for example, a user model
> that uses 'email' as the unique identifier, or one that captures API
> credentials rather than first and last name.
>
> The dirty secret is that when I implemented this feature for contrib.auth, I
> did so in a way that was completely independent of the User model itself.
> There aren't any explicit references to contrib.auth in the main model code
> that makes swappable User models possible. In theory *any* model can be
> declared as swappable, which will allow the end user to define that in their
> project the "X" model will be performed by model "Y", and any foreign keys
> will be re-routed appropriately.
>
> The magic sauce: On the model you want to be swappable (Person, in your
> case), add a Meta declaration:
>
> class Person(Model):
> class Meta:
> swappable = 'CUSTOM_PERSON_MODEL'

wow, I'm also taking notes of this :)

-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Better feedback for admin users

2012-10-17 Thread Marc Aymerich
On Wed, Oct 17, 2012 at 12:21 AM, Daniele Procida <dani...@vurt.org> wrote:
> I am starting to customise the admin classes for my models so that I can 
> provide extra feedback to the user.
>
> For example I want to report - in the admin page - useful information about 
> how the system will interpret the current state of the object being edited.
>
> I'm doing this by using readonly_fields, that contain the output of method on 
> the ModelAdmin class, a bit like this:
>
> class PersonAdmin(ModelAdmin):
> readonly_fields = ['check_address',]
>
> def check_address(self, instance):
> return instance.get_full_address or " class='errors'>Warning: I am unable to work out an address for this 
> person."
>
> (the actual examples are rather more complex, but this is the idea).
>
> Does a more elegant way of doing this exist, either in Django's core already, 
> or using some package that makes it easier?
>

don't know for a best way, but for me the one you're describing its
actually a good workaround that maybe I'll use :)
thanks for sharing !
-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django with Jquery

2012-10-11 Thread Marc Kirkwood
I'm having this problem at the moment too. In our case, it's because we 
have a base template that inserts the jQuery library via a script tag 
towards the end of the document, just before the close of the body element. 
Since anything following a $ character in JS depends on jQuery, including 
the $(document).ready function call itself, we can't do anything with 
jQuery in a child template because the browser only includes the jQuery 
library when it receives it from the server. A possible solution is simply 
to move the 

Re: Autoescape of & char ignoring safe filter

2012-10-03 Thread Marc Serra
I've checked the database contents with sqliteman and the ampersands are 
ok, not escaped. Also i've checked the value retrieved of the database with 
a custom template tag and logging the value just before sending it to 
template, just before sending the data to the template it's correct. 
Finally checked again with shell and it's showing on console the expected 
output, all seems ok until the result is processed on the template.

On your second remark, i'm sorry but i'm quite new on django i'm not sure 
how to check the pipeline process, I'll put here the variables on settings 
I think can alter the functionality of django:

 MIDDLEWARE_CLASSES = (

'django.middleware.common.CommonMiddleware',

'django.contrib.sessions.middleware.SessionMiddleware',

'django.middleware.csrf.CsrfViewMiddleware',

'django.contrib.auth.middleware.AuthenticationMiddleware',

'django.contrib.messages.middleware.MessageMiddleware',

# Uncomment the next line for simple clickjacking protection:

# 'django.middleware.clickjacking.XFrameOptionsMiddleware',

)

TEMPLATE_CONTEXT_PROCESSORS = (

'django.contrib.auth.context_processors.auth',

'django.core.context_processors.i18n',

'django.core.context_processors.request',

'django.core.context_processors.media',

'django.core.context_processors.static',

)

I've tried disabling all TEMPLATE_CONTEXT_PROCESSORS (except auth, needed 
by admin interface) and MIDDLEWARE_CLASSES with no success.

Can you point me something else I can or should check?

Regards,
Marc Serra


El dijous 4 d’octubre de 2012 1:28:23 UTC+2, Russell Keith-Magee va 
escriure:
>
> On Thu, Oct 4, 2012 at 1:17 AM, Marc Serra <mad...@gmail.com > 
> wrote: 
> > Laxmikant I think you didn't understand my point. I don't want it 
> escaped, 
> > and escape marks it for escaping. I want to output the contents of 
> database 
> > RAW, without escaping. Safe filter does this but I found the weird 
> exception 
> > of &, what messes with urls with parameters on them. 
>
> Are you *absolutely* certain that the database contains & and not 
> ? How are you verifying that this is what the database contains? 
> The reason I ask is that |safe is essentially a call to Django that 
> says "don't do anything", so I don't see how the behaviour you 
> describe could be caused. 
>
> Also - are you sure that there isn't anything else in your pipeline 
> between the database and your display? If part of the content is being 
> transformed, it has all the hallmarks of something being double 
> handled. 
>
> Yours, 
> Russ Magee %-) 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/a4AocuofZF8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Autoescape of & char ignoring safe filter

2012-10-03 Thread Marc Serra
Laxmikant I think you didn't understand my point. I don't want it escaped, 
and escape marks it for escaping. I want to output the contents of database 
RAW, without escaping. Safe filter does this but I found the weird 
exception of &, what messes with urls with parameters on them.

Regards,
Marc Serra

El dimecres 3 d’octubre de 2012 6:25:38 UTC+2, Laxmikant Gurnalkar va 
escriure:
>
> >>>I have not used *safe*  ever. But use *escape* this works for me.
>
> On Wed, Oct 3, 2012 at 9:54 AM, Laxmikant Gurnalkar <
> laxmikant...@gmail.com > wrote:
>
>> Hi, 
>> I have not used *sace*  ever. But use *escape* this works for me.
>> https://docs.djangoproject.com/en/1.0/ref/templates/builtins/#escape
>>
>> Cheers
>> *Laxmikant G.*
>>
>>
>>
>> On Wed, Oct 3, 2012 at 4:06 AM, Marc Serra <mad...@gmail.com
>> > wrote:
>>
>>> Hi, i'm trying to output raw html content form the database on the 
>>> website, so i use the safe filter on the variable. All html code is 
>>> displayed correctly except the ampersand that are escaped ignoring the safe 
>>> filter, or It seems to me.
>>>
>>> I also tried to use a templatetag  with the mark_safe function with the 
>>> same outcome.
>>>
>>> Here an example:
>>>
>>> Source in database:
>>>
>>> >> value="http://www.youtube.com/v/Uq8zzBW9hlc=en=1=1;>>> name="allowFullScreen" value="true">>> value="always">>> src="http://www.youtube.com/v/Uq8zzBW9hlc=en=1=1; 
>>> type="application/x-shockwave-flash" allowscriptaccess="always" 
>>> allowfullscreen="true" width="560" height="340">
>>>
>>> On template with |safe filter (notice "&" replacement with ""):
>>>
>>> >> value="http://www.youtube.com/v/Uq8zzBW9hlchl=enfs=1hd=1 
>>> <http://www.youtube.com/v/Uq8zzBW9hlc=en=1=1>">>> name="allowFullScreen" value="true">>> value="always">>> src="http://www.youtube.com/v/Uq8zzBW9hlchl=enfs=1hd=1 
>>> <http://www.youtube.com/v/Uq8zzBW9hlc=en=1=1>" 
>>> type="application/x-shockwave-flash" allowscriptaccess="always" 
>>> allowfullscreen="true" height="340" width="560">
>>>
>>>
>>> You know what can be the reason to this behaviour and how to solve it?
>>>
>>> Thank you,
>>> Marc Serra
>>>
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/django-users/-/M3FV3yY7JnoJ.
>>> To post to this group, send email to django...@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to 
>>> django-users...@googlegroups.com .
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>>
>> -- 
>> * 
>>
>>  GlxGuru
>>
>> *
>>
>
>
>
> -- 
> * 
>
>  GlxGuru
>
> *
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Yau7wHup5JoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Autoescape of & char ignoring safe filter

2012-10-02 Thread Marc Serra
Hi, i'm trying to output raw html content form the database on the website, 
so i use the safe filter on the variable. All html code is displayed 
correctly except the ampersand that are escaped ignoring the safe filter, 
or It seems to me.

I also tried to use a templatetag  with the mark_safe function with the 
same outcome.

Here an example:

Source in database:

http://www.youtube.com/v/Uq8zzBW9hlc=en=1=1;>http://www.youtube.com/v/Uq8zzBW9hlc=en=1=1; 
type="application/x-shockwave-flash" allowscriptaccess="always" 
allowfullscreen="true" width="560" height="340">

On template with |safe filter (notice "&" replacement with ""):

http://www.youtube.com/v/Uq8zzBW9hlchl=enfs=1hd=1;>http://www.youtube.com/v/Uq8zzBW9hlchl=enfs=1hd=1; 
type="application/x-shockwave-flash" allowscriptaccess="always" 
allowfullscreen="true" height="340" width="560">

You know what can be the reason to this behaviour and how to solve it?

Thank you,
Marc Serra


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/M3FV3yY7JnoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: settings and constants on a reusable app

2012-06-29 Thread Marc Aymerich
On Fri, Jun 29, 2012 at 11:08 AM, Thomas Rega <t...@pyt3ch.com> wrote:
> Am 28.06.12 17:30, schrieb Marc Aymerich:
>
>> Hi,
>> I'm developing a reusable application and I'm having troubles with
>> constant values on settings.
>>
>> Imagine that the reusable application comes with the following settings.py
>>
>> # MY_APP/settings.py
>> from django.conf import settings
>> MY_CONSTANT = 'C1'
>> MY_OTHER_CONSTANT =  'C2'
>> MY_SETTING = getattr(settings, 'MY_SETTING', CONSTANT)
>>
>>
>> But for your project you want to override the default value of
>> MY_SETTING by MY_OTHER_CONSTANT. So you edit your project settings.py
>> and adds these two lines:
>>
>> # Project settings.py
>> 
>> from MY_APP.settings import settings as my_app_settings
>> MY_SETTING = my_app_settings.MY_OTHER_SETTING
>>
>>
>> But this is going to fail because of the import order.
>>
>> Is there any consistent way to handle this situation?
>>
>> Thanks!
>
> Hi,
>
> what about the idea to overwrite these values via a 'local_settings.py'
> file?
>
> An example can be found here:
> https://bitbucket.org/chris1610/satchmo/src/1255b19295c7/satchmo/projects/skeleton/settings.py

Hi thomas, thanks :)

Yeah, actually I'm using a local_settings.py file, but at the end it
will be the same as using settings.py since local_settings.py is
imported by settings.py. :(


-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



settings and constants on a reusable app

2012-06-28 Thread Marc Aymerich
Hi,
I'm developing a reusable application and I'm having troubles with
constant values on settings.

Imagine that the reusable application comes with the following settings.py

# MY_APP/settings.py
from django.conf import settings
MY_CONSTANT = 'C1'
MY_OTHER_CONSTANT =  'C2'
MY_SETTING = getattr(settings, 'MY_SETTING', CONSTANT)


But for your project you want to override the default value of
MY_SETTING by MY_OTHER_CONSTANT. So you edit your project settings.py
and adds these two lines:

# Project settings.py

from MY_APP.settings import settings as my_app_settings
MY_SETTING = my_app_settings.MY_OTHER_SETTING


But this is going to fail because of the import order.

Is there any consistent way to handle this situation?

Thanks!
-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Use Django to implement my GUI!

2012-05-19 Thread Marc Aymerich
On Sat, May 19, 2012 at 8:01 PM, Eugène Ngontang <sympav...@gmail.com> wrote:
> Hi Jani.
> I don't know why you say
>
> " 3) Are you now trying to figure out how to plug in Django in "Adming
> module/PC with GUI block"?"
>
> My admin module and the gui do not share anything. They are not on the same
> pc.
> Gui is for displaying and admin for the page content management like any web
> aplication works.
>
> I please us unot to build a myster arround this thread. The problem was
> simple:


HI Eugène,
the problem was simple, but all we have misunderstood you because
usually the term GUI is used to refer "desktop application" rather
than a web page, which seems to be the case.

br
-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Process Related Object when Saving

2012-05-17 Thread Marc Aymerich
On Wed, May 16, 2012 at 7:15 AM, ghachey <ghac...@gmail.com> wrote:
> Hi again;
>
> Looking at the source code I realised that form.save_m2m() must be
> called.
>
> def save_related(self, request, form, formsets, change):
>
>        form.save_m2m()
>        for formset in formsets:
>            self.save_formset(request, form, formset, change=change)
>
>        if not change:
>            # Generate and send report only if creating for first time
> (insert)
>            parent_obj = form.instance
>            generate_pdf(parent_obj)
>
> I think the above does what I wanted; so far so good anyway.

An alternative could be register to the post_save signal of the EntryLog model.

> --
> GH
>
> On May 16, 3:55 pm, ghachey <ghac...@gmail.com> wrote:
>> Hi;
>>
>> I am trying to generate a printable report when saving objects for the
>> first time. This is easy enough except I can't easily access related
>> objects by overriding save() as they are not saved yet, nor are they
>> available within the save() method.
>>
>> The new ModelAdmin.save_related() in Django 1.4 method seems to have
>> been created for just my need. The docs say: "Here you can do any pre-
>> or post-save operations for objects related to the parent. Note that
>> at this point the parent object and its form have already been saved."
>> From what I read this seems perfect for my use case.
>>
>> I tried overriding the method as follows:
>>
>> def save_related(self, request, form, formsets, change):
>>
>>         if not change:
>>             # Generate and send report only if creating for first time
>>             parent_obj = form.instance
>>             import pdb; pdb.set_trace();
>>
>> 1) At that point when I look into the database I don't see the saved
>> parent object? This seems to contradict the docs.
>> 2) I can access cleaned data from the formsets, but is there an easy
>> way to simply get the related instances as I would with
>> parent.child_set.all(). This would make my life much easier as I have
>> written the code already to print a LaTeX report from any Django model
>> (by looping _meta.fields approach).
>>
>> I would appreciate any help.
>>
>> --
>> GH
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



  1   2   3   4   >