Re: Thinking about EAV database model for flexibility. How (in)compatible is it with the django model?

2014-12-23 Thread Felipe Faraggi
You guys are really active on this board! Thanks so much for your time once 
again.
My question has been answered at its fullest.


On Monday, December 22, 2014 11:00:46 PM UTC+1, Jamie Lawrence wrote:
>
> Well, Django, in the role of an ORM, is necessarily pretty coupled to SQL. 
> I know people have been toying with nosql databases with Django; I don't 
> know much about those efforts. 
>
> EAV intentionally defeats the intended use of RDBMSes by ignoring 
> normalization and data typing, thus (among other things) losing easy 
> queryability, validation and performance  optimizations designed with 
> structure in mind. You can butter bread with lumber, but doing so is likely 
> to be a little problematic.  
>
> So, to answer your question, 'both'. 
>
> I would imagine a fully nosql-capable Django would rethink the model 
> system quite a bit, given that the capabilities and use cases of nosql 
> systems are rather divergent from RMDBSes (and frequently each other).
>
> I know it is common to 'pick a side'. But nosql databases are different 
> beasts, good at different things. Doing things like storing sessions in 
> Mysql (say) on a heavily loaded site is almost always a bad idea in any 
> case. 
>
> -j
>
>
> On Dec 22, 2014, at 2:27 AM, Felipe Faraggi  > wrote:
>
> I'd like to 're-open' this question to ask another (maybe) short one:
>
> Therefore, is django not very suitable for NOSQL databases like mongo or 
> couch or others in general?
> Or is the problem specifically using RDBMS in a NoSQL manner?
>
> Because if using NOSQL, the whole model system would be obsolete. Am I 
> wrong in this line of thinking?
>
>
> thanks in advance!
>
>
> On Tuesday, December 16, 2014 11:24:12 AM UTC+1, Felipe Faraggi wrote:
>>
>> Thanks for your responses Jamie and Erik,
>>
>> We've since reconsidered and will in fact, be creating a standard 
>> relational structure. 
>>
>> Again, thanks for your input and feedback
>>
>>
>>
>>
>> On Tuesday, December 16, 2014 2:18:12 AM UTC+1, Jamie Lawrence wrote:
>>>
>>> Just to add to Erik's very good advice on (not) using EAV, another thing 
>>> to keep in mind is that the downsides of EAV tend to manifest after your 
>>> app is hosting a substantial amount of data, at which point the exercise of 
>>> sanitizing it in order to port it to a saner model can be *excruciating*. 
>>>
>>> I've come in to projects like this as a consultant and the golden rule 
>>> of any such contract is "no cap on data conversion fees, but please feel 
>>> free to do it yourself once you realize how much it will cost to preserve 
>>> that data."
>>>
>>> More generally, when using a relational database, you want to think hard 
>>> about temptations to store things in generic buckets. There is a data store 
>>> optimized for generic buckets of bits; it is called a file system. Rdbmses, 
>>> not being designed for that, tend to become expensive[1] when forced to act 
>>> like it. 
>>>
>>> -j
>>>
>>> [1] not necessarily in currency, but that can certainly happen as well. 
>>>
>>> -- 
>>> Sent from a phone, please excuse typos and terseness.
>>>
>>> On Dec 15, 2014, at 5:42 AM, Felipe Faraggi  wrote:
>>>
>>> Hello everybody.
>>>
>>> I am very new to django and I come from a wordpress background (yes, yes 
>>> I know) and I really like their wp_*meta model. 
>>>
>>> After a little digging I discovered this is called the 
>>> Entity-attribute-value 
>>> model or EAV 
>>> .
>>>  
>>> And I am currently setting up a project in django in which my data is very 
>>> variable because we will be opening up to many APIs and they all have their 
>>> own table styles. So instead of having a rigid model, we've opted for 
>>> having a EAV model to stock everything with its own key-value pair.
>>>
>>> So I would like to hear your general thoughts about this method (I've 
>>> heard some good/bad things about it) and your specific experiences with it 
>>> and django (if any).
>>>
>>> I found this repository https://github.com/mvpdev/django-eav that I 
>>> could use as reference.
>>>
>>> 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.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/f0c8def8-d577-4f37-8e67-17fdae896219%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To

Re: Model form with optional fields issue

2014-12-23 Thread marcin . j . nowak


