Django: Ticket Queryhttps://code.djangoproject.com/query?status=closed&resolution=wontfix&desc=1&order=summary
The Web framework for perfectionists with deadlines.en-USDjangohttps://www.djangoproject.com/s/img/site/hdr_logo.gifhttps://code.djangoproject.com/query?status=closed&resolution=wontfix&desc=1&order=summary
Trac 1.2.2https://code.djangoproject.com/ticket/5647
https://code.djangoproject.com/ticket/5647#5647: Your First App - URL section - too complex - suggestionsSun, 30 Sep 2007 23:15:32 GMTjohn.staff2222@…<p>
Yikes, the section on URL's is really too complex for "First App" - it's great that Django has all that power but especially for the "First App" the poor new user does not need to be exposed to that much - it's pretty overwhelming. So let's just use a simple example:
</p>
<p>
"(r'<sup>mymodel/list/$', 'myproject.myapp.views.mymodel_listing'),"
</sup></p>
<p>
forget the part of using "/include" - a first app doesn't need that level of detail.
</p>
<p>
Just keep the focus on how the user needs to provide a translation table of what the URL is and what it calls - and why the user needs to do this manually in Django as opposed to how it's automatically done in Rails. But I would add a "Tip" window that explains how the "myproject.myapp.views" can be moved to the patterns parameter for easier listings (I just discovered this rereading the section). Anything easier, simpler should always be highlighted in a "Tips" box
</p>
Resultshttps://code.djangoproject.com/ticket/5647#changeloghttps://code.djangoproject.com/ticket/18352
https://code.djangoproject.com/ticket/18352#18352: You can't use AnonymousUser in the database APISun, 20 May 2012 07:50:17 GMTteolicy<p>
There's an ancient ticket (<a class="closed ticket" href="https://code.djangoproject.com/ticket/3413" title="#3413: You can't use AnonymousUser in the database API (closed: invalid)">#3413</a>) with the same title, where the person opening the ticket probably failed to realize that you can't use AnonymousUser with the ORM and didn't duly check is_authenticated() before using request.user (or whatever).
</p>
<p>
I do understand the difference between User and AnonymousUser, and understand the latter can't be used with the ORM, but I think this is poor behaviour which may need correction (though breaking backwards compatibility could be a very good reason not to fix this). I think it's tedious and error prone to check for is_authenticated() all the time, and I had more than one bug where I was bit by request.user not having get_full_name() or .pk or plainly not being searchable as SomeModel.objects.filter(owner=request.user).exists() or so.
</p>
<p>
I think the best solution would be for AnonymousUser to be 100% compatible with the ORM, and I think the sanest way to get there would be to make it possible to create a User object with reasonable values. Backwards compatibility could be achieved with a setting like AUTH_NEW_STYLE_ANONYMOUS=True, syncdb() could create the record in the database.
</p>
<p>
I'd love to hear your comments, I'm thinking about implementing this as a (very small) external project if this will be rejected, so in addition to knowing whether this is a good idea for django, I'd appreciate your thoughts about whether this is a good idea at all.
</p>
Resultshttps://code.djangoproject.com/ticket/18352#changeloghttps://code.djangoproject.com/ticket/7495
https://code.djangoproject.com/ticket/7495#7495: XViewMiddleware gets Content-Type wrongWed, 18 Jun 2008 14:17:55 GMTJeremy Dunck<p>
The doc.XViewMiddleware gives short-circuits views to supply the X-View header.
</p>
<p>
It doesn't actually call the view, and uses the default Content-Type of <a class="wiki" href="https://code.djangoproject.com/wiki/HttpRequest">HttpRequest</a>.
</p>
<p>
This means that HEAD requests for people logged in as staff function incorrectly; in our case, this was a staffer's HEAD request for an RSS feed getting text/html.
</p>
<p>
I understand the performance implications of calling the view despite its content not being returned, but I think it's the right thing to do.
</p>
Resultshttps://code.djangoproject.com/ticket/7495#changeloghttps://code.djangoproject.com/ticket/610
https://code.djangoproject.com/ticket/610#610: XSLT as templating engine.Tue, 11 Oct 2005 13:26:23 GMTanonymous<p>
It would be great to have XSLT as an optional template engine. It would require some sort of model -&gt; XML conversion first.
The reasons to use XSLT are:
</p>
<ul><li>it's XML (easy to verify that the templates are in workding condition using DTD or Schema)
</li><li>it's a widely accepted standard (higher interoperability between different frameworks)
</li><li>it is extremely versatile and extensible
</li><li>it's very fast (using libxslt from xmlsoft.org or other fast implementations)
</li></ul>Resultshttps://code.djangoproject.com/ticket/610#changeloghttps://code.djangoproject.com/ticket/5458
https://code.djangoproject.com/ticket/5458#5458: Xml serializer - easier manipulation from Adobe FlexFri, 14 Sep 2007 15:05:01 GMTtrebor74hr@…<p>
Hi,
I'm sending you a patch to version from 2007-09-03 trunk checkout. For django.core.serialize method serialize() in xml mode, can take bool param flexmode which enables easier xml parsing from Adobe Flex (HttpService+Dataprovider) - i.e. no '-' in main tag name, tags 'field' to '%field.name%' tag.
</p>
<p>
Sample usage:
</p>
<pre class="wiki">data = serializers.serialize("xml", Holiday.objects.all(), flexmode=True)
</pre>Resultshttps://code.djangoproject.com/ticket/5458#changeloghttps://code.djangoproject.com/ticket/4585
https://code.djangoproject.com/ticket/4585#4585: XMLField in PostgreSQLSat, 16 Jun 2007 11:53:10 GMTBleSS<p>
I've seen that XMLField is really a TextField that checks if is valid XML:<br />
<a class="ext-link" href="http://www.djangoproject.com/documentation/model-api/#xmlfield"><span class="icon">​</span>http://www.djangoproject.com/documentation/model-api/#xmlfield</a>
</p>
<p>
But PostgreSql has already a type designed for XML:<br />
<a class="ext-link" href="http://developer.postgresql.org/pgdocs/postgres/datatype-xml.html"><span class="icon">​</span>http://developer.postgresql.org/pgdocs/postgres/datatype-xml.html</a> <br />
<a class="ext-link" href="http://developer.postgresql.org/pgdocs/postgres/functions-xml.html"><span class="icon">​</span>http://developer.postgresql.org/pgdocs/postgres/functions-xml.html</a>
</p>
<p>
and I think that the PostgreSQL backend would more powerfull if could use that type directly.
</p>
<p>
<a class="ext-link" href="http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql_psycopg2/introspection.py#L70"><span class="icon">​</span>http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql_psycopg2/introspection.py#L70</a> <br />
<a class="ext-link" href="http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/__init__.py#L943"><span class="icon">​</span>http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/__init__.py#L943</a>
</p>
Resultshttps://code.djangoproject.com/ticket/4585#changeloghttps://code.djangoproject.com/ticket/16696
https://code.djangoproject.com/ticket/16696#16696: wrong url validationThu, 25 Aug 2011 10:53:41 GMTcetver@…<p>
url validation with verify_exists = False allows url like <a class="ext-link" href="http://www.google"><span class="icon">​</span>http://www.google</a>
</p>
Resultshttps://code.djangoproject.com/ticket/16696#changeloghttps://code.djangoproject.com/ticket/13646
https://code.djangoproject.com/ticket/13646#13646: Wrong RE in comma_separated_int_list_reFri, 28 May 2010 00:10:56 GMTaledr<p>
The actual RE validator in comma_separated_int_list_re for CommaSeparatedIntegerField will allow some kind of following values:
</p>
<pre class="wiki">',,,' '1,,2,3,'
</pre><p>
It is
</p>
<pre class="wiki">comma_separated_int_list_re = re.compile('^[\d,]+$')
</pre><p>
and should be:
</p>
<pre class="wiki">comma_separated_int_list_re = re.compile('^[\d,]*\d$')
</pre>Resultshttps://code.djangoproject.com/ticket/13646#changeloghttps://code.djangoproject.com/ticket/22211
https://code.djangoproject.com/ticket/22211#22211: Wrong lighttpd deployment docsTue, 04 Mar 2014 23:41:30 GMTanonymous<p>
lighttpd deployment docs still recommend an alias.url for /media to admin/media, while admin works with staticfiles now.
The config should have an alias for (all) staticfiles, not to adminfiles in django/contrib/admin/
</p>
Resultshttps://code.djangoproject.com/ticket/22211#changeloghttps://code.djangoproject.com/ticket/9771
https://code.djangoproject.com/ticket/9771#9771: Wrong form actionMon, 08 Dec 2008 09:11:43 GMTtutonien<p>
Hello,
</p>
<p>
There may be an improvement in the form of the <a class="ext-link" href="http://docs.djangoproject.com/en/dev/intro/tutorial04/#write-a-simple-form"><span class="icon">​</span>fourth part of the tutorial</a>.
</p>
<p>
The form sends the vote to /polls/123/vote/ (with 123 the poll id) but the form itself is in the detail page which URL is /polls/123/. Therefore, it would make more sense to use a relative URL instead of an absolute one.
</p>
<pre class="wiki">&lt;form action="/polls/{{ poll.id }}/vote/" method="post"&gt;
</pre><p>
This way, the poll app would be more "pluggable" because the polls directory does not need to be at the root of the server.
</p>
<pre class="wiki">&lt;form action="vote/" method="post"&gt;
</pre><p>
Thank you for your time and your good work.
</p>
Resultshttps://code.djangoproject.com/ticket/9771#changeloghttps://code.djangoproject.com/ticket/21788
https://code.djangoproject.com/ticket/21788#21788: Wrong fields order after deferThu, 16 Jan 2014 04:48:53 GMTanonymous<p>
postgresql view:
</p>
<div class="wiki-code"><div class="code"><pre><span class="k">CREATE</span> <span class="k">VIEW</span> test_view <span class="k">AS</span>
<span class="k">SELECT</span> md5<span class="p">(</span><span class="k">g</span><span class="p">.</span><span class="o">*</span><span class="p">::</span><span class="nb">text</span><span class="p">)</span> <span class="k">as</span> hash<span class="p">,</span>
<span class="k">g</span><span class="p">.</span><span class="k">g</span> <span class="k">AS</span> num <span class="k">FROM</span> generate_series<span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span> <span class="k">g</span><span class="p">;</span>
</pre></div></div><p>
query result:
</p>
<table class="wiki">
<tr><th colspan="2"><table class="wiki">
<tr><td><blockquote>
<p>
hash
</p>
</blockquote>
</td><td><blockquote>
<p>
num
</p>
</blockquote>
</td></tr></table>
<table class="wiki">
<tr><td><blockquote>
<p>
c4ca4238a0b923820dcc509a6f75849b
</p>
</blockquote>
</td><td><blockquote>
<p>
1
</p>
</blockquote>
</td></tr></table>
<table class="wiki">
<tr><td><blockquote>
<p>
c81e728d9d4c2f636f067f89cc14862c
</p>
</blockquote>
</td><td><blockquote>
<p>
2
</p>
</blockquote>
</td></tr></table>
<table class="wiki">
<tr><td><blockquote>
<p>
eccbc87e4b5ce2fe28308fd9f2a7baf3
</p>
</blockquote>
</td><td><blockquote>
<p>
3
</p>
</blockquote>
</td></tr></table>
<table class="wiki">
<tr><td><blockquote>
<p>
a87ff679a2f3e71d9181a67b7542122c
</p>
</blockquote>
</td><td><blockquote>
<p>
4
</p>
</blockquote>
</td></tr></table>
</th></tr></table>
<p>
django model:
</p>
<div class="wiki-code"><div class="code"><pre><span class="k">class</span> <span class="nc">TestView</span><span class="p">(</span>models<span class="o">.</span>Model<span class="p">):</span>
<span class="nb">id</span> <span class="o">=</span> models<span class="o">.</span>CharField<span class="p">(</span>primary_key<span class="o">=</span><span class="bp">True</span><span class="p">,</span> max_length<span class="o">=</span><span class="mi">32</span><span class="p">,</span> db_column<span class="o">=</span><span class="s1">'hash'</span><span class="p">)</span>
<span class="nb">hash</span> <span class="o">=</span> models<span class="o">.</span>CharField<span class="p">(</span>max_length<span class="o">=</span><span class="mi">32</span><span class="p">,</span> db_column<span class="o">=</span><span class="s1">'hash'</span><span class="p">)</span>
num <span class="o">=</span> models<span class="o">.</span>IntegerField<span class="p">(</span>db_column<span class="o">=</span><span class="s1">'num'</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
db_table <span class="o">=</span> <span class="s1">'test_view'</span>
</pre></div></div><p>
ipython test:
</p>
<div class="wiki-code"><div class="code"><pre>
In <span class="p">[</span><span class="mi">1</span><span class="p">]:</span> <span class="kn">from</span> <span class="nn">public_api.models</span> <span class="kn">import</span> TestView
In <span class="p">[</span><span class="mi">2</span><span class="p">]:</span> TestView<span class="o">.</span>objects<span class="o">.</span>all<span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span>num
Out<span class="p">[</span><span class="mi">2</span><span class="p">]:</span> <span class="mi">1</span>
In <span class="p">[</span><span class="mi">3</span><span class="p">]:</span> TestView<span class="o">.</span>objects<span class="o">.</span>defer<span class="p">(</span><span class="s1">'hash'</span><span class="p">)</span><span class="o">.</span>all<span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span>num
Out<span class="p">[</span><span class="mi">3</span><span class="p">]:</span> <span class="sa">u</span><span class="s1">'c4ca4238a0b923820dcc509a6f75849b'</span>
</pre></div></div>Resultshttps://code.djangoproject.com/ticket/21788#changeloghttps://code.djangoproject.com/ticket/15567
https://code.djangoproject.com/ticket/15567#15567: Wrong error message when user having is_staff=False tries to login to adminTue, 08 Mar 2011 05:43:47 GMTarty<p>
Steps to reproduce:
</p>
<ul><li>Create a user with is_staff=False
</li><li>Logout and go to /admin/
</li><li>Try to log in using that user's credentials
</li></ul><p>
Error message would say: "Please enter a correct username and password. Note that both fields are case-sensitive."
</p>
<p>
This message is wrong, because username and password are correct. Proper message should be something like "You do not have permissions to enter admin area."
</p>
Resultshttps://code.djangoproject.com/ticket/15567#changeloghttps://code.djangoproject.com/ticket/16834
https://code.djangoproject.com/ticket/16834#16834: wrong error message when entering admin and not is_staff or is_activeTue, 13 Sep 2011 15:03:46 GMTWim Feijen <wim@…><p>
On the admin login, when a user tries to login, but is_staff is set to False, the error message is misleadingly wrong:
</p>
<p>
"Please enter a correct username and password. Note that both fields are case-sensitive."
</p>
<p>
The actual message should be something like:
</p>
<p>
"You are not allowed to enter the administration area of this website."
</p>
<p>
How do we deal with translations of this message?
</p>
Resultshttps://code.djangoproject.com/ticket/16834#changeloghttps://code.djangoproject.com/ticket/13258
https://code.djangoproject.com/ticket/13258#13258: Writing your first Django app, part 4, urls.pyThu, 01 Apr 2010 05:15:33 GMTjulyzergcn1@…<p>
maybe the urls.py should be like this at last.
</p>
<pre class="wiki">from django.conf.urls.defaults import *
from mysite.polls.models import Poll
info_dict = {
'queryset': Poll.objects.all(),
}
urlpatterns = patterns('',
url(r'^$', 'django.views.generic.list_detail.object_list', dict(info_dict, template_object_name='latest_poll', template_name='polls/index.html')),
url(r'^(?P&lt;object_id&gt;\d+)/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_object_name='poll', template_name='polls/detail.html')),
url(r'^(?P&lt;object_id&gt;\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_object_name='poll', template_name='polls/results.html'), 'poll_results'),
(r'^(?P&lt;poll_id&gt;\d+)/vote/$', 'mysite.polls.views.vote'),
)
</pre>Resultshttps://code.djangoproject.com/ticket/13258#changeloghttps://code.djangoproject.com/ticket/13738
https://code.djangoproject.com/ticket/13738#13738: "Writing Views" doesn't help much if you want in-depth info on writing viewsThu, 10 Jun 2010 20:49:30 GMTJonathanHayward<p>
<a class="ext-link" href="http://docs.djangoproject.com/en/dev/topics/http/views/"><span class="icon">​</span>http://docs.djangoproject.com/en/dev/topics/http/views/</a> as it exists now might more appropriately be called "Assigning error views" or something similar.
</p>
<p>
What it does not give is any particular detail about how to write an interesting view for a normal, i.e. 200 case. The views take a request object but do not demonstrate how to read CGI form variables from the request, and I would expect there's a lot more that can and should be said about writing views for a normal status 200 response than is said.
</p>
<p>
I don't know if the expanded documentation should be in this page or another, but any page labelled "Writing Views" page should be a detailed page covering most of the bases for how one writes a view for a normal (200) response, and workhorses like retrieving submitted CGI variables. It might also include what the present page does, but right now the "Writing Views" page isn't doing what a page with that name should do.
</p>
<p>
Jonathan, <a class="ext-link" href="http://JonathansCorner.com/"><span class="icon">​</span>http://JonathansCorner.com/</a>
</p>
Resultshttps://code.djangoproject.com/ticket/13738#changeloghttps://code.djangoproject.com/ticket/15719
https://code.djangoproject.com/ticket/15719#15719: Write tests for databrowseWed, 30 Mar 2011 13:03:11 GMTAymeric Augustin<p>
Currently there are none.
</p>
Resultshttps://code.djangoproject.com/ticket/15719#changeloghttps://code.djangoproject.com/ticket/5806
https://code.djangoproject.com/ticket/5806#5806: Would like a callback on models.Field during SQL generationTue, 23 Oct 2007 15:47:36 GMTsam@…<p>
It would be useful if Fields had the opportunity to specify SQL code to be included when generating the SQL for their model.
</p>
<p>
I am currently trying to add some stuff to the SQL generated by Django to implement full text indexes in PostgreSQL for several models. Each model requires the following to be added:
</p>
<pre class="wiki">-- full text indexing on blogs_post
CREATE INDEX blogs_post_fts
ON blogs_post
USING gin
(vector);
CREATE FUNCTION blogs_post_fts_update () RETURNS trigger AS $$
BEGIN
NEW.vector = ts2.to_tsvector ('default', NEW.title || ' ' || NEW.body);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER blogs_post_fts_update BEFORE INSERT OR UPDATE ON blogs_post FOR EACH
ROW EXECUTE PROCEDURE blogs_post_fts_update ();
-- end of full text indexing on blogs_post
</pre><p>
Entering this for every table that I want to create an index upon is really annoying!
</p>
<p>
It is possible to generate these SQL statements based on information in the model definition:
</p>
<pre class="wiki">class Blog (models.Model):
title = models.TextField ()
body = models.TextField ()
vector = TsvectorField (fields = ['title', 'body'])
</pre><p>
In order to do this, I created a custom field type that adds the actual field to the CREATE TABLE statement:
</p>
<pre class="wiki">class TsvectorField (models.Field):
def __init__ (self, fields, *args, **kwargs):
if kwargs.pop ('editable', False) == True:
raise ValueError ('TsvectorFields can not be editable')
super (TsvectorField, self).__init__ (*args, **kwargs)
# do something with fields!
def db_type (self):
return 'ts2.tsvector'
</pre><p>
But at this point I am stuck: as far as I can see, there is nowhere to place the code to generate the above SQL.
</p>
<p>
I propose that <code>django.core.management.sql.sql_indexes_for_model</code> by modified to call a method on each field, named something like <code>get_sql_index</code>. This method would generate &amp; return the above SQL statements.
</p>
<p>
Thoughts?
</p>
Resultshttps://code.djangoproject.com/ticket/5806#changeloghttps://code.djangoproject.com/ticket/16636
https://code.djangoproject.com/ticket/16636#16636: Wording in documentation for contrib.auth could be improved on is_authenticated()Mon, 15 Aug 2011 14:15:19 GMTcyclops<p>
<a class="ext-link" href="https://docs.djangoproject.com/en/1.3/topics/auth/#django.contrib.auth.models.User.is_authenticated"><span class="icon">​</span>https://docs.djangoproject.com/en/1.3/topics/auth/#django.contrib.auth.models.User.is_authenticated</a>
</p>
<p>
starts with the text:
</p>
<blockquote>
<p>
"Always returns True. This is a way to tell if the user has been authenticated. "
</p>
</blockquote>
<p>
I really <em>hope</em> it doesn't always return True. :)
</p>
<p>
A better wording might be:
</p>
<blockquote>
<p>
"Returns True if the user has been properly authenticated."
</p>
</blockquote>
<p>
This (and related ticket <a class="closed ticket" href="https://code.djangoproject.com/ticket/16635" title="#16635: Bug: Wording in documentation for contrib.auth could be improved on ... (closed: wontfix)">#16635</a>) have really been bugging me for a while, I finally had to post a ticket. :)
</p>
Resultshttps://code.djangoproject.com/ticket/16636#changeloghttps://code.djangoproject.com/ticket/16635
https://code.djangoproject.com/ticket/16635#16635: Wording in documentation for contrib.auth could be improved on is_anonymous()Mon, 15 Aug 2011 14:10:15 GMTcyclops<p>
<a class="ext-link" href="https://docs.djangoproject.com/en/1.3/topics/auth/#django.contrib.auth.models.User.is_anonymous"><span class="icon">​</span>https://docs.djangoproject.com/en/1.3/topics/auth/#django.contrib.auth.models.User.is_anonymous</a>
</p>
<p>
starts with the text:
</p>
<blockquote>
<p>
"Always returns False."
</p>
</blockquote>
<p>
A better wording might be:
</p>
<blockquote>
<p>
"Returns False if the user has not been authenticated, i.e., entered a valid login and password."
</p>
</blockquote>
Resultshttps://code.djangoproject.com/ticket/16635#changeloghttps://code.djangoproject.com/ticket/367
https://code.djangoproject.com/ticket/367#367: Wontfix: may be it's possible to add SQL_EXECUTE_AFTER_CONNECT setting?Thu, 18 Aug 2005 22:36:35 GMTmordaha@…<p>
It is an SQL-string that will be executed after connect to server.
For examle to make some 'SET ..' comands in mysql.
</p>
Resultshttps://code.djangoproject.com/ticket/367#changeloghttps://code.djangoproject.com/ticket/22246
https://code.djangoproject.com/ticket/22246#22246: WizardView.form_list is undocumentedTue, 11 Mar 2014 12:30:58 GMTdjango-issues@…<p>
<a class="ext-link" href="https://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/"><span class="icon">​</span>The WizardView documentation</a> neither documents or provides an example of how to specify which forms the wizard is comprised of. This is made even more confusing by the fact that WizardView.get_form_list() returns an OrderedDict rather than the list one might expect.
</p>
Resultshttps://code.djangoproject.com/ticket/22246#changeloghttps://code.djangoproject.com/ticket/18526
https://code.djangoproject.com/ticket/18526#18526: {% with %} template tag shows strange behaviour if TEMPLATE_STRING_IF_INVALID is non-empty.Wed, 27 Jun 2012 15:24:39 GMTGregor Müllegger<p>
The value that should be assigned to a new one using the <strong>with</strong> template tag breaks if the value is not existend. It uses the value from TEMPLATE_STRING_IF_INVALID to set the new one. But this might break template code in unexpected ways since this usually non-existend variable now evaluates as True in an if statement.
</p>
<p>
See the following snippet:
</p>
<pre class="wiki"># in settings.py
TEMPLATE_STRING_IF_INVALID = '&lt;INVALID&gt;'
</pre><pre class="wiki">In [16]: Template('{% with not_exist as value %}{% if value %}Hello {{ value }}{% endif %}{% endwith %}').render(Context())
Out[16]: u'Hello &amp;lt;INVALID&amp;gt;'
</pre>Resultshttps://code.djangoproject.com/ticket/18526#changeloghttps://code.djangoproject.com/ticket/3826
https://code.djangoproject.com/ticket/3826#3826: `{% with %}` template tagMon, 26 Mar 2007 20:48:41 GMTChris Beaven<p>
Following on from the <a class="ext-link" href="http://groups.google.com/group/django-developers/browse_thread/thread/2f1814c78709420a/#"><span class="icon">​</span>related discussion</a>, here's a ticket for the <code>{% with %}</code> tag.
</p>
Resultshttps://code.djangoproject.com/ticket/3826#changeloghttps://code.djangoproject.com/ticket/11824
https://code.djangoproject.com/ticket/11824#11824: {% with %} tag to support tuplesThu, 03 Sep 2009 11:09:20 GMTIlya Semenov<p>
Currently, that's possible to iterate over a collection of tuples with:
</p>
<pre class="wiki">{% for x, y in points %}
There is a point at {{ x }},{{ y }}
{% endfor %}
</pre><p>
However, given a single tuple, there's no way to extract its items to (temporary) context variables. For example:
</p>
<pre class="wiki">{% with object.get_last_point as point %}
There is a point at {{ point.0 }},{{ point.1 }} -- ugly and unmaintainable
{% endwith %}
</pre><p>
I would like to propose the extension of {% with %} tag to support the following syntax:
</p>
<pre class="wiki">{% with object.get_last_point as x, y %}
There is a point at {{ x }},{{ y }}
{% endwith %}
</pre>Resultshttps://code.djangoproject.com/ticket/11824#changeloghttps://code.djangoproject.com/ticket/8297
https://code.djangoproject.com/ticket/8297#8297: Withblock template tagWed, 13 Aug 2008 22:31:50 GMTJulien Phalip<p>
<strong>Important note</strong>: This ticket can work only if <a class="closed ticket" href="https://code.djangoproject.com/ticket/8296" title="#8296: Allow template parser to parse until &#34;complex&#34; block node (closed: duplicate)">#8296</a> gets checked in.
</p>
<p>
Currently there is the convenient <code>{% with %}</code> tag to create variables in templates. Unfortunately there is no built-in counterpart for blocks. The attached patch does just that, with the following suggested syntax:
</p>
<pre class="wiki">{% withblock as myurl %}
{% url path.to.some_view arg1,arg2,name1=value1 %}
{% and as var %}
{% whatever %}
{% in %}
Click the link: &lt;a href="{{ myurl }}"&gt;link&lt;/a&gt;.
&lt;p&gt;{{ var }}&lt;/p&gt;
{% endwithblock %}
</pre>Resultshttps://code.djangoproject.com/ticket/8297#changeloghttps://code.djangoproject.com/ticket/24579
https://code.djangoproject.com/ticket/24579#24579: With argparse on Python 3, the migrate management command fails when no database providedFri, 03 Apr 2015 21:14:22 GMTBrandon Konkle<p>
On Python 3.4, when 'migrate' is invoked with no --database option, the command fails.
</p>
<pre class="wiki">File "/Users/brandon.konkle/code/django/django/core/management/commands/migrate.py", line 70, in handle
connection = connections[db]
File "/Users/brandon.konkle/code/django/django/db/utils.py", line 234, in __getitem__
if hasattr(self._connections, alias):
TypeError: hasattr(): attribute name must be string
</pre><p>
This is because the newly-introduced argparse resolves <code>db = options.get('database')</code> to <code>None</code>, and Python 3 raises a TypeError when None is used as the first argument to <code>hasattr</code>.
</p>
Resultshttps://code.djangoproject.com/ticket/24579#changeloghttps://code.djangoproject.com/ticket/12891
https://code.djangoproject.com/ticket/12891#12891: wishlist: allow .dates() query to span relationsWed, 17 Feb 2010 10:14:32 GMTTilman Koschnick<p>
At the moment, the dates() query only accepts field parameters that do not span relations. It would be nice if support for more complex cases was added, so that a query like this would be possible:
</p>
<pre class="wiki">queryset.dates('foreignkey__date', 'year')
</pre><p>
I currently use the following hack to work around this:
</p>
<pre class="wiki"> # check if date_field spans relations
fields = date_field.split('__')
for field in fields[:-1]:
relation_field = getattr(queryset.model, field)
queryset = relation_field.field.rel.to.objects.all()
dates = queryset.dates(fields[-1], 'year')
</pre>Resultshttps://code.djangoproject.com/ticket/12891#changeloghttps://code.djangoproject.com/ticket/11781
https://code.djangoproject.com/ticket/11781#11781: Wish: FILE_UPLOAD_DIRECTORY_PERMISSIONSMon, 24 Aug 2009 20:15:57 GMTmichal.dtz@…<p>
Please add this variable to global_settings.py
</p>
<p>
Then, in django.core.files.storage, use
os.makedirs(directory, settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS)
</p>
<p>
Some people (like me) need this settings - and it is relativley easy to add it. Pretty please :-)
</p>
Resultshttps://code.djangoproject.com/ticket/11781#changeloghttps://code.djangoproject.com/ticket/16420
https://code.djangoproject.com/ticket/16420#16420: Windows 7 and Vista support symbolic linksTue, 05 Jul 2011 18:50:28 GMTdpjh70100@…<p>
Page: <a class="ext-link" href="https://docs.djangoproject.com/en/dev/topics/install/#installing-development-version"><span class="icon">​</span>https://docs.djangoproject.com/en/dev/topics/install/#installing-development-version</a>
</p>
<p>
It should be noted in point 4, that you can create a symbolic link in Windows 7/Vista as well as Unix, using the mklink command (in this example, I created a bin directory under my user folder and added it to my path):
</p>
<pre class="wiki">mklink \Users\CURRENT-USER\bin\django-admin.py WORKING-DIR\django-trunk\django\bin\django-admin.py
</pre>Resultshttps://code.djangoproject.com/ticket/16420#changeloghttps://code.djangoproject.com/ticket/24430
https://code.djangoproject.com/ticket/24430#24430: wildcard matching and reversing of URLsSat, 28 Feb 2015 09:53:39 GMTAnshuman Aggarwal<p>
Example:
</p>
<pre class="wiki">urlpatterns += patterns('',
(r'^\w+/', include(admin.site.urls),),
)
</pre><p>
All links generated by the admin site with this url show a 'x'
for example : <code>/x/&lt;app_name&gt;/&lt;model_name&gt;/</code>
</p>
<p>
instead of the result of the matching wild card 'ABC' from <code>ABC/&lt;app_name&gt;/&lt;model_name&gt;</code>
</p>
<p>
the problem is that reverse can not know what to put in the wild card without having the path or the request as context.
</p>
<p>
Solution: add an optional parameter to reverse which is the request and the reverse can happen with the context of the request which is found acceptable in case the request parameter is not none.
</p>
Resultshttps://code.djangoproject.com/ticket/24430#changeloghttps://code.djangoproject.com/ticket/12026
https://code.djangoproject.com/ticket/12026#12026: widthratio rounding option/filterTue, 13 Oct 2009 15:39:44 GMTopeninformation <nospam@…><p>
The widthratio tag is great for displaying quick graphs and percentages. The only "problem" is that it rounds to 0 digits after the decimal point. That often adds up to percentages &gt; 100%.
</p>
<p>
It would be great if one could specify a filter that controls the number of digits behind the decimal point.
</p>
Resultshttps://code.djangoproject.com/ticket/12026#changeloghttps://code.djangoproject.com/ticket/4616
https://code.djangoproject.com/ticket/4616#4616: Widgets should be able to rendered separatelyMon, 18 Jun 2007 20:48:07 GMTfero <luca.ferroni@…><p>
Hello, I spent this evening in trying to make the SplitDateTimeWidget working in the template.
I get a bound_field and I'd like to split visualization of date and time like this:
</p>
<p>
{% load i18n %}
&lt;p class="datetime"&gt;
</p>
<blockquote>
<p>
{% trans "Date:" %} a {{ bound_field.form.fields.datetime_start.fields.0 }}&lt;br /&gt;
{% trans "Time:" %} b {{ bound_field.field.fields.1.widget }}
</p>
</blockquote>
<p>
&lt;/p&gt;
</p>
<p>
I can't make it works ! I tried many permutations of the components form, fields, field_name and widget and I've never reached a results.
Please correct this bug asap.
</p>
Resultshttps://code.djangoproject.com/ticket/4616#changeloghttps://code.djangoproject.com/ticket/28945
https://code.djangoproject.com/ticket/28945#28945: widgets.Input should support non-app custom template_namesTue, 19 Dec 2017 14:03:55 GMTJonas Haag<p>
If you make your own <code>django.forms.widgets.Input</code> subclass an overwrite the <code>template_name</code> argument, Django will only look in <code>django/forms/templates/</code> and in your app dirs, but not in any templates defined in a <code>settings.TEMPLATES[...]['DIRS']</code> dir.
</p>
<pre class="wiki">class MyInput(widgets.Input):
template_name = 'foo.html'
</pre><p>
Even if I have <code>spam/templates</code> in <code>DIRS</code>, it won't look for <code>spam/templates/foo.html</code>.
</p>
<p>
We should at least document this.
</p>
Resultshttps://code.djangoproject.com/ticket/28945#changeloghttps://code.djangoproject.com/ticket/2083
https://code.djangoproject.com/ticket/2083#2083: Why is the username field in "django/contrib/auth/models.py" restricted?Sun, 04 Jun 2006 21:08:55 GMTdjangoproject.com@…<p>
Why is the username field for a user in django restricted to: 30 chars, alphanumeric?
</p>
<p>
It is more use to everybody who wants to be "more open" with his site when the username can be (nearly) anything. Let the site-creator decide (using his own validators) how the username should look like for his site.
</p>
<p>
So:
</p>
<pre class="wiki">username = models.CharField(_('username'), maxlength=30, unique=True, validator_list=[validators.isAlphaNumeric])
</pre><p>
should be changed to something like:
</p>
<pre class="wiki">username = models.CharField(_('username'), maxlength=255, unique=True)
</pre><p>
Regards, Alex
</p>
Resultshttps://code.djangoproject.com/ticket/2083#changeloghttps://code.djangoproject.com/ticket/1933
https://code.djangoproject.com/ticket/1933#1933: why do settings exist in code (settings.py) and not in a (potentially remote) XML config file?Fri, 19 May 2006 19:03:53 GMTeetheband@…<p>
After playing around with Django quite a bit (and loving it for the most part), and talking with a fellow developer friend who also gave it a whirl - we both a agreed that having settings inside actual code was really inconvenient (and bad design for the most part). Why is it like this? Why not put these 'settings' in an xml file, that can then be placed outside your build directory, for easy maintainability and reusability? -Thanks for your work.
</p>
Resultshttps://code.djangoproject.com/ticket/1933#changeloghttps://code.djangoproject.com/ticket/20848
https://code.djangoproject.com/ticket/20848#20848: Whitespace in PythonThu, 01 Aug 2013 22:48:36 GMTwill@…<p>
Great tutorial - as I noted in another ticket. White space issues killed my code at one point in the tutorial. I figured it out pretty quickly, but I haven't had to think about white space to that degree in other languages(though I do try to keep it consistent). Might be worth a note in the tutorial. I had problems when I copied code from the browser, and placed it in with my hand-entered code.
</p>
<p>
--Will
</p>
Resultshttps://code.djangoproject.com/ticket/20848#changeloghttps://code.djangoproject.com/ticket/27336
https://code.djangoproject.com/ticket/27336#27336: Whitespace control django configuration templateWed, 12 Oct 2016 12:00:04 GMTRamin Farajpour Cami<p>
Hi,
</p>
<p>
i see on django admin panle,there isn't Whitespace control on jinja2 template ,so i think django can not support defulat whitespace control, this means <code>trim_blocks</code> and <code>lstrip_blocks enabled</code> is disbale,
</p>
<p>
Jinja2 WhiteSpace Control is what you need :
<a class="ext-link" href="http://jinja.pocoo.org/docs/templates/#whitespace-control"><span class="icon">​</span>http://jinja.pocoo.org/docs/templates/#whitespace-control</a>
</p>
Resultshttps://code.djangoproject.com/ticket/27336#changeloghttps://code.djangoproject.com/ticket/862
https://code.djangoproject.com/ticket/862#862: Which field caused method_save to bomb out?Mon, 21 Nov 2005 01:48:04 GMTgarthk<p>
If method_save fails whilst trying to call pre_save on a field, it can be tricky to figure out which field caused the problem without wading to exactly the right place in the stack frame or riddling meta\<span class="underline">init.py</span> with debugging code. To save everyone the effort, I've got a patch that'll append a descriptive message to the exception's arguments so the errant field name is obvious and easy to find from the last line of the traceback.
</p>
Resultshttps://code.djangoproject.com/ticket/862#changeloghttps://code.djangoproject.com/ticket/10610
https://code.djangoproject.com/ticket/10610#10610: When you run syncdb for the first time with django.contrib.auth you are forced to input an email addressTue, 24 Mar 2009 17:12:00 GMTDavid Reynolds<p>
The email address field on the User model isn't a required field, so why should you be forced to enter an email address by this?
</p>
Resultshttps://code.djangoproject.com/ticket/10610#changeloghttps://code.djangoproject.com/ticket/25042
https://code.djangoproject.com/ticket/25042#25042: When user is authenticated using external (REMOTE_USER) authentication, their attributes should get updated if the external environment provides the dataWed, 01 Jul 2015 12:22:56 GMTJan Pazdziora<p>
When external authentication is used, the traditional result is the username, passed to application via REMOTE_USER or similar mechanism.
</p>
<p>
With user identities being primarily managed outside of applications' user databases, user records in applications' databases (that need to be created so that foreign keys have parents) will increasingly be created during the first successful login. While the username might be enough for some applications, some might want the full set of attributes including the name and email address to get filled based on the data from the external identity/authentication source.
</p>
<p>
Since <code>AbstractUser</code> defines <code>first_name</code>, <code>last_name</code>, and <code>email</code>, I propose these attributes to be populated upon successful external authentication. The source of this data could be <code>REMOTE_USER_FIRSTNAME</code>, <code>REMOTE_USER_LASTNAME</code>, and <code>REMOTE_USER_EMAIL</code> based on the proposal at <a class="ext-link" href="http://www.freeipa.org/page/Environment_Variables#Proposed_Additional_Variables"><span class="icon">​</span>http://www.freeipa.org/page/Environment_Variables#Proposed_Additional_Variables</a>.
</p>
<p>
With mod_auth_mellon 0.10.10 (for SAML), the configuration to populate these variables is
</p>
<pre class="wiki">MellonSetEnvNoPrefix REMOTE_USER_FIRSTNAME givenname
MellonSetEnvNoPrefix REMOTE_USER_LASTNAME fullname
MellonSetEnvNoPrefix REMOTE_USER_EMAIL email
</pre><p>
With mod_lookup_identity, the configuration would typically be
</p>
<pre class="wiki">LookupUserAttr givenname REMOTE_USER_FIRSTNAME
LookupUserAttr sn REMOTE_USER_LASTNAME
LookupUserAttr mail REMOTE_USER_EMAIL
</pre>Resultshttps://code.djangoproject.com/ticket/25042#changeloghttps://code.djangoproject.com/ticket/18794
https://code.djangoproject.com/ticket/18794#18794: When timezone support is enabled, permalinks for DateDetailView are impossible.Sat, 18 Aug 2012 21:47:03 GMTAlexey Boriskin<p>
With timezone support enabled, permalinks for <code>DateDetailView</code> are hard to create.
</p>
<p>
As clearly stated in docstring of <code>DateMixin._make_date_lookup_arg</code>,
</p>
<pre class="wiki"> When time zone support is enabled, `date` is assumed to be in the
current time zone, so that displayed items are consistent with the URL.
</pre><p>
As current time zone is a time zone of the current user, web site should generate different urls for different users in order them view same content and not 404 page. That's weird: we don't have permalinks anymore. User in Moscow may send a link to <code>DateDetailView</code> to another user in New York, and that user will see 404 page. Or it may be <code>DayArchiveView</code>, and user in New York will see another set of records.
</p>
<p>
I may be not understanding something, as last test in <code>regressiontests.generic_views.dates</code> even checks for this 404. But what is the way I should generate worldwide accessible permalinks?
</p>
Resultshttps://code.djangoproject.com/ticket/18794#changeloghttps://code.djangoproject.com/ticket/13022
https://code.djangoproject.com/ticket/13022#13022: when saving a model with m2m field in the admin, 'clear' and 'add' m2m_changed signals are fired even when there is no change.Wed, 03 Mar 2010 20:24:02 GMTbenc<p>
I've built a simple test project with one app and two models, Model1 and Model2.
Model2 has a ManyToManyField to Model1.
I've created one Model1 instance and one Model2 instance with a relation to the Model1 instance.
</p>
<p>
When saving the Model2 instance in the admin, even without a change, m2m_changed fires twice.
I think it shouldn't fire at all when the admin form is saved without a change:
</p>
<pre class="wiki">sender &lt;class 'testproject.testapp.models.Model2_models1'&gt;
instance Model2 object
action clear
model &lt;class 'testproject.testapp.models.Model1'&gt;
sender &lt;class 'testproject.testapp.models.Model2_models1'&gt;
instance Model2 object
action add
model &lt;class 'testproject.testapp.models.Model1'&gt;
</pre>Resultshttps://code.djangoproject.com/ticket/13022#changeloghttps://code.djangoproject.com/ticket/2030
https://code.djangoproject.com/ticket/2030#2030: When hitting a problem with an upload the DEBUG screen will display full file contentsMon, 29 May 2006 10:36:11 GMTasmodai@…<p>
Currently when you are testing file uploads and you hit a problem you will get a DEBUG screen which will have your FileField data in the debugging information. The only downside is that if you have a file of, say, 5 MB, the DEBUG screen will show all 5 MB of that data in the appropriate dict value for the FileField key.
This is not what you would want to see because it in general will slow your browser down considerably.
Perhaps this can be stripped/masked out before dumping into the DEBUG screen.
</p>
Resultshttps://code.djangoproject.com/ticket/2030#changeloghttps://code.djangoproject.com/ticket/2213
https://code.djangoproject.com/ticket/2213#2213: when an AddManipulator returns with errors, the foreign key field chosen is not shownThu, 22 Jun 2006 09:29:28 GMTlawgon@…<p>
When using AddManipulator on a model with a foreign key, when the form is returned with errors, the foreign key choice is not shown on the form although the view is aware of it.
</p>
Resultshttps://code.djangoproject.com/ticket/2213#changeloghttps://code.djangoproject.com/ticket/8772
https://code.djangoproject.com/ticket/8772#8772: When a get_object_or_404 returns a 404, it'd be nice if it would return which query didn't provide an object (when DEBUG=True)Mon, 01 Sep 2008 21:20:34 GMTBeetle_B<p>
I recently had an error in a query in a context processor. When I tried to go to a certain page, I got the error:
</p>
<p>
"No CollabProject matches the given query".
</p>
<p>
And practically no other information. No trackbacks or anything. No indication of which file the error was in. Just that message and a 404.
</p>
<p>
I kept checking and couldn't find any error in my view. I even confirmed that the view executed to the end.
</p>
<p>
It was only by chance that I discovered the error in the context processor.
</p>
<p>
Isn't there a way to have it such that if the error occurs in a context processor, it can point to the line in the context processor that had the bad query?
</p>
<p>
BTW, by bad query I mean a valid query that doesn't return any objects in the database.
</p>
<p>
I suspect this may be a problem with such a query in a middleware, but did not experiment.
</p>
Resultshttps://code.djangoproject.com/ticket/8772#changeloghttps://code.djangoproject.com/ticket/21838
https://code.djangoproject.com/ticket/21838#21838: What about adding a .reload() method to the QuerySet API?Tue, 21 Jan 2014 10:25:56 GMTfero@…<p>
Sometimes it is needed to reload data from database backend. It could be necessary in example to benefit of some values type-casting applied by the database backend module.
</p>
<p>
In various Django projects I developed I find useful a simple method QuerySet.reload() like this:
</p>
<pre class="wiki"> def reload(self):
"""Reload QuerySet from backend."""
pks_list = self.values_list('pk')
return self.model.objects.filter(pk__in=pks_list)
</pre>Resultshttps://code.djangoproject.com/ticket/21838#changeloghttps://code.djangoproject.com/ticket/13005
https://code.djangoproject.com/ticket/13005#13005: We need a way to allow for request/user specific default values in the admin fieldsTue, 02 Mar 2010 02:18:09 GMThejsan<p>
I propose a new function in line with the get_readonly_fields(self, request, obj=None) function in the ModelAdmin class.
</p>
<p>
It could have the following signature:
</p>
<pre class="wiki">def default_value_for_formfield(self, request, field_name, obj=None)
</pre><p>
And by default return None (or "") or in the case of a ModelForm, it should of return the default value of the related Model.
</p>
<p>
This is usefull because it could then be overridden in our ModelAdmin subclass to return different values dependant on for example the permissions of the currently logged in user:
</p>
<pre class="wiki">def default_value_for_formfield(self, request, field_name, obj=None)
super(NewsArticleAdmin, self).default_value_for_formfield(self, request, field_name, obj)
user = request.user
if not user.is_superuser:
if 'categories' == field_name:
if not user.has_perm('news.choose_category'):
return PK_OF_SOME_CATEGORY
if 'authors' == field_name:
if not user.has_perm('news.choose_author'):
# Can only mark him/herself as author
return user.pk
return super(NewsArticleAdmin, self).default_value_for_formfield(self, request, field_name, obj)
</pre><p>
I know that this functionality could be made happen using the save_model() method of the ModelAdmin class, but this way is still prettier, it looks better to the end user to have the actual name of the category displayed instead of (None) in the case of readonly fields and reliefs any ambiguity.
</p>
<p>
This makes the new get_readonly_fields() method all the more usefull.
</p>
Resultshttps://code.djangoproject.com/ticket/13005#changeloghttps://code.djangoproject.com/ticket/17771
https://code.djangoproject.com/ticket/17771#17771: weird problem db with autocommitSat, 25 Feb 2012 21:33:41 GMTmeister<p>
Hello,
</p>
<p>
Here is problematic code (standard django setup, mysql backend):
</p>
<pre class="wiki">import time
import os, sys, re
sys.path.append(os.path.abspath(os.path.dirname(__file__))+'/..')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from django.conf import settings
from django.contrib.auth.models import User
#from django.db import connection
#cursor = connection.cursor()
#cursor.execute('SET autocommit = 1')
while True:
u = User.objects.get(pk=1)
print u.first_name
time.sleep(1)
</pre><p>
It displays user first_name each second. On the other hand with mysql client :
</p>
<pre class="wiki">$ update auth_user set first_name = "foo" where id=1;
</pre><p>
Value does not update in my loop (wireshark shows the old value too in the mysql packets dumped). If I restart the process, it fetch the correct new value.
I can fix the problem by adding the 3 autocommit lines commented out.
</p>
<p>
Problem do not occur on my ubuntu 32b desktop (32bits django 1.3.1 / MySQL-python 1.2.3, mysql 5.1.58) nor a debian squeeze server (32bits mysql 5.1.49).
</p>
<p>
Problem occurs on a 64 bits debian squeeze server (64bits mysql 5.1.49) and a ubuntu 64 server (64 bits mysql 5.1.41).
</p>
<p>
Thanks.
</p>
Resultshttps://code.djangoproject.com/ticket/17771#changeloghttps://code.djangoproject.com/ticket/10345
https://code.djangoproject.com/ticket/10345#10345: 'week_day' lookup type should use python's values for lookupTue, 24 Feb 2009 13:59:38 GMTFlorian Sening<p>
<a class="closed ticket" href="https://code.djangoproject.com/ticket/7672" title="#7672: Add filter for 'Day of week' on Date / DateTime fields (closed: fixed)">#7672</a> introduced a new lookup type for weekdays that was committed in <a class="changeset" href="https://code.djangoproject.com/changeset/9818/">[9818]</a>. The problem are that values that it uses. There already was some discussion about the values but they eventually settled on Sunday=1 and Saturday=6. Imho this is not the best decision. Of course it is obvious that they ended up with these values because that's what the databases are using mostly but there are problems when used with e.g. Python internals.
Python always starts with Monday being the first day of the week whether you use weekday() (Monday=0) or isoweekday() (Monday=1). The Python behaviour also conforms to national/international standards and recommendations like ISO 8601 or DIN 1355 where it also starts with Monday being the first day of the week.
</p>
<p>
I looked at the code and i know that it requires some conversion and changes for this but it would be even worse if you had to do that conversion every time you're using that django feature. So my suggestions is to change the behaviour to that of Python's weekday().
</p>
Resultshttps://code.djangoproject.com/ticket/10345#changeloghttps://code.djangoproject.com/ticket/247
https://code.djangoproject.com/ticket/247#247: Webpage to list web hostsTue, 02 Aug 2005 14:19:20 GMTEric Windisch<p>
It would be useful to have a webpage (preferably Wiki) where web hosts supporting Django can be listed and found.
</p>
<p>
The following is a suggested layout (with supported installation methods in italics)
</p>
<hr />
<p>
<a class="ext-link" href="http://example.com/"><span class="icon">​</span>Example Host</a> - Some description about the provider, this can be a paragraph of text so that they can express all the information they wish to.
<em>mod_python, fcgi</em>
</p>
<p>
<a class="ext-link" href="http://example.com"><span class="icon">​</span>Lame Host</a> - Some support for some applications and other stuff that is stuff and that stuff is stuff too.
<em>cgi</em>
</p>
<p>
<a class="ext-link" href="http://example.com"><span class="icon">​</span>Boring.net</a> - Support for nothing but everything and everything that is nothing, except when it isn't.
<em>mod_snake</em>
</p>
Resultshttps://code.djangoproject.com/ticket/247#changeloghttps://code.djangoproject.com/ticket/3744
https://code.djangoproject.com/ticket/3744#3744: Warn that Generic Relations are a prototype feature (in the right places).Fri, 16 Mar 2007 08:27:00 GMTenlight<p>
There was a thread on django-users recently ("GenericRelation and serialization") where Russell Keith-Magee wrote:
"GenericRelations are a bit of a wierd case - they're available in Django, but they're still a prototype feature - they're not fully documented, and they're not as well tested as other aspects of Django."
</p>
<p>
This was a bit of a shock to me, I knew they were barely documented, but I didn't realise they were a prototype feature. Since I didn't recall any such warning in the scarce documentation on generic relations - I went looking for it, sure enough I found it at the end of the "Branches in development" section over on this page <a class="ext-link" href="http://code.djangoproject.com"><span class="icon">​</span>http://code.djangoproject.com</a>. That explains why I didn't recall it, I wasn't expecting any of the text in that section to apply to the trunk.
</p>
<p>
The warning should really be moved to the following places where I would've actually noticed and paid attention to it:
</p>
<p>
<a class="ext-link" href="http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/generic.py"><span class="icon">​</span>http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/generic.py</a>
and
<a class="ext-link" href="http://www.djangoproject.com/documentation/models/generic_relations/"><span class="icon">​</span>http://www.djangoproject.com/documentation/models/generic_relations/</a>
</p>
<p>
I'll see about creating a patch for this tomorrow.
</p>
Resultshttps://code.djangoproject.com/ticket/3744#changeloghttps://code.djangoproject.com/ticket/16422
https://code.djangoproject.com/ticket/16422#16422: Warnings when building the docs in epub formatTue, 05 Jul 2011 21:34:39 GMTAymeric Augustin<p>
I guess it's ultra-low priority, but it was reported in the comments of <a class="closed ticket" href="https://code.djangoproject.com/ticket/16414" title="#16414: New feature: Missing Windows build script for Sphinx (closed: fixed)">#16414</a>:
</p>
<pre class="wiki">
docs % make epub
sphinx-build -b epub -d _build/doctrees . _build/epub
Making output directory...
Running Sphinx v1.0.5
loading pickled environment... not yet created
building [epub]: targets for 219 source files that are out of date
updating environment: 219 added, 0 changed, 0 removed
reading sources... [100%] topics/testing
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] topics/testing
writing additional files... genindex py-modindex search
copying images... [100%] internals/_images/djangotickets.png
copying downloadable files... [100%] ref/contrib/gis/create_template_postgis-debian.sh
copying static files... done
writing mimetype file...
writing META-INF/container.xml file...
writing content.opf file...
WARNING: unknown mimetype for _downloads/create_template_postgis-1.3.sh, ignoring
WARNING: unknown mimetype for _downloads/create_template_postgis-1.4.sh, ignoring
WARNING: unknown mimetype for _downloads/create_template_postgis-1.5.sh, ignoring
WARNING: unknown mimetype for _downloads/create_template_postgis-debian.sh, ignoring
WARNING: unknown mimetype for _downloads/geodjango_setup.bat, ignoring
WARNING: unknown mimetype for _static/doctools.js, ignoring
WARNING: unknown mimetype for _static/jquery.js, ignoring
WARNING: unknown mimetype for _static/searchtools.js, ignoring
WARNING: unknown mimetype for _static/underscore.js, ignoring
writing toc.ncx file...
writing Django.epub file...
build succeeded, 9 warnings.
Build finished. The epub file is in _build/epub.
</pre>Resultshttps://code.djangoproject.com/ticket/16422#changeloghttps://code.djangoproject.com/ticket/24891
https://code.djangoproject.com/ticket/24891#24891: Warn if referencing a template by the same name as one in an installed app with higher precedenceMon, 01 Jun 2015 14:03:33 GMTMarkus Amalthea Magnuson<p>
Due to how precedence works when looking up templates, you can write an app that e.g. in one of its views references a template name in the same app, but that will never actually be used if one by the same name exists in another app that is listed earlier in <code>INSTALLED_APPS</code>.
</p>
<p>
This can be quite a surprise and frustration if you are not aware of it, trying to debug why your template is not being used. The common solution is to have an additional subdirectory in the app template folder, named like the app itself. But you will have to find that out first, somehow.
</p>
<p>
I'd suggest some kind of warning is emitted if an installed app is referencing a template name that also exists in another installed app with higher precedence. The warning would ideally only happen if that template actually exists in the app with lower precedence.
</p>
<p>
What do you think?
</p>
Resultshttps://code.djangoproject.com/ticket/24891#changeloghttps://code.djangoproject.com/ticket/6892
https://code.djangoproject.com/ticket/6892#6892: Warn about raw "%" in redirect_to strings.Wed, 26 Mar 2008 09:05:02 GMTdaonb <bennydaon@…><p>
from my urls.py:
</p>
<pre class="wiki">url(r'^password/change/done/$',
django.views.generic.simple.redirect_to,
{'url': '/toviva/myroom/?' + urlencode({'message': _('Password change successful')})})
</pre><p>
When I access the url I get an error:
</p>
<pre class="wiki">ValueError at /toviva/accounts/password/change/done/
unsupported format character 'D' (0x44) at index 25
</pre><p>
printing the url parameters in redirect_to:
</p>
<pre class="wiki">/toviva/myroom/?message=%D7%94%D7%A1%D7%99%D7%A1%D7%9E%D7%94+%D7%A9%D7%95%D7%A0%D7%AA%D7%94+%D7%91%D7%94%D7%A6%D7%9C%D7%97%D7%94
</pre><p>
In redirect_to the line that fails is:
</p>
<pre class="wiki"> return HttpResponsePermanentRedirect(url % kwargs)
</pre><p>
I found another way to do it:
</p>
<pre class="wiki"> url(r'^password/change/done/$',
django.views.generic.simple.redirect_to,
{'url': '/toviva/myroom/?message=%(message)s', 'message': urlquote_plus(_('Password change successful'))}),
</pre><p>
Which works for me, but still - I'd be happy if someone can find a way to make redirect_to more robust.
</p>
Resultshttps://code.djangoproject.com/ticket/6892#changeloghttps://code.djangoproject.com/ticket/27500
https://code.djangoproject.com/ticket/27500#27500: Warn about potentially significant performance degrading schema changes when making/running migrationsWed, 16 Nov 2016 18:03:05 GMTOliver Bristow<p>
Today we ran a migration which removed a unique=True constraint on a char field for a MySQL database, this implicitly removed the indexing on the column which caused significant performance problems.
</p>
<p>
It didn't take too long to work out the mistake, but it would be nice if there was more of a fuss made when things like (implicit) index removal occur.
</p>
<p>
Hopefully this way developers are less likely to overlook or not be aware of such things, and also help pinpoint the source of an issue after an update.
</p>
Resultshttps://code.djangoproject.com/ticket/27500#changeloghttps://code.djangoproject.com/ticket/4984
https://code.djangoproject.com/ticket/4984#4984: Want support for conditional links in templatesThu, 26 Jul 2007 21:31:22 GMTdaniel@…<p>
First off -- thanks for Django, it's spectacularly awesome.
</p>
<p>
One small thing that would improve my life greatly:
Right now, I have a linkbar generated with '&lt;a href="{% url one %}"&gt;one&lt;/a&gt; &lt;a href="{% url two %}"&gt;two&lt;/a&gt; &lt;a href="{% url three %}"&gt;three&lt;/a&gt;', etc. However, I would like this to not generate links to the current page: i.e., if I'm already on two, I want one and three to be links, and two to just be plain text. A filter like '{% cond_url_link some.app.here one %}', maybe with an optional style class or so, that generates the entire link struct for me: &lt;a href="/url/here/"&gt;desc&lt;/a&gt; if it's a different page, but just the description if we're already on that same page.
</p>
<p>
Thanks again!
</p>
Resultshttps://code.djangoproject.com/ticket/4984#changeloghttps://code.djangoproject.com/ticket/14884
https://code.djangoproject.com/ticket/14884#14884: Visible form <input>s and <textarea> should use the "required" attributeFri, 10 Dec 2010 20:13:00 GMTpaulc<p>
Per HTML5, as well as to have the ability to style required fields differently, visible form fields should output with the "required" attribute if they are required, e.g.
</p>
<pre class="wiki">&lt;input type="text" name="..." id="..." required&gt;
</pre><p>
That may just be a matter of changing the default widget_attrs to return "required" by default and add to that in subclasses, e.g.
</p>
<pre class="wiki">class Field(object):
# ...
def widget_attrs(self, widget):
return {'required': 'required'}
</pre><p>
It would be even better if there was a way to output just "required", but that would require changes to forms.util.flatatt as far as I can tell.
</p>
<p>
I'm up to submit a patch if this seems like a good direction, etc.
</p>
Resultshttps://code.djangoproject.com/ticket/14884#changeloghttps://code.djangoproject.com/ticket/17021
https://code.djangoproject.com/ticket/17021#17021: views.generic.create_update.lo okup_object uses .objects instead of the default managerSat, 08 Oct 2011 18:39:17 GMTGuilherme Salgado<p>
It should use the default manager as the model passed to it may not have a .objects attribute.
</p>
Resultshttps://code.djangoproject.com/ticket/17021#changeloghttps://code.djangoproject.com/ticket/6037
https://code.djangoproject.com/ticket/6037#6037: View on years-months-days in databrowse's calendar pluginTue, 27 Nov 2007 10:50:30 GMTjan2ary<p>
For now calendar plug-in lists entries by years, then by months and then list of objects associated with this month. I think there should be one more level showing days of months and then objects associated with selected day.
</p>
Resultshttps://code.djangoproject.com/ticket/6037#changeloghttps://code.djangoproject.com/ticket/458
https://code.djangoproject.com/ticket/458#458: "View on site" doesn't link to model's get_absoulte_url() methodSun, 04 Sep 2005 07:20:40 GMTigor@…<p>
"View on site" button doesn't link to model's get_absolute_url() method, but shows something like '/r/12/1/'. It could be observed on the generic Users model.
</p>
Resultshttps://code.djangoproject.com/ticket/458#changeloghttps://code.djangoproject.com/ticket/125
https://code.djangoproject.com/ticket/125#125: View-Controller separation violationWed, 20 Jul 2005 22:13:00 GMTmaurycy<p>
For example, django.views.admin.main:
</p>
<pre class="wiki"> if lookup_opts.admin.search_fields:
raw_template.append('&lt;div id="toolbar"&gt;\n&lt;form id="changelist-search" action="" method="get"&gt;\n')
raw_template.append('&lt;label&gt;&lt;img src="%simg/admin/icon_searchbox.png" /&gt;&lt;/label&gt; ' % ADMIN_MEDIA_PREFIX)
raw_template.append('&lt;input type="text" size="40" name="%s" value="%s" id="searchbar" /&gt; ' % \
(SEARCH_VAR, escape(query)))
</pre><p>
Shouldn't it be done only with templates?
</p>
Resultshttps://code.djangoproject.com/ticket/125#changeloghttps://code.djangoproject.com/ticket/6655
https://code.djangoproject.com/ticket/6655#6655: Very little refactoring of get_svn_revision()Sun, 24 Feb 2008 23:37:55 GMTIvan Illarionov<p>
Just fewer lines of code that do the same thing more clear (in my opinion).
</p>
Resultshttps://code.djangoproject.com/ticket/6655#changeloghttps://code.djangoproject.com/ticket/3971
https://code.djangoproject.com/ticket/3971#3971: Verbose testing framework does not say which test it is about to executeMon, 09 Apr 2007 04:46:32 GMTMalcolm Tredinnick<p>
Some of the changes I'm making at the moment have the side-effect of breaking tests <em>very early</em> in their execution (when table flushing fails, for example). The problem is, even when running with -v2, I get no indication of which test it was trying to run. The verbose output only seems shows output that didn't cause the harness itself to fail.
</p>
<p>
I'm not sure how feasible it is to implement, but it would be nice for times to like this to have a -v3 option that said something like "About to attempt modeltests.model_forms.models", so that if I break the harness itself, I know where to look. I had to resort to running each directory in tests/modeltests/ one at a time until I saw the breakage (tests aren't run in any particularly predictable order, that I can see). Not the end of the world, but time consuming and a little tiring the third or fourth time it happened.
</p>
Resultshttps://code.djangoproject.com/ticket/3971#changeloghttps://code.djangoproject.com/ticket/4829
https://code.djangoproject.com/ticket/4829#4829: verbose_name(_plural) not accessible in templates (contrib.contenttype)Tue, 10 Jul 2007 12:50:54 GMTDavid Danier <goliath.mailinglist@…><p>
I created an history application similar to <a class="ext-link" href="http://code.djangoproject.com/wiki/FullHistory"><span class="icon">​</span>http://code.djangoproject.com/wiki/FullHistory</a>, so I have a table with a generic relation (object_id and content_type-fields). Now I created a template that should list all recent changes. As the content-type differs I want to this it in the output. But <code> {{ entry.content_type.model_class._meta.verbose_name }} </code> ist not accessible as "_meta" begins with an underscore.
</p>
<p>
As I did not find any way to get to verbose_name while dir()'ing through the Model-classes, I created a small patch that adds model_verbose_name() and model_verbose_name_plural()-methods to the ContentType-Model. So this is possible: <code> {{ entry.content_type.model_verbose_name }} </code>
</p>
<p>
As I know this is redundant and will not be needed by many people I think the chances to get this into the trunk are not that big. On the other hand it does not change many things.
</p>
Resultshttps://code.djangoproject.com/ticket/4829#changeloghttps://code.djangoproject.com/ticket/25810
https://code.djangoproject.com/ticket/25810#25810: verbose_name_plural is not respected in filter_horizontal or filter_vertical widgetTue, 24 Nov 2015 18:51:11 GMTJens-Erik Weber<p>
When using the filter_horizontal or filter_vertical widget in the admin section, verbose_name_plural should appear in the selection labels, but in fact only the class name in lower case appears.
</p>
<p>
In Ticket <a class="closed ticket" href="https://code.djangoproject.com/ticket/14869" title="#14869: The filter_horizontal widget converts the fields 'verbose_name_plural' ... (closed: invalid)">#14869</a> there was a report mentioning that verbose_name_plural appears in lower case, but that’s not case in the current version.
</p>
<p>
It also doesn’t matter what verbose_name is set to. So the problem is not mixing up singular and plural.
</p>
Resultshttps://code.djangoproject.com/ticket/25810#changeloghttps://code.djangoproject.com/ticket/3373
https://code.djangoproject.com/ticket/3373#3373: verbose_name_plural and internationalizationFri, 26 Jan 2007 21:28:28 GMTVitek<p>
In Czech (Polish, Russian etc..) are more than 2 forms. In English: 1 object, 2+ objects. We have: 1 objekt; 2-4 objekty; 0, 5+ objektů.
So if I define verbose_name and verbose_name_plural, translation in Admin interface under list of objects and other places, where i wont use it, is not correct.
Maybe there is a way to use ngettext (optional, for i18n sites) for verbose_name_plural, but i didn't found this.
</p>
Resultshttps://code.djangoproject.com/ticket/3373#changeloghttps://code.djangoproject.com/ticket/2123
https://code.djangoproject.com/ticket/2123#2123: verbose_name in manipulatorsFri, 09 Jun 2006 07:46:03 GMTGacha<p>
When django throws an error message in manipulators, then the message contains field names, but not the verbose_names of fields in models.
</p>
Resultshttps://code.djangoproject.com/ticket/2123#changeloghttps://code.djangoproject.com/ticket/23111
https://code.djangoproject.com/ticket/23111#23111: Vendor inspect.getcallargs for Jython 2.7 supportSun, 27 Jul 2014 09:41:36 GMTanonymous<p>
<code>inspect.getcallargs</code> is not available in Jython 2.7. I'm shure this is something that should be fixed in Jython too, a workaround in Django would be easy to implement and has no drawbacks to the standard CPython implementation.
</p>
Resultshttps://code.djangoproject.com/ticket/23111#changeloghttps://code.djangoproject.com/ticket/26074
https://code.djangoproject.com/ticket/26074#26074: Vendor GIS js to circumvent mixed contentTue, 12 Jan 2016 19:26:26 GMTJosh Schneier<p>
The inclusion of <code>http://openlayers.org/api/2.13.1/OpenLayers.js</code> (and presumably <code>http://www.openstreetmap.org/openlayers/OpenStreetMap.js</code>) breaks in some browsers (Chrome and Firefox at least) due to mixed content warnings. One of the files I've attached is a shot of the admin lacking the ability to choose a GeoPoint.
</p>
<p>
My proposal is to vendor those two into Django.
</p>
Resultshttps://code.djangoproject.com/ticket/26074#changeloghttps://code.djangoproject.com/ticket/9345
https://code.djangoproject.com/ticket/9345#9345: Various string consistency fixesSun, 12 Oct 2008 00:28:11 GMTFlorian Sening<p>
Corrected the spelling of e-mail throughout the code and fixed a few associated whitespace issues. I also did some small changes to comments to make the translation strings more consistent with django core.
</p>
Resultshttps://code.djangoproject.com/ticket/9345#changeloghttps://code.djangoproject.com/ticket/26185
https://code.djangoproject.com/ticket/26185#26185: values_list throws interesting error when ordering by an extra columnMon, 08 Feb 2016 16:07:22 GMTSven R. Kunze<pre class="wiki">MyModel.objects.extra(select={'my_column': 'adas'}).order_by('my_column').values_list('id', flat=True)
ProgrammingError: column "adas" does not exist
LINE 1: ...arch3_beleg"."id" FROM "modarch3_beleg" ORDER BY (adas) ASC ...
</pre><p>
There's already a similar ticket (but it's closed as fixed) <a href="https://code.djangoproject.com/ticket/14930">https://code.djangoproject.com/ticket/14930</a>
</p>
Resultshttps://code.djangoproject.com/ticket/26185#changeloghttps://code.djangoproject.com/ticket/8144
https://code.djangoproject.com/ticket/8144#8144: values_list doesn't give the full object when requestedWed, 06 Aug 2008 21:58:08 GMTKenneth Arnold<p>
<code>values_list</code> is very useful to us, but one thing that keeps it from being more useful is that it will not return full objects when we ask for them.
</p>
<p>
Current behavior:
</p>
<pre class="wiki">Model.objects.values_list('other') # yields ids
</pre><p>
Desired behavior:
</p>
<pre class="wiki">Model.objects.values_list('other_id') # yields ids
Model.objects.values_list('other') # yields objects
</pre><p>
This of course requires getting extra things from the database, akin to <code>select_related</code>. We prefer <code>values_list</code> because it is more explicit and doesn't require pulling in all the fields of the first model (<code>Model</code>, above) where we don't ask for them.
</p>
Resultshttps://code.djangoproject.com/ticket/8144#changeloghttps://code.djangoproject.com/ticket/26296
https://code.djangoproject.com/ticket/26296#26296: values() after extra() gives incorrect error messageMon, 29 Feb 2016 19:35:03 GMTaimestereo<p>
In documentation there's comment in <code>values()</code> section about some behavior of <code>extra</code>
</p>
<p>
<a class="ext-link" href="https://docs.djangoproject.com/en/1.9/ref/models/querysets/#django.db.models.query.QuerySet.values"><span class="icon">​</span>https://docs.djangoproject.com/en/1.9/ref/models/querysets/#django.db.models.query.QuerySet.values</a>
</p>
<pre class="wiki">If you use a values() clause after an extra() call, any fields defined by a select argument in the extra() must be explicitly included in the values() call. Any extra() call made after a values() call will have its extra selected fields ignored.
</pre><p>
It's points that any extra fields after values() call will be ignored. But I think that it's not correct and need more description.
</p>
<p>
For example it could be not obvious that next simple construction will cause exception and such an not obvious one!
</p>
<pre class="wiki">User.objects.values('username').extra(select={'test_field': 1}).values('test_field', 'username')
FieldError: Cannot resolve keyword 'test_field' into field. Choices are: date_joined, email, first_name, groups, id, is_active, is_staff, is_superuser, last_login, last_name, logentry, password, test_field, user_permissions, username
</pre><p>
I want to point out that <code>test_field</code> is listed in choices that's very confusing. It happens because of all checks is runs against <code>extra_select</code> but error is uses <code>extra</code> as part of available choices.
</p>
<pre class="wiki">sorted(list(get_field_names_from_opts(opts)) + list(self.extra)
+ list(self.annotation_select))
</pre><p>
I can help you with this small change.
<a class="ext-link" href="https://github.com/django/django/pull/6225"><span class="icon">​</span>https://github.com/django/django/pull/6225</a>
</p>
Resultshttps://code.djangoproject.com/ticket/26296#changeloghttps://code.djangoproject.com/ticket/18882
https://code.djangoproject.com/ticket/18882#18882: ValueError when running a test inside a threadThu, 30 Aug 2012 21:44:56 GMTebas<p>
When running tests, unittest.installHandler is called to catch SIGINT. This is impossible when it's not on the main thread, and will throw a ValueError.
</p>
<p>
Running tests inside a thread occurs, for example, when used in conjuction with autoreload, as used in:
</p>
<ul><li><a class="ext-link" href="https://github.com/rca/django/commit/043e9723ae8fdb98745c2390f3ff92649bc106df"><span class="icon">​</span>https://github.com/rca/django/commit/043e9723ae8fdb98745c2390f3ff92649bc106df</a>
</li><li><a class="ext-link" href="https://github.com/garethr/django-test-extensions"><span class="icon">​</span>https://github.com/garethr/django-test-extensions</a>
</li></ul><p>
Using either of these will result in a ValueError.
</p>
<p>
One might argue this is an unittest bug, but i disagree. Unittest doesn't automatically install this handler, therefor its the users (django) responsibility to use it appropriately.
</p>
<p>
Branch on github: <a class="ext-link" href="https://github.com/ebas/django/tree/fix/simple.py-valueerror"><span class="icon">​</span>https://github.com/ebas/django/tree/fix/simple.py-valueerror</a>
</p>
Resultshttps://code.djangoproject.com/ticket/18882#changeloghttps://code.djangoproject.com/ticket/657
https://code.djangoproject.com/ticket/657#657: validator - characters without numbersThu, 20 Oct 2005 09:08:22 GMTBless<p>
It should be a validator for characters without numbers, because is possible that you want whatever text minus numbers.
</p>
<pre class="wiki">num_re = re.compile(r'\d')
def thereisNumeric:
if num_re.search(field_data):
raise ValidationError, "This value musn't contain numbers."
</pre>Resultshttps://code.djangoproject.com/ticket/657#changeloghttps://code.djangoproject.com/ticket/17386
https://code.djangoproject.com/ticket/17386#17386: Validation & Unicode Character 'ZERO WIDTH SPACE' (U+200B)Mon, 12 Dec 2011 22:56:42 GMTRaymond Penners<p>
Once in a while users somehow manage to inject e-mail addresses into the system containing unicode zero width space characters. I am not sure how they do it -- it probably happens when copy/pasting from a document of some sorts. Nevertheless, form validation does not reject such e-mail addresses:
</p>
<pre class="wiki">&gt;&gt;&gt; from django.core.validators import validate_email
&gt;&gt;&gt; email=u'test@hotmail.co\u200bm'
&gt;&gt;&gt; validate_email(email)
&gt;&gt;&gt; # No ValidationError ?
</pre><p>
These e-mail addresses get accepted and cause trouble later on (try sending mail to them, or hashing them for gravatar uses). Either:
a) Raise a ValidationError for such e-mail addresses, or
b) Automatically strip this character
</p>
<p>
Downside of a) is that the user is most likely unaware of this invisible character. He wouldn't know what character to remove where, even if instructed by an error message.
</p>
Resultshttps://code.djangoproject.com/ticket/17386#changeloghttps://code.djangoproject.com/ticket/15923
https://code.djangoproject.com/ticket/15923#15923: Validate that IntegerField is a valid Signed value for databases that don't do it themselves.Thu, 28 Apr 2011 21:45:42 GMTCal Leeming<p>
Hey,
</p>
<p>
So I found that, if you attempt to store a number larger than the SIGNED INT maximum, for some reason, Django (or the db) auto converts it to the maximum allowed, rather than throwing an error. This really causes some strange issues, especially when your app logic *thinks* you've managed to save the correct value lol.
</p>
<p>
Suggested patch might be, enforcing a default maximum, which throws a ValueError whenever you try saving it into the database??
</p>
<p>
If this would be an appropriate way forward, I'd be more than happy to submit a patch.
</p>
<p>
Lmk
</p>
<p>
Cal
</p>
<p>
PS) To test for yourself, try using the following:
</p>
<pre class="wiki">
class TestModel(models.Model):
test_field = models.IntegerField(db_index = True)
TestModel(
test_field = 3517601254
)
TestModel.objects.get(test_field = 3517601254)
</pre>Resultshttps://code.djangoproject.com/ticket/15923#changeloghttps://code.djangoproject.com/ticket/5101
https://code.djangoproject.com/ticket/5101#5101: validate on saveMon, 06 Aug 2007 18:54:53 GMTpk11<p>
add validation-on-save method to models. using this method you can force validation before saving.
</p>
Resultshttps://code.djangoproject.com/ticket/5101#changeloghttps://code.djangoproject.com/ticket/7297
https://code.djangoproject.com/ticket/7297#7297: utils.text docstrings inaccurate, not testable with doctest.testmodFri, 23 May 2008 14:24:16 GMTAntti Kaihola<p>
The code examples in the docstrings of [source:django/trunk/django/utils/text.py django.utils.text] can't be tested with doctest.testmod because of Python's issue <a class="ext-link" href="http://bugs.python.org/issue1108"><span class="icon">​</span>1108</a>. A simple work-around would be to copy docstrings of individual functions to the module's <code>__doc__</code> variable.
</p>
<p>
Also, the code examples are not accurate. Attached is a doctest.testmod run after fixing the doctest issue.
</p>
Resultshttps://code.djangoproject.com/ticket/7297#changeloghttps://code.djangoproject.com/ticket/16900
https://code.djangoproject.com/ticket/16900#16900: utils.dictconfig and utils.unittest don't work with python 3.0 and 3.1Wed, 21 Sep 2011 10:37:45 GMTadsworth<p>
utils.log imports the django specific copy of dictconfig is the import from the stdlib fails.
The copy is a copy of the 2.X version of dictconfig.py and this version does not work with py3k.
</p>
<p>
We can now either:
</p>
<ol class="loweralpha"><li>adapt the copy to work with py3k
</li><li>also copy the py3k version of dictconfig and if the import from the stdlib fails make a conditional import depending on if we are running a version &gt;= 3 or not.
</li></ol>Resultshttps://code.djangoproject.com/ticket/16900#changeloghttps://code.djangoproject.com/ticket/10308
https://code.djangoproject.com/ticket/10308#10308: us_states.STATE_CHOICES is missing AA, AE, AP, MH, PWFri, 20 Feb 2009 06:10:49 GMTMonteDavidoff<p>
According to the official list of state abbreviations defined by the USPS, <a class="ext-link" href="http://www.usps.com/ncsc/lookups/usps_abbreviations.html"><span class="icon">​</span>http://www.usps.com/ncsc/lookups/usps_abbreviations.html</a>, django.contrib.localflavor.us.us_states is missing these abbreviations: AA, AE, AP, MH, and PW.
</p>
<p>
AA Armed Forces Americas<br />
AE Armed Forces Europe / Canada / Middle East / Africa<br />
AP Armed Forces Pacific<br />
FM Federated States of Micronesia<br />
MH Marshall Islands<br />
PW Palau
</p>
<p>
Please note that the attached patch file also contains the fix for ticket <a class="closed ticket" href="https://code.djangoproject.com/ticket/10307" title="#10307: us localflavor STATES_NOMALIZED incorrectly includes FM (closed: fixed)">#10307</a> (FM inconsistency).
</p>
Resultshttps://code.djangoproject.com/ticket/10308#changeloghttps://code.djangoproject.com/ticket/4020
https://code.djangoproject.com/ticket/4020#4020: USPhoneField, USZipCodeField and USSocialSecurityNumberField should implement HTML maxlengthThu, 12 Apr 2007 11:13:52 GMTjoe4444<p>
For a CharField with max_length=30 it is not necessary to set attrs={'maxlength': '30'} in that form's widget (or set a widget at all in many cases). However, the fields USPhoneField, USZipCodeField and USSocialSecurityNumberField do not set maxlength="#" in the HTML they produce. In fact, USZipCodeField explicitly sets max_length=None. Maybe there is a good reason for this, but it seems like these fields could automatically add maxlength="#" to their output considering they validate for a specific length and format.
</p>
<p>
<br />
</p>
<pre class="wiki"> phone = forms.USPhoneField(widget=forms.TextInput(attrs={'maxlength': '12'})) # a bit verbose
phone = forms.USPhoneField() # should be equivalent to the previous line
</pre><p>
<br />
</p>
<p>
I wish I had a patch for this, but I wouldn't know where to begin.
</p>
Resultshttps://code.djangoproject.com/ticket/4020#changeloghttps://code.djangoproject.com/ticket/22794
https://code.djangoproject.com/ticket/22794#22794: Using WizardForm with only one modelSun, 08 Jun 2014 13:33:29 GMTsofi.vasserman@…<p>
In some cases the model for which you create a form has to many fields and using only one form will create a very long form which is not comfortable for the user. In this case I would to break the forms into more than one page, and for that I would like to use the WizardForm. The problem I encountered while using the wizardForm is that form has to have it's own modelForm, which makes me to have a form with only part of the model fields. If my fields are defined as not nullable, this scenario creates a problem in saving the object. For this there two solutions - either I create two models that are compatible to my forms and have a OneToOne relationship, either I have to change the save method in which I combine the data from the two forms. I chose the second option and had problems with the saving problems until I realized I have to override the save_instance procedure.
I think cases in which a model has many fields that will create a very long form are very common, and in this cases there is a need to use WizardForm in which each form represents only part of the model. There should be an easy way to handle this situation, maybe changing the save method of the wizard form and add the parameter construct, so we will be able to change it to true in the save method.
</p>
Resultshttps://code.djangoproject.com/ticket/22794#changeloghttps://code.djangoproject.com/ticket/27524
https://code.djangoproject.com/ticket/27524#27524: Using user instance (instead of get_user_model()) leads to errors when user model is overriddenTue, 22 Nov 2016 17:02:57 GMTAndy Martin<p>
We've been seeing errors like this on 1.8.16:
</p>
<pre class="wiki">File "[...snip...]/django/contrib/auth/__init__.py", line 111, in login
request.session[SESSION_KEY] = user._meta.pk.value_to_string(user)
AttributeError: 'MetaDict' object has no attribute 'pk'
</pre><p>
We solved them by going through the object returned by get_user_model() instead of using the user instance directly. This also matches what's done in other parts of the codebase (for example, in _get_user_session_key(request)).
</p>
Resultshttps://code.djangoproject.com/ticket/27524#changeloghttps://code.djangoproject.com/ticket/7239
https://code.djangoproject.com/ticket/7239#7239: Using the url tag with the blocktrans oneWed, 14 May 2008 16:42:32 GMTDavid Larlet<p>
For the moment, you can't use blocktrans with the url tag:
</p>
<pre class="wiki">{% blocktrans %}
foo {% url bar %} baz.
{% endblocktrans %}
</pre><p>
It seems that it had already been discussed: <a class="ext-link" href="http://groups.google.fr/group/django-developers/browse_thread/thread/e8b6b99973b10a17"><span class="icon">​</span>http://groups.google.fr/group/django-developers/browse_thread/thread/e8b6b99973b10a17</a>
but I can't find a ticket about that. If someone can post the final syntax (<em>We're pretty close to having a good syntax</em>), I can write the patch.
</p>
Resultshttps://code.djangoproject.com/ticket/7239#changeloghttps://code.djangoproject.com/ticket/13565
https://code.djangoproject.com/ticket/13565#13565: Using syncdb with Oracle using synonyms causes ORA-00955.Wed, 19 May 2010 06:56:08 GMTash@…<p>
When working with legacy databases and Django, Oracle has a nice feature to alias a table to match what Django thinks it should be. (Which is absolutely needed when the table you're referencing is in another user's schema.)
</p>
<p>
Unfortunately, the table creation SQL doesn't detect the alias, and sees the table as missing. When it tries to create it, you get a ORA-00955 error. (Name is already used by an existing object).
</p>
<pre class="wiki">Creating table users_foo
Traceback (most recent call last):
File "./manage.py", line 11, in &lt;module&gt;
execute_manager(settings)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2-py2.6.egg/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.6/dist-packages/Django-1.2-py2.6.egg/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2-py2.6.egg/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2-py2.6.egg/django/core/management/base.py", line 218, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2-py2.6.egg/django/core/management/base.py", line 347, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2-py2.6.egg/django/core/management/commands/syncdb.py", line 95, in handle_noargs
cursor.execute(statement)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2-py2.6.egg/django/db/backends/util.py", line 15, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2-py2.6.egg/django/db/backends/oracle/base.py", line 507, in execute
return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: ORA-00955: name is already used by an existing object
</pre>Resultshttps://code.djangoproject.com/ticket/13565#changeloghttps://code.djangoproject.com/ticket/24764
https://code.djangoproject.com/ticket/24764#24764: Using 'startswith' field lookup with F objects causes AttributeErrorThu, 07 May 2015 15:49:57 GMTPetros Moisiadis<p>
In Django 1.7.8, when using "startswith" field lookup with F objects in the same query, the following AttributeError exception is raised:
</p>
<pre class="wiki">&gt;&gt;&gt; objects = MyObject.objects.filter(name__startswith=F('description'))
&gt;&gt;&gt; objects
Traceback (most recent call last):
File "&lt;console&gt;", line 1, in &lt;module&gt;
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/query.py", line 116, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/query.py", line 141, in __iter__
self._fetch_all()
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/query.py", line 966, in _fetch_all
self._result_cache = list(self.iterator())
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/query.py", line 265, in iterator
for row in compiler.results_iter():
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 701, in results_iter
for rows in self.execute_sql(MULTI):
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 776, in execute_sql
sql, params = self.as_sql()
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 110, in as_sql
where, w_params = self.compile(self.query.where)
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 81, in compile
return node.as_sql(self, self.connection)
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/sql/where.py", line 106, in as_sql
sql, params = qn.compile(child)
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 81, in compile
return node.as_sql(self, self.connection)
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/lookups.py", line 152, in as_sql
rhs_sql = self.get_rhs_op(connection, rhs_sql)
File "/path/to/virtualenv/lib/python3.4/site-packages/django/db/models/lookups.py", line 258, in get_rhs_op
return connection.pattern_ops[self.lookup_name] % rhs
AttributeError: 'DatabaseWrapper' object has no attribute 'pattern_ops'
</pre><p>
The following (without the 'startswith' field lookup), however, works:
</p>
<pre class="wiki">&gt;&gt;&gt; objects = MyObject.objects.filter(name=F('description'))
&gt;&gt;&gt; objects
[...]
</pre><p>
Interestingly, Django 1.8 does not have this bug.
</p>
Resultshttps://code.djangoproject.com/ticket/24764#changeloghttps://code.djangoproject.com/ticket/24918
https://code.djangoproject.com/ticket/24918#24918: Using SchemaEditor to create materialized views in PostgreSQLThu, 04 Jun 2015 10:04:26 GMTAndreas Madsack<p>
We use the schemaeditor to create not only tables in the database, but also materialized views.
This is working for us on Django 1.7, but we use the somehow private API of Django migrations.
</p>
<p>
Our solution:
</p>
<ul><li>Subclassing the Postgresql-DatabaseWrapper to change the schema_editor to our own:
</li></ul><pre class="wiki">from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper as PGDatabaseWrapper
class DatabaseWrapper(PGDatabaseWrapper):
def __init__(self, *args, **kwargs):
self.SchemaEditorClass = OurDatabaseSchemaEditor
super(DatabaseWrapper, self).__init__(*args, **kwargs)
</pre><ul><li>in <em>OurDatabaseSchemaEditor</em> we overwrite every action method we need changed.
</li></ul><p>
For example:
</p>
<pre class="wiki"> def create_model(self, model):
if check_if_materialized(model):
from materialized.helpers import create_model
create_model(model)
return
super(OurDatabaseSchemaEditor, self).create_model(model)
</pre><p>
The same way for <em>delete_model</em>, <em>add_field</em>, <em>alter_field</em>, <em>remove_field</em>, ...
</p>
<p>
Purpose of this ticket is the discussion about custom changes to schemaeditor methods like we do.
<strong>Is this the way to go or should it be done in another way?</strong>
</p>
<p>
I'm in Cardiff at the sprints today and on freenode as mfandreas.
</p>
Resultshttps://code.djangoproject.com/ticket/24918#changeloghttps://code.djangoproject.com/ticket/6466
https://code.djangoproject.com/ticket/6466#6466: Using email as primary key for usersSat, 26 Jan 2008 14:05:00 GMTpupeno@…<p>
Not being able to smoothly use email as primary key for users, instead of username, is the biggest (and single) showstopper to adopting Django I have. I am not sure what the solution would be, but I think you should be aware of the problem.
</p>
<p>
Thank you.
</p>
Resultshttps://code.djangoproject.com/ticket/6466#changeloghttps://code.djangoproject.com/ticket/7508
https://code.djangoproject.com/ticket/7508#7508: Using edit_inline = models.TABULAR doesn't show any validation errors in the admin.Thu, 19 Jun 2008 21:50:17 GMTRemco Wendt<p>
<strong>Disclaimer</strong>: this issue will be resolved with the upcoming newforms-admin branch. It is here to provide a work-around to help people running into a similar case.
</p>
<p>
If you have a model which is editted through a different model using edit_inline like:
</p>
<div class="wiki-code"><div class="code"><pre><span class="k">class</span> <span class="nc">Article</span><span class="p">(</span>models<span class="o">.</span>Model<span class="p">):</span>
title <span class="o">=</span> models<span class="o">.</span>CharField<span class="p">(</span><span class="s1">'Title of article'</span><span class="p">,</span> max_length<span class="o">=</span><span class="mi">20</span><span class="p">,</span> blank<span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">Author</span><span class="p">(</span>models<span class="o">.</span>Model<span class="p">):</span>
article <span class="o">=</span> models<span class="o">.</span>ForeignKey<span class="p">(</span>Article<span class="p">,</span> edit_inline<span class="o">=</span>models<span class="o">.</span>TABULAR<span class="p">)</span>
first_name <span class="o">=</span> models<span class="o">.</span>CharField<span class="p">(</span><span class="s1">'First name of editor'</span><span class="p">,</span> max_length<span class="o">=</span><span class="mi">20</span><span class="p">,</span> blank<span class="o">=</span><span class="bp">False</span><span class="p">,</span> core<span class="o">=</span><span class="bp">True</span><span class="p">)</span>
</pre></div></div><p>
Then adding a new article and not filling in the Author name generates a ValidationError. But because models.TABULAR is used the ValidationError will not show, thus making it hard for users to correct their errors. This problem will be fixed in newforms-admin. But as a work around one can add the following (adapted) edit_inline_tabular.html to their templates/admin directory (the directory that overrides the templates provided by contrib.admin itself). Now validation errors will show.
</p>
<div class="wiki-code"><div class="code"><pre><span class="p">{</span><span class="o">%</span> load admin_modify <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;</span>fieldset class<span class="o">=</span><span class="s2">"module"</span><span class="o">&gt;</span>
<span class="o">&lt;</span>h2<span class="o">&gt;</span><span class="p">{{</span> bound_related_object<span class="o">.</span>relation<span class="o">.</span>opts<span class="o">.</span>verbose_name_plural<span class="o">|</span>capfirst <span class="p">}}</span><span class="o">&lt;/</span>h2<span class="o">&gt;&lt;</span>table<span class="o">&gt;</span>
<span class="o">&lt;</span>thead<span class="o">&gt;&lt;</span>tr<span class="o">&gt;</span>
<span class="p">{</span><span class="o">%</span> <span class="k">for</span> fw <span class="ow">in</span> bound_related_object<span class="o">.</span>field_wrapper_list <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> <span class="k">if</span> fw<span class="o">.</span>needs_header <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;</span>th<span class="p">{{</span> fw<span class="o">.</span>header_class_attribute <span class="p">}}</span><span class="o">&gt;</span><span class="p">{{</span> fw<span class="o">.</span>field<span class="o">.</span>verbose_name<span class="o">|</span>capfirst <span class="p">}}</span><span class="o">&lt;/</span>th<span class="o">&gt;</span>
<span class="p">{</span><span class="o">%</span> endif <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> endfor <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;/</span>tr<span class="o">&gt;&lt;/</span>thead<span class="o">&gt;</span>
<span class="p">{</span><span class="o">%</span> <span class="k">for</span> fcw <span class="ow">in</span> bound_related_object<span class="o">.</span>form_field_collection_wrappers <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> <span class="k">if</span> change <span class="o">%</span><span class="p">}{</span><span class="o">%</span> <span class="k">if</span> original_row_needed <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> <span class="k">if</span> fcw<span class="o">.</span>obj<span class="o">.</span>original <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;</span>tr class<span class="o">=</span><span class="s2">"row-label {</span><span class="si">% c</span><span class="s2">ycle row1,row2 %}"</span><span class="o">&gt;&lt;</span>td colspan<span class="o">=</span><span class="s2">"{{ num_headers }}"</span><span class="o">&gt;&lt;</span>strong<span class="o">&gt;</span><span class="p">{{</span> fcw<span class="o">.</span>obj<span class="o">.</span>original <span class="p">}}</span><span class="o">&lt;/</span>strong<span class="o">&gt;&lt;/</span>tr<span class="o">&gt;</span>
<span class="p">{</span><span class="o">%</span> endif <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> endif <span class="o">%</span><span class="p">}{</span><span class="o">%</span> endif <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> <span class="k">if</span> fcw<span class="o">.</span>obj<span class="o">.</span>errors <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;</span>tr class<span class="o">=</span><span class="s2">"errorlist"</span><span class="o">&gt;&lt;</span>td colspan<span class="o">=</span><span class="s2">"{{ num_headers }}"</span><span class="o">&gt;</span>
<span class="p">{{</span> fcw<span class="o">.</span>obj<span class="o">.</span>html_combined_error_list <span class="p">}}</span>
<span class="o">&lt;/</span>tr<span class="o">&gt;</span>
<span class="p">{</span><span class="o">%</span> endif <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;</span>tr class<span class="o">=</span><span class="s2">"{</span><span class="si">% c</span><span class="s2">ycle row1,row2 %}"</span><span class="o">&gt;</span>
<span class="p">{</span><span class="o">%</span> <span class="k">for</span> bound_field <span class="ow">in</span> fcw<span class="o">.</span>bound_fields <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> <span class="k">if</span> <span class="ow">not</span> bound_field<span class="o">.</span>hidden <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;</span>td <span class="p">{{</span> bound_field<span class="o">.</span>cell_class_attribute <span class="p">}}</span><span class="o">&gt;</span>
<span class="p">{{</span> bound_field<span class="o">.</span>html_error_list <span class="p">}}</span>
<span class="p">{</span><span class="o">%</span> field_widget bound_field <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;/</span>td<span class="o">&gt;</span>
<span class="p">{</span><span class="o">%</span> endif <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> endfor <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> <span class="k">if</span> bound_related_object<span class="o">.</span>show_url <span class="o">%</span><span class="p">}</span><span class="o">&lt;</span>td<span class="o">&gt;</span>
<span class="p">{</span><span class="o">%</span> <span class="k">if</span> fcw<span class="o">.</span>obj<span class="o">.</span>original <span class="o">%</span><span class="p">}</span><span class="o">&lt;</span>a href<span class="o">=</span><span class="s2">"/r/{{ fcw.obj.original.content_type_id }}/{{ fcw.obj.original.id }}/"</span><span class="o">&gt;</span>View on site<span class="o">&lt;/</span>a<span class="o">&gt;</span><span class="p">{</span><span class="o">%</span> endif <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;/</span>td<span class="o">&gt;</span><span class="p">{</span><span class="o">%</span> endif <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;/</span>tr<span class="o">&gt;</span>
<span class="p">{</span><span class="o">%</span> endfor <span class="o">%</span><span class="p">}</span> <span class="o">&lt;/</span>table<span class="o">&gt;</span>
<span class="p">{</span><span class="o">%</span> <span class="k">for</span> fcw <span class="ow">in</span> bound_related_object<span class="o">.</span>form_field_collection_wrappers <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> <span class="k">for</span> bound_field <span class="ow">in</span> fcw<span class="o">.</span>bound_fields <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> <span class="k">if</span> bound_field<span class="o">.</span>hidden <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> field_widget bound_field <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> endif <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> endfor <span class="o">%</span><span class="p">}</span>
<span class="p">{</span><span class="o">%</span> endfor <span class="o">%</span><span class="p">}</span>
<span class="o">&lt;/</span>fieldset<span class="o">&gt;</span>
</pre></div></div><p>
See also the attachment for a downloadable version of the above file.
</p>
Resultshttps://code.djangoproject.com/ticket/7508#changeloghttps://code.djangoproject.com/ticket/1518
https://code.djangoproject.com/ticket/1518#1518: using different TEMPLATE_FILE_EXTENSION would be niceSun, 19 Mar 2006 11:56:18 GMTanonymous<p>
building a site that partly consists of svg would be easier if the TEMPLATE_FILE_EXTENSION could be set differently. perhaps a parameter to render_to_response() would do, better would be some aproach to set it via urlpatterns.
</p>
Resultshttps://code.djangoproject.com/ticket/1518#changeloghttps://code.djangoproject.com/ticket/11476
https://code.djangoproject.com/ticket/11476#11476: Using delete on modelformset doesn't remove form from setTue, 14 Jul 2009 09:42:42 GMTMichael Stevens <mstevens@…><p>
I'm using a ModelFormset created with lineformset_factory.
</p>
<p>
When I click delete on one of the records and save the formset, it
successfully removes the associated db record, but if I redisplay the
formset after the save, it's still showing the now removed form.
</p>
<p>
I've modified my code to recreate the formset from the db immediately
after the save:
</p>
<pre class="wiki"> if foo_formset.is_valid():
foo_formset.save()
foo_formset = FooInlineFormset(instance=bar, prefix='foo')
</pre><p>
and it does what I expect, but shouldn't it be in the right state
after the save?
</p>
<p>
Looking at the code I think the problem is that BaseModelFormSet
doesn't do anything with deleted forms after it deletes the underlying
model object - I'm expecting them to be removed from the formset as
well.
</p>
<p>
I'm running a svn checkout of 1.1.
</p>
Resultshttps://code.djangoproject.com/ticket/11476#changeloghttps://code.djangoproject.com/ticket/4381
https://code.djangoproject.com/ticket/4381#4381: Using caps in column/table names in postgresql requires those fields to be quoted in initial sql filesThu, 24 May 2007 21:48:34 GMTRemco Wendt <remco@…><p>
This may be nice to specifically refer to in the initial data paragraph within the 'Creating models' documentation.
</p>
Resultshttps://code.djangoproject.com/ticket/4381#changeloghttps://code.djangoproject.com/ticket/7634
https://code.djangoproject.com/ticket/7634#7634: Using auto_now or auto_now_add should raise a DeprecationWarningSat, 05 Jul 2008 01:55:18 GMTAlex Gaynor<p>
To my understanding these are both slated for eventual removal in favor of the default kwarg and overiding the save() method, therefore they should raise a DeprecationWarning to alert people of this fact.
</p>
Resultshttps://code.djangoproject.com/ticket/7634#changeloghttps://code.djangoproject.com/ticket/25570
https://code.djangoproject.com/ticket/25570#25570: Using a templatetag in a Python file in a project template causes an ExceptionMon, 19 Oct 2015 13:24:14 GMTDaniel Samuels<p>
If you have a Python file in your project template and you have a string of code such as <code> {% static %} </code>, startproject will throw an exception as it tries to render the tag.
</p>
<p>
As a minimum viable test case, I put together the following repository: <a class="ext-link" href="https://github.com/danielsamuels/django-project-template-bug"><span class="icon">​</span>https://github.com/danielsamuels/django-project-template-bug</a>
It consists of a single <code> __init__.py </code> with a comment inside, the contents of the comment being <code> {% static %} </code>. Using this as a project template will cause the following exception to be thrown:
</p>
<p>
<code> django-admin startproject output --template https://github.com/danielsamuels/django-project-template-bug/archive/master.zip </code>
</p>
<pre class="wiki">Traceback (most recent call last):
File "/Users/danielsamuels/Workspace/testing/.venv/bin/django-admin", line 11, in &lt;module&gt;
sys.exit(execute_from_command_line())
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
utility.execute()
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 343, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/core/management/commands/startproject.py", line 33, in handle
super(Command, self).handle('project', project_name, target, **options)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/core/management/templates.py", line 151, in handle
template = Engine().from_string(content)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/template/engine.py", line 153, in from_string
return Template(template_code, engine=self)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/template/base.py", line 190, in __init__
self.nodelist = engine.compile_string(template_string, origin)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/template/engine.py", line 261, in compile_string
return parser.parse()
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/template/base.py", line 339, in parse
self.invalid_block_tag(token, command, parse_until)
File "/Users/danielsamuels/Workspace/testing/.venv/lib/python2.7/site-packages/django/template/base.py", line 395, in invalid_block_tag
raise self.error(token, "Invalid block tag: '%s'" % command)
django.template.base.TemplateSyntaxError: Invalid block tag: 'static'
</pre><p>
In theory, this project template _should_ work, given that the templatetag is just a comment within the project.
</p>
Resultshttps://code.djangoproject.com/ticket/25570#changeloghttps://code.djangoproject.com/ticket/19876
https://code.djangoproject.com/ticket/19876#19876: Using a staticmethod for a FileField's upload_to attribute doesn't workThu, 21 Feb 2013 21:15:57 GMTBaptiste Mispelon<p>
When trying to use a <code>staticmethod</code> for a <code>FileField</code>'s <code>upload_to</code> attribute, the results are not what you'd expect.
</p>
<div class="wiki-code"><div class="code"><pre><span class="c1"># models.py</span>
<span class="k">class</span> <span class="nc">Foo</span><span class="p">(</span>models<span class="o">.</span>Model<span class="p">):</span>
<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">my_callable</span><span class="p">(</span>instance<span class="p">,</span> filename<span class="p">):</span>
<span class="k">return</span> <span class="s1">'foo'</span>
f <span class="o">=</span> models<span class="o">.</span>FileField<span class="p">(</span>upload_to<span class="o">=</span>my_callable<span class="p">)</span>
</pre></div></div><p>
The following code shows what happens:
</p>
<div class="wiki-code"><div class="code"><pre><span class="kn">from</span> <span class="nn">myapp.models</span> <span class="kn">import</span> Foo
instance <span class="o">=</span> Foo<span class="p">()</span>
<span class="k">print</span> instance<span class="o">.</span>_meta<span class="o">.</span>get_field<span class="p">(</span><span class="s1">'f'</span><span class="p">)</span><span class="o">.</span>generate_filename<span class="p">(</span>instance<span class="p">,</span> <span class="s1">'bar'</span><span class="p">)</span>
</pre></div></div><p>
I would expect the output of this to be <code>'foo'</code> but instead, it prints <code>u'&lt;staticmethod object at 0x1c8b130&gt;/bar'</code>.
</p>
<p>
Putting a breakpoint inside <code>FileField.__init__</code>, it appears that at the time the field is initialized, <code>upload_to</code> is a staticmethod object which is not itself callable (it has a <code>__func__</code> attribute which is the callable we are looking for).
</p>
Resultshttps://code.djangoproject.com/ticket/19876#changeloghttps://code.djangoproject.com/ticket/9633
https://code.djangoproject.com/ticket/9633#9633: Using adaptor objects as query parameters with sqlite3Wed, 19 Nov 2008 07:57:35 GMTmdh<p>
And now for my final stumbling block within the Django core on the road to using GeoDjango with SQLite:
</p>
<p>
It is handy to be able to pass an adaptor object as a query parameter that will ultimately end up in the hands of <code>cursor.execute()</code>, which can convert the adaptor to a string to insert into the SQL. This is explicitly supported in (at least) the <code>postgresql</code> back-end, where it’s handled by [source:django/trunk/django/db/backends/postgresql/base.py UnicodeCursorWrapper.format_params()]. GeoDjango currently takes advantage of this when it uses [source:django/trunk/django/contrib/gis/db/backend/postgis/adaptor.py PostGISAdaptor] to wrap, well, pretty much any geospatial entity en route to PostGIS.
</p>
<p>
The <code>sqlite3</code> back-end could easily support something similar, but it doesn’t: if you try the corresponding trick with SQLite, you get to enjoy “<code>InterfaceError: Error binding parameter 0 - probably unsupported type.</code>” There may be a completely different way to address the underlying problem, which I’d certainly be very open to hearing about, but I’m personally inclined towards doing things in the corresponding ways for each back-end as much as possible, so this is the approach I’ve taken for now..
</p>
<p>
I’ve attached a fairly simple patch that takes what is clearly one of many possible similar approaches to achieving the corresponding thing for <code>sqlite3</code>, as well as quick test to see if <em>your</em> favorite back-end supports query parameter adaptors.
</p>
Resultshttps://code.djangoproject.com/ticket/9633#changeloghttps://code.djangoproject.com/ticket/476
https://code.djangoproject.com/ticket/476#476: use vars values in template {{}} dotted styleFri, 09 Sep 2005 16:27:28 GMTSokolov Yura<p>
What if I has two contexts:
</p>
<pre class="wiki">s1= Context({'person':
{'first_name':'Homer', 'last_name':'Sympson'},
'first_field':'first_name','second_field':'last_name'})
s2= Context({'person':
{'first_name':'Homer', 'last_name':'Sympson'},
'first_field':'last_name','second_field':'first_name'})
</pre><p>
and wish to render template accordinary to field ord?
I wrote a tag to get a dictionary value, but I think it is ugly to write a tag when I want to take variable's field.
May be better to make this possible:
</p>
<pre class="wiki">&lt;h4&gt;{{ first_field }}&lt;/h4&gt;&lt;h3&gt;{{ person.$first_field}}&lt;/h3&gt;
&lt;h4&gt;{{ second_field }}&lt;/h4&gt;&lt;h3&gt;{{ person.$second_field}}&lt;/h3&gt;
</pre><p>
or even:
</p>
<pre class="wiki">&lt;h4&gt;{{ first_field }}&lt;/h4&gt;&lt;h3&gt;{{ person.${first_field} }}&lt;/h3&gt;
&lt;h4&gt;{{ second_field }}&lt;/h4&gt;&lt;h3&gt;{{ person.${second_field} }}&lt;/h3&gt;
</pre><p>
or
</p>
<pre class="wiki">&lt;h4&gt;{{ first_field }}&lt;/h4&gt;&lt;h3&gt;{{ person.(first_field) }}&lt;/h3&gt;
&lt;h4&gt;{{ second_field }}&lt;/h4&gt;&lt;h3&gt;{{ person.(second_field) }}&lt;/h3&gt;
</pre><p>
or append to resolution order as a last resort: foo[Context[bar]] But it is error prone cause of nested resolution:
person.(fields.(num)) could not be written without braces. Or maybe allow filters to access Context Object as Node.render do,
then most tags could be implemented as filters and this task would be written simpler.
</p>
<p>
Priority is low cause there are a bit of real life needs. But thinking that it can be possible makes me good.
May be it will help to write custom form generator.
</p>
Resultshttps://code.djangoproject.com/ticket/476#changeloghttps://code.djangoproject.com/ticket/3769
https://code.djangoproject.com/ticket/3769#3769: use vars in {% url %}Tue, 20 Mar 2007 18:57:24 GMTPaul Rauch <LightLan@…><p>
atm it seems impossible to me to use vars in the template"function"
</p>
<p>
<a class="ext-link" href="http://www.djangoproject.com/documentation/templates/#url"><span class="icon">​</span>http://www.djangoproject.com/documentation/templates/#url</a>
</p>
<p>
both {% url {{variable}} %} and {% url {{variable}} %} lead to an empty string, though variable is a valid string(app_name.views.function)
</p>
<p>
{% url app_name.views.function %} works without a prob.
</p>
Resultshttps://code.djangoproject.com/ticket/3769#changeloghttps://code.djangoproject.com/ticket/5915
https://code.djangoproject.com/ticket/5915#5915: use_tls is not passed to send_email (django.core.mail)Sat, 10 Nov 2007 02:05:51 GMTanonymous<p>
As for revision 6660 you cannot pass use_tls to send_email function.
Patch is simple:
</p>
<pre class="wiki">max@explorer ~/devel/django-inst/trunk/django/core $ svn diff mail.py
Index: mail.py
===================================================================
--- mail.py (revision 6660)
+++ mail.py (working copy)
@@ -326,7 +326,7 @@
New code should use the EmailMessage class directly.
"""
connection = SMTPConnection(username=auth_user, password=auth_password,
- fail_silently=fail_silently)
+ fail_silently=fail_silently, use_tls=None)
return EmailMessage(subject, message, from_email, recipient_list, connection=connection).send()
def send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password=None):
</pre>Resultshttps://code.djangoproject.com/ticket/5915#changelog