On Tuesday, December 23, 2014 3:49:07 AM UTC+1, James Schneider wrote:
>
> Have you looked at the Django REST Framework module?
>
Yes, I have. They wrote own serializers and fields for validation, and they 
don't use builtin forms.
Personally I don't like DRF API, because it is too heavy and not following 
PEP20 (simple is better than complex), same as CBV in Django.

I wrote custom REST(-like) framework, independent from any framework but 
with bridge to Django. It's a little inspired by Cornice framework and I 
don't need (and don't want) to change it to Django REST Framework.

In my handlers I was using Django forms to clean & validate data, but they 
failed. I though that I've found bug, but now I see that I need to replace 
clean & validation to something better (maybe Colander).
  

> Django is primarily used for displaying/validating data received from HTML 
> forms
>
Now I know... I thought that Django is a generic web framework, but it 
isn't. It's a HTML-oriented web framework.
 

> However, the internal behavior is decoupled enough 
>
I disagree. It isn't decoupled enough for generic web framework:

1. Widgets are to close to fields (field.widget), and base Form class is 
using widgets directly in validation (field.widget.value_from_datadict 
calls in form`s methods).
2. Form._clean_fields() treats None value same as not existing key in input 
data - this is logical bug or improper simplification.

But in the context of validation only HTML fields this is OK.

Regards,
Marcin

-- 
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/074812a3-f776-4092-894c-264c88858fd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: makemigrate adds multiple migrations.AddField for same model (django 1.7.1)

2014-12-23 Thread pjotr
Sorry, all the ALTER statements are identical except the FIELDNAME. It adds 
6 new fields.

On Tuesday, December 23, 2014 4:46:42 AM UTC+1, Collin Anderson wrote:
>
> Hi,
>
> You're just using one database?
>
> Are all 6 ALTER statements identical?
>
> Collin
>
> On Sunday, December 21, 2014 5:27:06 PM UTC-6, pjotr wrote:
>>
>> Just realized the subject was wrong, it should be *makemigrations , not 
>> makemigrate*
>>
>> On Sunday, December 21, 2014 8:36:29 PM UTC+1, pjotr wrote:
>>>
>>> Hi,
>>>
>>> I have a django model that I just added six new fields to. I ran 
>>> *makemigrations 
>>> *and after that noticed when we ran our rehearsal upgrade with dump of 
>>> the production database that things took longer than we expected, and 
>>> checked the processlist. We saw that there were six *alter table* 
>>> statements that was executed after each other, each taking around 15 
>>> minutes to run.
>>>
>>> My expectations were that the migration framework would optimise this 
>>> and only execute one alter table statement. But obviously it was not. Or is 
>>> there a bug? :)
>>>
>>> Are there anyway to fix this, without having to change the migration and 
>>> perform the alter table statement with pure SQL?
>>>
>>> DB: MySQL
>>> Django 1.7.1
>>>
>>> The migrations generated were six of these (only showing one to reduce 
>>> post size):
>>>
>>> migrations.AddField(
>>> model_name='mymodel',
>>> name='field_a',
>>> field=models.BigIntegerField(help_text=b'Blablabla', null=True, 
>>> db_index=True),
>>> preserve_default=True,
>>> ),
>>>
>>>
>>> Regards, Peter Lauri
>>>
>>>

-- 
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/c598973a-d928-4396-8b62-2082d4a57c57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

2014-12-23 Thread suren
I have following model.

class CampaignTemp(models.Model):
campaign_modules = Module.objects.filter(active=True)
choices = 
...
... # other fields 

I get following error when I try `python manage.py`.
...
File "/home/auser/aproject/src/apps/anapp/models.py", line 35, in 
CampaignTemp
campaign_modules = Module.objects.filter(active=True)
...
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
...

The code was written for Django1.6 and is being ported to 1.7. 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/15025122-8284-416d-b075-ebaf8483effd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


potential bug with defer() & only()

2014-12-23 Thread William Earp
Hi all,

I'm writing some tests #18586) for defer() and only() and there appears to 
be a bug when it comes to chaining these two in a single query.

If you look at the docs 
(https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.only),
 
it says this:

# Final result is that everything except "headline" is 
deferred.Entry.objects.only("headline", "body").defer("body")
# Final result loads headline and body immediately (only() replaces any# 
existing set of fields).

Entry.objects.defer("body").only("headline", "body")

However, when I test the last example "body" is still deferred after only() has 
been applied to it. In a situation where there are only these two fields in a 
model there should be no deferred field. 

Is there any reason for this or does this need reporting as a bug. If so, 
what's the procedure for this?

Many thanks,

Will 

-- 
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/5a46bca6-3c88-4ac1-aa5b-5190d25895ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


defer() and only() chaining bug

2014-12-23 Thread William Earp
Hi all,

I'm currently writing unit tests for defer() and only() under issue #18586. 
But there appears to a bug when it comes to chaining the two together.

The docs gives the following example for only():

# Final result loads headline and body immediately (only() replaces any 
existing set of fields).

Entry.objects.defer("body").only("headline", "body")

https://docs.djangoproject.com/en/dev/ref/models/querysets/#defer

It turns out that "body" remains a DeferredAttribute when it shouldn't. So 
in the example above, if the model contained just the two fields "headline" 
and "body" there wouldn't be any deferred field. In my tests "body" is 
still a DeferredAttribute.

Am I getting this right or is this actually a bug?

Cheers,

Will

-- 
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/9ab0e284-5e65-42a5-bd7d-aba7d043a0ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: (yet another) Custom templatetag raising KeyError when DEBUG=False

2014-12-23 Thread Alexandre Provencio
Hi Collin, thanks for answering.

Yes this is the home view, but just to clarify, almost all of the
views of the project follow this pattern of a function that returns
the render shortcut. The templates of the views also follow the a
pattern in the sense they all extend from base.html, which is where
the calls for the templatetag are done. This is the full traceback:

0 errors found
December 23, 2014 - 09:53:07
Django version 1.6.2, using settings 'foo.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
line 206, in __call__
response = self.get_response(request)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 155, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 238, in handle_uncaught_exception
return callback(request, **param_dict)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/utils/decorators.py",
line 99, in _wrapped_view
response = view_func(request, *args, **kwargs)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/views/defaults.py",
line 46, in server_error
return http.HttpResponseServerError(template.render(Context({})))
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/base.py",
line 140, in render
return self._render(context)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/base.py",
line 134, in _render
return self.nodelist.render(context)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/base.py",
line 840, in render
bit = self.render_node(node, context)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/debug.py",
line 78, in render_node
return node.render(context)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/loader_tags.py",
line 123, in render
return compiled_parent._render(context)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/base.py",
line 134, in _render
return self.nodelist.render(context)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/base.py",
line 840, in render
bit = self.render_node(node, context)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/debug.py",
line 78, in render_node
return node.render(context)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/defaulttags.py",
line 196, in render
nodelist.append(node.render(context))
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/base.py",
line 1125, in render
return func(*resolved_args, **resolved_kwargs)
  File 
"/home/xand/Documentos/src/Projetos/django-foo/app/templatetags/helper_tags.py",
line 14, in change_lang
path = context['request'].path
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/context.py",
line 56, in __getitem__
raise KeyError(key)
KeyError: 'request'
[23/Dec/2014 09:53:18] "GET /en/home HTTP/1.1" 500 59
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
line 206, in __call__
response = self.get_response(request)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 155, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 238, in handle_uncaught_exception
return callback(request, **param_dict)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/utils/decorators.py",
line 99, in _wrapped_view
response = view_func(request, *args, **kwargs)
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/views/defaults.py",
line 46, in server_error
return http.HttpResponseServerError(template.render(Context({})))
  File 
"/home/xand/.virtualenvs/django-foo/local/lib/python2.7/site-packages/django/template/base.py",
line 140, in render
return self._ren

not select_relelated records

2014-12-23 Thread Jose Ignacio Berreteaga
 Hi

Some records on "son" table haven´t their parent record on "parent" table. 
How to know are they?

Thanks in advace.

Jose I.

-- 
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/9659df2c-5bbe-4a62-bd64-b01c33c2e4fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

2014-12-23 Thread Jani Tiainen
On Tue, 23 Dec 2014 02:23:16 -0800 (PST)
su...@janakitech.com wrote:

> I have following model.
> 
> class CampaignTemp(models.Model):
> campaign_modules = Module.objects.filter(active=True)
> choices = 
> ...
> ... # other fields 
> 
> I get following error when I try `python manage.py`.
> ...
> File "/home/auser/aproject/src/apps/anapp/models.py", line 35, in 
> CampaignTemp
> campaign_modules = Module.objects.filter(active=True)
> ...
> django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
> ...
> 
> The code was written for Django1.6 and is being ported to 1.7. Any help 
> would be appreciated.
> 

You're doing it wrong. You should never try to access data from database when
constructing models (or load modules) since there is no guarantee that "Module" 
model
is completely initialized and working properly.

Since you don't provide more details I assume that you try to have dynamic from 
Module to
fill choices. There are two fundamental problems first is what happens above 
and second
is that campaign_modules is only evaluated _once_ in lifetime of a CampaignTemp 
model. So
if you change active status of modules they're not reflected to that list.

You need to provide more context of your model so we can help with proper 
solution.

-- 

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20141223152847.16290ac5%40jns42-l.w2k.keypro.fi.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with google calendar on ancient django version

2014-12-23 Thread Roy Smith
Heh, I figured it out (a good night's sleep helped).  I've got Privacy Badger 
installed.  Disabling that lets the the file load properly :-)

I guess for completeness, the answers to my questions are:

1) Probably not

2) No clue

3) "Will not fix -- working as designed" :-)

4) No


On Dec 22, 2014, at 9:02 PM, Roy Smith wrote:

> I'm in the process of incrementally upgrading a site running some ancient 
> software (django 1.3.1 and django-cms 2.2).  I've got a development version 
> of the site running django-cms 2.3.8 (and still django 1.3.1) for testing.  
> The plan is to get it up to modern versions of both, but one step at a time.  
> One oddity is see in the newer site, my google calendar is missing some of 
> the icons.   The problem is that
> 
> https://calendar.google.com/googlecalendar/images/combined_v22.png
> 
> (a bunch of sprited images) is failing to load on the 2.3.8 site, with 
> "net::ERR_BLOCKED_BY_CLIENT" showing in the javascript console.  The referrer 
> URL for that is
> 
> https://www.google.com/calendar/static/7f25774200d4fe9fa8584b21c00791ffe
> 
> so it's clear this is some kind of cross-domain problem.  The questions are:
> 
> 1) Has anybody else seen this?
> 
> 2) Why did changing the django-cms version change how this behaves?
> 
> 3) Is this fixed in later django-cms versions?
> 
> 4) Is this fundamentally a bug in Google calendar, i.e. I should be reporting 
> it to them?
> 
> --
> Roy Smith
> r...@panix.com
> 


--
Roy Smith
r...@panix.com



-- 
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/005A9097-03FF-4C96-9E93-39A253C36FA9%40panix.com.
For more options, visit https://groups.google.com/d/optout.


Difference between Q and filter and exclude

2014-12-23 Thread Anssi Kääriäinen
These queries should be equivalent.

 - Anssi

-- 
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/40b9994a-f83f-4a20-82e1-3ce5f432a5e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Raw access to cache table

2014-12-23 Thread Collin Anderson
Hi Russ,

Makes sense. Thanks.

Collin

On Sunday, December 21, 2014 5:41:34 PM UTC-6, Russell Keith-Magee wrote:
>
>
> On Sun, Dec 21, 2014 at 12:55 PM, Collin Anderson  > wrote:
>>
>> Hi Erik,
>>
>> If you want a nicer interface, I just ran manage.py inspecdb on one of my 
>> databases and got this for the cache table. Not sure why django still does 
>> it by hand.
>>
>
> Gather `round, children, and let Grandpa fill you in on the details... :-)
>
> Although it isn't huge, Django's ORM does have an overhead. If you're 
> looking for the general capability to query rows on a database, this 
> overhead is a reasonable price to pay - you have a little overhead, but 
> it's a lot easier to express complex queries. However, in the case of a 
> cache table, you need to issue exactly 2 queries:
>
> 1) Get me the object with key X.
>
> 2) Set the value of key X.
>
> These two queries are trivial to write -- so trivial in fact, that they 
> don't even need to rewritten as they move across database backends. They're 
> as "vanilla" as a query can get in SQL. 
>
> So - this becomes a case study in when *not* to use the ORM. We know the 2 
> queries that need to be issued. That SQL isn't hard to write or maintain. 
> And using the ORM would impose a non-trivial runtime overhead - and by 
> definition, a cache backend is supposed to be as efficient as possible. Raw 
> SQL is the "right" answer here.
>
> (well not using a database backed cache backend is the *really* right 
> answer, but I'll let that slide for the moment...)
>
> If you *do* want to do complex queries on the database cache table, the 
> approach suggested by Collin is as good an approach as any. A managed table 
> will give you ORM operations over an arbitrary table - include Django's own 
> internal tables.
>
> That said, I'll also concur that the database cache backend is the wrong 
> answer here. If you're writing a cron script, the approach I've always used 
> is PIDfile based lock:
>
>
> http://unix.stackexchange.com/questions/12815/what-are-pid-and-lock-files-for
>
> 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/d3674731-8421-4ec8-a208-8290e7486330%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Optimizing admin change view with inlines

2014-12-23 Thread 'Petros Moisiadis' via Django users
Hello people :)

I am struggling with optimizing an admin with inlines which causes too
many database requests.

My model structure is like this:

class ExampleA(models.Model):
...
   
class ExampleB(models.Model):
aexample = models.ForeignKey('ExampleA', related_name='bexamples')
cexample = models.ForeignKey('ExampleC')
dexample = models.ForeignKey('ExampleD')
eexample = models.ForeignKey('ExampleE')
...

class ExampleC(models.Model):
...
   
class ExampleD(models.Model):
...
   
class ExampleE(models.Model):
...

The admin classes:

class ExampleBInline(admin.StackedInline):
model = ExampleB
extra = 0

class ExampleAAdmin(admin.ModelAdmin):
inlines = [ExampleBInline]

admin.site.register(ExampleA, ExampleAAdmin)

As I can see with django-debug-toolbar, when rendering the admin
template for the inline formset with the forms for ExampleB objects, a
new db request is sent to db server for each related field of each
ExampleB object. Particularly, I am seeing a lot of queries like these:

SELECT ••• FROM `examplec` WHERE `examplec`.`id` = 1 LIMIT 21
SELECT ••• FROM `examplee` WHERE `examplee`.`id` = 2 LIMIT 21
SELECT ••• FROM `examplec` WHERE `examplec`.`id` = 2 LIMIT 21
SELECT ••• FROM `exampled` WHERE `exampled`.`id` = 2 LIMIT 21
SELECT ••• FROM `examplee` WHERE `examplee`.`id` = 3 LIMIT 21

The template context is this (I am using grappelli):
   
21{% if field.is_readonly %}
22{{
field.contents|linebreaksbr }}
23{% else %}
the marked line =>  24{{ field.field }}
25{% endif %}
26{% endif %}
27{% if line.fields|length_is:'1' %}{{
line.errors }}{% endif %}


I have tried the following optimizations:

First try:

class ExampleAAdmin(admin.ModelAdmin):
inlines = [ExampleBInline]

def get_queryset(self, request):
qs = super(ExampleAAdmin, self).get_queryset(request)
return qs.prefetch_related('bexamples',
'bexamples__cexample', 'bexamples__dexample', 'bexamples__example')

Second try:

class ExampleBInline(admin.StackedInline):
model = ExampleB
extra = 0
  
def get_queryset(self, request):
qs = super(ExampleInline, self).get_queryset(request)
return qs.select_related('cexample', 'dexample', 'eexample')

Third try:

class BaseExampleBFormSet(BaseInlineFormSet):
def __init__(self, *args, **kwargs):
super(BaseExampleBFormSet, self).__init__(*args, **kwargs)
qs = self.queryset
self.queryset = qs.select_related('cexample', 'dexample',
'eexample')

ExampleBFormSet = inlineformset_factory(ExampleA, ExampleB,
formset=BaseExampleBFormSet)

class ExampleBInline(admin.StackedInline):
model = ExampleB
extra = 0
formset = ExampleBFormSet

Unfortunately, none of the above works.

So, I would be really grateful if anyone could help on this by giving
any hint or pointing out what could be possibly missing. Or, could I
have hit a restriction of django admin's internals?

Thank you in advance,

Petros

-- 
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/5499A2A1.3040403%40yahoo.gr.
For more options, visit https://groups.google.com/d/optout.


Two Django projects with common models and business logic

2014-12-23 Thread andy


Hi,

I have two Django Projects that have different use cases. There are reached 
using different domains. They are hosted in two different servers. Also 
each Django project has it's own database.

Now, both the projects have some models and some business logic common 
between them. I don't want to duplicate the code and data which shall be 
chaotic going forward. Also, I want the models and code (business logic) to 
be in sync (when models/code is altered).

Can anyone guide me towards a pattern that can help me attain the required 
architecture: 2 separate projects with common models and business logic.

Thanks in advance.

/andy

P.S. This is my first post. So pardon me for breaking any forum etiquette.

-- 
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/ae6f4561-bd32-463b-820e-d66c68412575%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django url issues, append slash and case insensitvity

2014-12-23 Thread pythonista
I am having some issues with trailing slashes.

The application is working fine from my local machine whether I add a 
trailing slash or not.

It is not working as expected on the servers.  The link is being redirected 
to localhost for some reason.


I thought that SLASH_APPEND= True was on by default in the settings.py file.

1. I can add that to the settings file.
url(r'^waitlist/',
2.  I can addwaitlist/?' ( ?)
to each url.  

On my machine the url router goes to the correct page, but it now is 
missing the /
waitlist/add_account/

now becomes 

waitlistadd_account/(the middle /   is missing, but the code seems to 
be working.)

Any help would be appreciated.

While I am on a similar subject,

to make the request case insensitive, if I make the above call like this to 
make it case insensitive, is this the best way, are there any side effects 
of this approach?

url(r'^(?i)waitlist/?'

Thanks in advance.

We are using nginx, is there any way to code the case insensitivity piece 
in there?

Thanks

Bob

-- 
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/724c4041-24ba-4a04-b427-31fde9c83208%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Database queries location

2014-12-23 Thread pythonista
Can this be used with a complex query in which multiple tables (classes) 
are being joined? 

I also have to pass multiple post values to the query.

Thanks for the example



On Monday, December 22, 2014 8:52:04 PM UTC-5, Collin Anderson wrote:
>
> Hi,
>
> There's a good example of creating a custom manager here:
> https://docs.djangoproject.com/en/dev/topics/db/managers/#custom-managers
>
> Collin
>
> On Saturday, December 20, 2014 8:28:57 AM UTC-6, pythonista wrote:
>>
>> Thank you for your response.  
>>
>> Most of my data is complex raw sql.
>> I had placed it in the views and it is working as expected
>>
>> I would like to migrate the raw sql to managers, 
>> Can you point me to one or more good examples of how the manager is coded 
>> and how the sql interacts with the views.
>>
>> Thanks
>>
>>
>> On Friday, December 19, 2014 7:06:54 AM UTC-5, aRkadeFR wrote:
>>>
>>> Depend exactly on what to compute for your post data. 
>>>
>>> I would almost write no logic code in the views. 
>>>
>>> I split every application as follow: 
>>> - managers.py: All the logic as a table level (raw SQL, complex queries) 
>>> - models.py: All logic as a row level / object level (python computing 
>>> data) 
>>> - forms.py: All logic as forms data / processing / validation for 
>>> request data 
>>>
>>> Have a good one, 
>>>
>>> aRkadeFR 
>>>
>>> On 12/18/2014 10:12 PM, pythonista wrote: 
>>> > I understand that functions can be placed in the models fille 
>>> > 
>>> > However if I have complex queries that receive post input does the 
>>> > 
>>> > 
>>> > Query live in the model  the views or an external module 
>>> > 
>>>
>>>

-- 
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/da462827-3f99-4438-bba5-94639f11e2a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Two Django projects with common models and business logic

2014-12-23 Thread Javier Guerra Giraldez
On Tue, Dec 23, 2014 at 1:22 PM, andy  wrote:
> Now, both the projects have some models and some business logic common
> between them. I don't want to duplicate the code and data which shall be
> chaotic going forward. Also, I want the models and code (business logic) to
> be in sync (when models/code is altered).


encapsulate those models and code in reusable apps.  and since Django
apps are just Python modules, you can package and deploy them using
Python tools like pip.

-- 
Javier

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


Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-23 Thread Ken Wayne
Windows 8
Django 1.7.1
Python 3.4.2
Google Chrome Version 39.0.2171.95 m

Bottom of part 2 of the the 
tutorial https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it 
indicates how to customize the admin template but when I follow the 
directions it doesn't show any change in my browser.  I've restarted the 
development server and refreshed my browser.

*File Snip base_site.html:*
{% block title %}{{ title }} | Polls Administration {% endblock %}

*File Snip settings.py:*
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']

I tried the environment path, and hard coding the path.  Since the tutorial 
didn't indicate the BASE_DIR path I made a copy of the file in each of the 
following directories:
C:\Python34\Scripts\mysite\templates\admin
C:\Python34\Scripts\mysite\mysite\templates\admin
C:\Python34\Scripts\mysite\polls\templates\admin

Any thoughts on what I might be doing wrong?

-- 
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/0a7c4e30-ba26-418b-b217-72936c72975f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-23 Thread Néstor
You might need to make for admin
mysite/templates/admin/base_site.html

for regular html files for the polls only
mysite/polls/templates/polls/index.html

That is how I got it to work.  Good luck!!!

:-)

On Tue, Dec 23, 2014 at 2:13 PM, Ken Wayne  wrote:

> Windows 8
> Django 1.7.1
> Python 3.4.2
> Google Chrome Version 39.0.2171.95 m
>
> Bottom of part 2 of the the tutorial
> https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it indicates how
> to customize the admin template but when I follow the directions it doesn't
> show any change in my browser.  I've restarted the development server and
> refreshed my browser.
>
> *File Snip base_site.html:*
> {% block title %}{{ title }} | Polls Administration {% endblock %}
>
> *File Snip settings.py:*
> import os
> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
> # TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
> TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']
>
> I tried the environment path, and hard coding the path.  Since the
> tutorial didn't indicate the BASE_DIR path I made a copy of the file in
> each of the following directories:
> C:\Python34\Scripts\mysite\templates\admin
> C:\Python34\Scripts\mysite\mysite\templates\admin
> C:\Python34\Scripts\mysite\polls\templates\admin
>
> Any thoughts on what I might be doing wrong?
>
> --
> 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/0a7c4e30-ba26-418b-b217-72936c72975f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-23 Thread Ken Wayne
Hmmm, that is one of the directories I tried, 
C:\Python34\Scripts\mysite\templates\admin with the file base_site.html


On 12/23/2014 5:07 PM, Néstor wrote:

You might need to make for admin
mysite/templates/admin/base_site.html

for regular html files for the polls only
mysite/polls/templates/polls/index.html

That is how I got it to work.  Good luck!!!

:-)

On Tue, Dec 23, 2014 at 2:13 PM, Ken Wayne > wrote:


Windows 8
Django 1.7.1
Python 3.4.2
Google Chrome Version 39.0.2171.95 m

Bottom of part 2 of the the tutorial
https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it
indicates how to customize the admin template but when I follow
the directions it doesn't show any change in my browser.  I've
restarted the development server and refreshed my browser.

*File Snip base_site.html:*
{% block title %}{{ title }} | Polls Administration {% endblock %}

*File Snip settings.py:*
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']

I tried the environment path, and hard coding the path.  Since the
tutorial didn't indicate the BASE_DIR path I made a copy of the
file in each of the following directories:
C:\Python34\Scripts\mysite\templates\admin
C:\Python34\Scripts\mysite\mysite\templates\admin
C:\Python34\Scripts\mysite\polls\templates\admin

Any thoughts on what I might be doing wrong?
-- 
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/0a7c4e30-ba26-418b-b217-72936c72975f%40googlegroups.com

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


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAON-vCPcGEhk3%2B0wO4RXSnuQWqW5H6H4ZbiHoo1h5yRx36GbBQ%40mail.gmail.com 
.

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


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


django problem with mysql and apache

2014-12-23 Thread th . granier
Hello
i have just installed Django on Ubuntu 14.04  and i'd like to know 

1  how to do a multilingual site?
2 how to do a forum or use one existent

3 during the installation i have this probleme about mysql



root@linux-pc:/home/siteweb# python3.4 manage.py migrate
Traceback (most recent call last):
  File 
"/usr/local/lib/python3.4/dist-packages/django/db/backends/mysql/base.py", 
line 14, in 
import MySQLdb as Database
ImportError: No module named 'MySQLdb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", 
line 385, in execute_from_command_line
utility.execute()
  File 
"/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", 
line 354, in execute
django.setup()
  File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 
21, in setup
apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", 
line 108, in populate
app_config.import_models(all_models)
  File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 
202, in import_models
self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.4/importlib/__init__.py", line 109, in 
import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 2231, in _gcd_import
  File "", line 2214, in _find_and_load
  File "", line 2203, in 
_find_and_load_unlocked
  File "", line 1200, in _load_unlocked
  File "", line 1129, in _exec
  File "", line 1448, in exec_module
  File "", line 321, in 
_call_with_frames_removed
  File 
"/usr/local/lib/python3.4/dist-packages/django/contrib/auth/models.py", 
line 40, in 
class Permission(models.Model):
  File "/usr/local/lib/python3.4/dist-packages/django/db/models/base.py", 
line 124, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
  File "/usr/local/lib/python3.4/dist-packages/django/db/models/base.py", 
line 299, in add_to_class
value.contribute_to_class(cls, name)
  File 
"/usr/local/lib/python3.4/dist-packages/django/db/models/options.py", line 
166, in contribute_to_class
self.db_table = truncate_name(self.db_table, 
connection.ops.max_name_length())
  File "/usr/local/lib/python3.4/dist-packages/django/db/__init__.py", line 
40, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/usr/local/lib/python3.4/dist-packages/django/db/utils.py", line 
242, in __getitem__
backend = load_backend(db['ENGINE'])
  File "/usr/local/lib/python3.4/dist-packages/django/db/utils.py", line 
108, in load_backend
return import_module('%s.base' % backend_name)
  File "/usr/lib/python3.4/importlib/__init__.py", line 109, in 
import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 2231, in _gcd_import
  File "", line 2214, in _find_and_load
  File "", line 2203, in 
_find_and_load_unlocked
  File "", line 1200, in _load_unlocked
  File "", line 1129, in _exec
  File "", line 1448, in exec_module
  File "", line 321, in 
_call_with_frames_removed
  File 
"/usr/local/lib/python3.4/dist-packages/django/db/backends/mysql/base.py", 
line 17, in 
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: 
No module named 'MySQLdb'




how can i repair this?


AND finally
4 i'd like ti use my apache server instead of the server provided by 
Django. I have made the modifications in the apacahe2.conf 
but now??

how use apache instead of the internat server od Django?


MANY 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/d81eeaea-fa8f-4711-acf1-bcf7bb8b529e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Poll Tutorial (for Django 1.7) Files Available?

2014-12-23 Thread Russell Keith-Magee
Hi Ken,

No - the full tutorial code isn't available anywhere (at least, not in an
official capacity). If you need help debugging a problem, let us know what
error you're getting, and we might be able to help you; if you're looking
for some immediate feedback, try the #django IRC channel. There's usually
someone there who will be willing to help someone work through the tutorial.

Yours,
Russ Magee %-)

On Tue, Dec 23, 2014 at 7:06 AM, Ken Wayne  wrote:
>
> I'm trying to work through the Poll Tutorial and I've run into some
> problems.  I'd like to compare the code I've written to a working file.  Is
> there any place to download the entire working project?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/26f1c16c-865c-43a6-910e-5dd90beb22bb%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: potential bug with defer() & only()

2014-12-23 Thread Russell Keith-Magee
Hi Will,

On Tue, Dec 23, 2014 at 3:56 PM, William Earp  wrote:
>
> Hi all,
>
> I'm writing some tests #18586) for defer() and only() and there appears to
> be a bug when it comes to chaining these two in a single query.
>
> If you look at the docs (
> https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.only),
> it says this:
>
> # Final result is that everything except "headline" is 
> deferred.Entry.objects.only("headline", "body").defer("body")
> # Final result loads headline and body immediately (only() replaces any# 
> existing set of fields).
>
> Entry.objects.defer("body").only("headline", "body")
>
> However, when I test the last example "body" is still deferred after only() 
> has been applied to it. In a situation where there are only these two fields 
> in a model there should be no deferred field.
>
> Is there any reason for this or does this need reporting as a bug. If so, 
> what's the procedure for this?
>
> Well, either the code is wrong or the documentation is wrong, so
*something* needs to be changed. The documentation describes what I
understood to be Django's behavior, so it if isn't working like that, then
it sounds like you've found a bug.

To report it, visit

https://code.djangoproject.com

and on the top left, there's a "New ticket" button. (You may need to log in
first - either with your Github account, or by creating a Django Project
account).

Fill in the details (pretty much what you've done here, but also provide
Django + Python version numbers, and the database you're testing with), and
someone else will try to replicate the problem you describe.

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