上传文件至 'test/Django-2.1.15/docs/faq'
This commit is contained in:
parent
4e7cdb61fe
commit
625dfcbfd6
|
@ -0,0 +1,107 @@
|
|||
==============
|
||||
FAQ: The admin
|
||||
==============
|
||||
|
||||
I can't log in. When I enter a valid username and password, it just brings up the login page again, with no error messages.
|
||||
===========================================================================================================================
|
||||
|
||||
The login cookie isn't being set correctly, because the domain of the cookie
|
||||
sent out by Django doesn't match the domain in your browser. Try setting the
|
||||
:setting:`SESSION_COOKIE_DOMAIN` setting to match your domain. For example, if
|
||||
you're going to "https://www.example.com/admin/" in your browser, set
|
||||
``SESSION_COOKIE_DOMAIN = 'www.example.com'``.
|
||||
|
||||
I can't log in. When I enter a valid username and password, it brings up the login page again, with a "Please enter a correct username and password" error.
|
||||
===========================================================================================================================================================
|
||||
|
||||
If you're sure your username and password are correct, make sure your user
|
||||
account has :attr:`~django.contrib.auth.models.User.is_active` and
|
||||
:attr:`~django.contrib.auth.models.User.is_staff` set to True. The admin site
|
||||
only allows access to users with those two fields both set to True.
|
||||
|
||||
How do I automatically set a field's value to the user who last edited the object in the admin?
|
||||
===============================================================================================
|
||||
|
||||
The :class:`~django.contrib.admin.ModelAdmin` class provides customization hooks
|
||||
that allow you to transform an object as it saved, using details from the
|
||||
request. By extracting the current user from the request, and customizing the
|
||||
:meth:`~django.contrib.admin.ModelAdmin.save_model` hook, you can update an
|
||||
object to reflect the user that edited it. See :ref:`the documentation on
|
||||
ModelAdmin methods <model-admin-methods>` for an example.
|
||||
|
||||
How do I limit admin access so that objects can only be edited by the users who created them?
|
||||
=============================================================================================
|
||||
|
||||
The :class:`~django.contrib.admin.ModelAdmin` class also provides customization
|
||||
hooks that allow you to control the visibility and editability of objects in the
|
||||
admin. Using the same trick of extracting the user from the request, the
|
||||
:meth:`~django.contrib.admin.ModelAdmin.get_queryset` and
|
||||
:meth:`~django.contrib.admin.ModelAdmin.has_change_permission` can be used to
|
||||
control the visibility and editability of objects in the admin.
|
||||
|
||||
My admin-site CSS and images showed up fine using the development server, but they're not displaying when using mod_wsgi.
|
||||
=========================================================================================================================
|
||||
|
||||
See :ref:`serving the admin files <serving-the-admin-files>`
|
||||
in the "How to use Django with mod_wsgi" documentation.
|
||||
|
||||
My "list_filter" contains a ManyToManyField, but the filter doesn't display.
|
||||
============================================================================
|
||||
|
||||
Django won't bother displaying the filter for a ``ManyToManyField`` if there
|
||||
are fewer than two related objects.
|
||||
|
||||
For example, if your :attr:`~django.contrib.admin.ModelAdmin.list_filter`
|
||||
includes :doc:`sites </ref/contrib/sites>`, and there's only one site in your
|
||||
database, it won't display a "Site" filter. In that case, filtering by site
|
||||
would be meaningless.
|
||||
|
||||
Some objects aren't appearing in the admin.
|
||||
===========================================
|
||||
|
||||
Inconsistent row counts may be caused by missing foreign key values or a
|
||||
foreign key field incorrectly set to :attr:`null=False
|
||||
<django.db.models.Field.null>`. If you have a record with a
|
||||
:class:`~django.db.models.ForeignKey` pointing to a nonexistent object and
|
||||
that foreign key is included is
|
||||
:attr:`~django.contrib.admin.ModelAdmin.list_display`, the record will not be
|
||||
shown in the admin changelist because the Django model is declaring an
|
||||
integrity constraint that is not implemented at the database level.
|
||||
|
||||
How can I customize the functionality of the admin interface?
|
||||
=============================================================
|
||||
|
||||
You've got several options. If you want to piggyback on top of an add/change
|
||||
form that Django automatically generates, you can attach arbitrary JavaScript
|
||||
modules to the page via the model's class Admin :ref:`js parameter
|
||||
<modeladmin-asset-definitions>`. That parameter is a list of URLs, as strings,
|
||||
pointing to JavaScript modules that will be included within the admin form via
|
||||
a ``<script>`` tag.
|
||||
|
||||
If you want more flexibility than simply tweaking the auto-generated forms,
|
||||
feel free to write custom views for the admin. The admin is powered by Django
|
||||
itself, and you can write custom views that hook into the authentication
|
||||
system, check permissions and do whatever else they need to do.
|
||||
|
||||
If you want to customize the look-and-feel of the admin interface, read the
|
||||
next question.
|
||||
|
||||
The dynamically-generated admin site is ugly! How can I change it?
|
||||
==================================================================
|
||||
|
||||
We like it, but if you don't agree, you can modify the admin site's
|
||||
presentation by editing the CSS stylesheet and/or associated image files. The
|
||||
site is built using semantic HTML and plenty of CSS hooks, so any changes you'd
|
||||
like to make should be possible by editing the stylesheet.
|
||||
|
||||
What browsers are supported for using the admin?
|
||||
================================================
|
||||
|
||||
The admin provides a fully-functional experience to `YUI's A-grade`_ browsers,
|
||||
with the notable exception of IE6, which is not supported.
|
||||
|
||||
There *may* be minor stylistic differences between supported browsers—for
|
||||
example, some browsers may not support rounded corners. These are considered
|
||||
acceptable variations in rendering.
|
||||
|
||||
.. _YUI's A-grade: https://github.com/yui/yui3/wiki/Graded-Browser-Support
|
|
@ -0,0 +1,99 @@
|
|||
======================
|
||||
FAQ: Contributing code
|
||||
======================
|
||||
|
||||
How can I get started contributing code to Django?
|
||||
==================================================
|
||||
|
||||
Thanks for asking! We've written an entire document devoted to this question.
|
||||
It's titled :doc:`Contributing to Django </internals/contributing/index>`.
|
||||
|
||||
I submitted a bug fix in the ticket system several weeks ago. Why are you ignoring my patch?
|
||||
============================================================================================
|
||||
|
||||
Don't worry: We're not ignoring you!
|
||||
|
||||
It's important to understand there is a difference between "a ticket is being
|
||||
ignored" and "a ticket has not been attended to yet." Django's ticket system
|
||||
contains hundreds of open tickets, of various degrees of impact on end-user
|
||||
functionality, and Django's developers have to review and prioritize.
|
||||
|
||||
On top of that: the people who work on Django are all volunteers. As a result,
|
||||
the amount of time that we have to work on the framework is limited and will
|
||||
vary from week to week depending on our spare time. If we're busy, we may not
|
||||
be able to spend as much time on Django as we might want.
|
||||
|
||||
The best way to make sure tickets do not get hung up on the way to checkin is
|
||||
to make it dead easy, even for someone who may not be intimately familiar with
|
||||
that area of the code, to understand the problem and verify the fix:
|
||||
|
||||
* Are there clear instructions on how to reproduce the bug? If this
|
||||
touches a dependency (such as Pillow), a contrib module, or a specific
|
||||
database, are those instructions clear enough even for someone not
|
||||
familiar with it?
|
||||
|
||||
* If there are several patches attached to the ticket, is it clear what
|
||||
each one does, which ones can be ignored and which matter?
|
||||
|
||||
* Does the patch include a unit test? If not, is there a very clear
|
||||
explanation why not? A test expresses succinctly what the problem is,
|
||||
and shows that the patch actually fixes it.
|
||||
|
||||
If your patch stands no chance of inclusion in Django, we won't ignore it --
|
||||
we'll just close the ticket. So if your ticket is still open, it doesn't mean
|
||||
we're ignoring you; it just means we haven't had time to look at it yet.
|
||||
|
||||
When and how might I remind the team of a patch I care about?
|
||||
=============================================================
|
||||
|
||||
A polite, well-timed message to the mailing list is one way to get attention.
|
||||
To determine the right time, you need to keep an eye on the schedule. If you
|
||||
post your message right before a release deadline, you're not likely to get the
|
||||
sort of attention you require.
|
||||
|
||||
Gentle IRC reminders can also work -- again, strategically timed if possible.
|
||||
During a bug sprint would be a very good time, for example.
|
||||
|
||||
Another way to get traction is to pull several related tickets together. When
|
||||
the someone sits down to review a bug in an area they haven't touched for
|
||||
a while, it can take a few minutes to remember all the fine details of how
|
||||
that area of code works. If you collect several minor bug fixes together into
|
||||
a similarly themed group, you make an attractive target, as the cost of coming
|
||||
up to speed on an area of code can be spread over multiple tickets.
|
||||
|
||||
Please refrain from emailing anyone personally or repeatedly raising the same
|
||||
issue over and over. This sort of behavior will not gain you any additional
|
||||
attention -- certainly not the attention that you need in order to get your
|
||||
issue addressed.
|
||||
|
||||
But I've reminded you several times and you keep ignoring my patch!
|
||||
===================================================================
|
||||
|
||||
Seriously - we're not ignoring you. If your patch stands no chance of
|
||||
inclusion in Django, we'll close the ticket. For all the other tickets, we
|
||||
need to prioritize our efforts, which means that some tickets will be
|
||||
addressed before others.
|
||||
|
||||
One of the criteria that is used to prioritize bug fixes is the number of
|
||||
people that will likely be affected by a given bug. Bugs that have the
|
||||
potential to affect many people will generally get priority over those that
|
||||
are edge cases.
|
||||
|
||||
Another reason that bugs might be ignored for while is if the bug is a symptom
|
||||
of a larger problem. While we can spend time writing, testing and applying
|
||||
lots of little patches, sometimes the right solution is to rebuild. If a
|
||||
rebuild or refactor of a particular component has been proposed or is
|
||||
underway, you may find that bugs affecting that component will not get as much
|
||||
attention. Again, this is just a matter of prioritizing scarce resources. By
|
||||
concentrating on the rebuild, we can close all the little bugs at once, and
|
||||
hopefully prevent other little bugs from appearing in the future.
|
||||
|
||||
Whatever the reason, please keep in mind that while you may hit a particular
|
||||
bug regularly, it doesn't necessarily follow that every single Django user
|
||||
will hit the same bug. Different users use Django in different ways, stressing
|
||||
different parts of the code under different conditions. When we evaluate the
|
||||
relative priorities, we are generally trying to consider the needs of the
|
||||
entire community, not just the severity for one particular user. This doesn't
|
||||
mean that we think your problem is unimportant -- just that in the limited
|
||||
time we have available, we will always err on the side of making 10 people
|
||||
happy rather than making 1 person happy.
|
|
@ -0,0 +1,206 @@
|
|||
============
|
||||
FAQ: General
|
||||
============
|
||||
|
||||
Why does this project exist?
|
||||
============================
|
||||
|
||||
Django grew from a very practical need: World Online, a newspaper Web
|
||||
operation, is responsible for building intensive Web applications on journalism
|
||||
deadlines. In the fast-paced newsroom, World Online often has only a matter of
|
||||
hours to take a complicated Web application from concept to public launch.
|
||||
|
||||
At the same time, the World Online Web developers have consistently been
|
||||
perfectionists when it comes to following best practices of Web development.
|
||||
|
||||
In fall 2003, the World Online developers (Adrian Holovaty and Simon Willison)
|
||||
ditched PHP and began using Python to develop its websites. As they built
|
||||
intensive, richly interactive sites such as Lawrence.com, they began to extract
|
||||
a generic Web development framework that let them build Web applications more
|
||||
and more quickly. They tweaked this framework constantly, adding improvements
|
||||
over two years.
|
||||
|
||||
In summer 2005, World Online decided to open-source the resulting software,
|
||||
Django. Django would not be possible without a whole host of open-source
|
||||
projects -- `Apache`_, `Python`_, and `PostgreSQL`_ to name a few -- and we're
|
||||
thrilled to be able to give something back to the open-source community.
|
||||
|
||||
.. _Apache: https://httpd.apache.org/
|
||||
.. _Python: https://www.python.org/
|
||||
.. _PostgreSQL: https://www.postgresql.org/
|
||||
|
||||
What does "Django" mean, and how do you pronounce it?
|
||||
=====================================================
|
||||
|
||||
Django is named after `Django Reinhardt`_, a jazz manouche guitarist from the 1930s
|
||||
to early 1950s. To this day, he's considered one of the best guitarists of all time.
|
||||
|
||||
Listen to his music. You'll like it.
|
||||
|
||||
Django is pronounced **JANG**-oh. Rhymes with FANG-oh. The "D" is silent.
|
||||
|
||||
We've also recorded an `audio clip of the pronunciation`_.
|
||||
|
||||
.. _Django Reinhardt: https://en.wikipedia.org/wiki/Django_Reinhardt
|
||||
.. _audio clip of the pronunciation: https://www.red-bean.com/~adrian/django_pronunciation.mp3
|
||||
|
||||
Is Django stable?
|
||||
=================
|
||||
|
||||
Yes, it's quite stable. Companies like Disqus, Instagram, Pinterest, and
|
||||
Mozilla have been using Django for many years. Sites built on Django have
|
||||
weathered traffic spikes of over 50 thousand hits per second.
|
||||
|
||||
Does Django scale?
|
||||
==================
|
||||
|
||||
Yes. Compared to development time, hardware is cheap, and so Django is
|
||||
designed to take advantage of as much hardware as you can throw at it.
|
||||
|
||||
Django uses a "shared-nothing" architecture, which means you can add hardware
|
||||
at any level -- database servers, caching servers or Web/application servers.
|
||||
|
||||
The framework cleanly separates components such as its database layer and
|
||||
application layer. And it ships with a simple-yet-powerful
|
||||
:doc:`cache framework </topics/cache>`.
|
||||
|
||||
Who's behind this?
|
||||
==================
|
||||
|
||||
Django was originally developed at World Online, the Web department of a
|
||||
newspaper in Lawrence, Kansas, USA. Django's now run by an international
|
||||
`team of volunteers <https://www.djangoproject.com/foundation/teams/>`_.
|
||||
|
||||
Which sites use Django?
|
||||
=======================
|
||||
|
||||
`DjangoSites.org`_ features a constantly growing list of Django-powered sites.
|
||||
|
||||
.. _DjangoSites.org: https://djangosites.org
|
||||
|
||||
.. _faq-mtv:
|
||||
|
||||
Django appears to be a MVC framework, but you call the Controller the "view", and the View the "template". How come you don't use the standard names?
|
||||
=====================================================================================================================================================
|
||||
|
||||
Well, the standard names are debatable.
|
||||
|
||||
In our interpretation of MVC, the "view" describes the data that gets presented
|
||||
to the user. It's not necessarily *how* the data *looks*, but *which* data is
|
||||
presented. The view describes *which data you see*, not *how you see it.* It's
|
||||
a subtle distinction.
|
||||
|
||||
So, in our case, a "view" is the Python callback function for a particular URL,
|
||||
because that callback function describes which data is presented.
|
||||
|
||||
Furthermore, it's sensible to separate content from presentation -- which is
|
||||
where templates come in. In Django, a "view" describes which data is presented,
|
||||
but a view normally delegates to a template, which describes *how* the data is
|
||||
presented.
|
||||
|
||||
Where does the "controller" fit in, then? In Django's case, it's probably the
|
||||
framework itself: the machinery that sends a request to the appropriate view,
|
||||
according to the Django URL configuration.
|
||||
|
||||
If you're hungry for acronyms, you might say that Django is a "MTV" framework
|
||||
-- that is, "model", "template", and "view." That breakdown makes much more
|
||||
sense.
|
||||
|
||||
At the end of the day, of course, it comes down to getting stuff done. And,
|
||||
regardless of how things are named, Django gets stuff done in a way that's most
|
||||
logical to us.
|
||||
|
||||
<Framework X> does <feature Y> -- why doesn't Django?
|
||||
=====================================================
|
||||
|
||||
We're well aware that there are other awesome Web frameworks out there, and
|
||||
we're not averse to borrowing ideas where appropriate. However, Django was
|
||||
developed precisely because we were unhappy with the status quo, so please be
|
||||
aware that "because <Framework X> does it" is not going to be sufficient reason
|
||||
to add a given feature to Django.
|
||||
|
||||
Why did you write all of Django from scratch, instead of using other Python libraries?
|
||||
======================================================================================
|
||||
|
||||
When Django was originally written, Adrian and Simon spent quite a bit of time
|
||||
exploring the various Python Web frameworks available.
|
||||
|
||||
In our opinion, none of them were completely up to snuff.
|
||||
|
||||
We're picky. You might even call us perfectionists. (With deadlines.)
|
||||
|
||||
Over time, we stumbled across open-source libraries that did things we'd
|
||||
already implemented. It was reassuring to see other people solving similar
|
||||
problems in similar ways, but it was too late to integrate outside code: We'd
|
||||
already written, tested and implemented our own framework bits in several
|
||||
production settings -- and our own code met our needs delightfully.
|
||||
|
||||
In most cases, however, we found that existing frameworks/tools inevitably had
|
||||
some sort of fundamental, fatal flaw that made us squeamish. No tool fit our
|
||||
philosophies 100%.
|
||||
|
||||
Like we said: We're picky.
|
||||
|
||||
We've documented our philosophies on the
|
||||
:doc:`design philosophies page </misc/design-philosophies>`.
|
||||
|
||||
Is Django a content-management-system (CMS)?
|
||||
============================================
|
||||
|
||||
No, Django is not a CMS, or any sort of "turnkey product" in and of itself.
|
||||
It's a Web framework; it's a programming tool that lets you build websites.
|
||||
|
||||
For example, it doesn't make much sense to compare Django to something like
|
||||
Drupal_, because Django is something you use to *create* things like Drupal.
|
||||
|
||||
Of course, Django's automatic admin site is fantastic and timesaving -- but
|
||||
the admin site is one module of Django the framework. Furthermore, although
|
||||
Django has special conveniences for building "CMS-y" apps, that doesn't mean
|
||||
it's not just as appropriate for building "non-CMS-y" apps (whatever that
|
||||
means!).
|
||||
|
||||
.. _Drupal: https://drupal.org/
|
||||
|
||||
How can I download the Django documentation to read it offline?
|
||||
===============================================================
|
||||
|
||||
The Django docs are available in the ``docs`` directory of each Django tarball
|
||||
release. These docs are in reST (reStructuredText) format, and each text file
|
||||
corresponds to a Web page on the official Django site.
|
||||
|
||||
Because the documentation is `stored in revision control`_, you can browse
|
||||
documentation changes just like you can browse code changes.
|
||||
|
||||
Technically, the docs on Django's site are generated from the latest development
|
||||
versions of those reST documents, so the docs on the Django site may offer more
|
||||
information than the docs that come with the latest Django release.
|
||||
|
||||
.. _stored in revision control: https://github.com/django/django/tree/master/docs/
|
||||
|
||||
How do I cite Django?
|
||||
=====================
|
||||
|
||||
It's difficult to give an official citation format, for two reasons: citation
|
||||
formats can vary wildly between publications, and citation standards for
|
||||
software are still a matter of some debate.
|
||||
|
||||
For example, `APA style`_, would dictate something like::
|
||||
|
||||
Django (Version 1.5) [Computer Software]. (2013). Retrieved from https://djangoproject.com.
|
||||
|
||||
However, the only true guide is what your publisher will accept, so get a copy
|
||||
of those guidelines and fill in the gaps as best you can.
|
||||
|
||||
If your referencing style guide requires a publisher name, use "Django Software
|
||||
Foundation".
|
||||
|
||||
If you need a publishing location, use "Lawrence, Kansas".
|
||||
|
||||
If you need a web address, use https://djangoproject.com.
|
||||
|
||||
If you need a name, just use "Django", without any tagline.
|
||||
|
||||
If you need a publication date, use the year of release of the version you're
|
||||
referencing (e.g., 2013 for v1.5)
|
||||
|
||||
.. _APA style: https://www.apastyle.org
|
|
@ -0,0 +1,71 @@
|
|||
=================
|
||||
FAQ: Getting Help
|
||||
=================
|
||||
|
||||
How do I do X? Why doesn't Y work? Where can I go to get help?
|
||||
==============================================================
|
||||
|
||||
If this FAQ doesn't contain an answer to your question, you might want to
|
||||
try the |django-users| mailing list. Feel free to ask any question related
|
||||
to installing, using, or debugging Django.
|
||||
|
||||
If you prefer IRC, the `#django IRC channel`_ on the Freenode IRC network is an
|
||||
active community of helpful individuals who may be able to solve your problem.
|
||||
|
||||
.. _`#django IRC channel`: irc://irc.freenode.net/django
|
||||
|
||||
.. _message-does-not-appear-on-django-users:
|
||||
|
||||
Why hasn't my message appeared on `django-users`?
|
||||
=================================================
|
||||
|
||||
|django-users| has a lot of subscribers. This is good for the community, as
|
||||
it means many people are available to contribute answers to questions.
|
||||
Unfortunately, it also means that |django-users| is an attractive target for
|
||||
spammers.
|
||||
|
||||
In order to combat the spam problem, when you join the |django-users| mailing
|
||||
list, we manually moderate the first message you send to the list. This means
|
||||
that spammers get caught, but it also means that your first question to the
|
||||
list might take a little longer to get answered. We apologize for any
|
||||
inconvenience that this policy may cause.
|
||||
|
||||
Nobody on `django-users` answered my question! What should I do?
|
||||
================================================================
|
||||
|
||||
Try making your question more specific, or provide a better example of your
|
||||
problem.
|
||||
|
||||
As with most open-source mailing lists, the folks on |django-users| are
|
||||
volunteers. If nobody has answered your question, it may be because nobody
|
||||
knows the answer, it may be because nobody can understand the question, or it
|
||||
may be that everybody that can help is busy. One thing you might try is to ask
|
||||
the question on IRC -- visit the `#django IRC channel`_ on the Freenode IRC
|
||||
network.
|
||||
|
||||
You might notice we have a second mailing list, called |django-developers| --
|
||||
but please don't email support questions to this mailing list. This list is
|
||||
for discussion of the development of Django itself. Asking a tech support
|
||||
question there is considered quite impolite.
|
||||
|
||||
I think I've found a bug! What should I do?
|
||||
===========================================
|
||||
|
||||
Detailed instructions on how to handle a potential bug can be found in our
|
||||
:ref:`Guide to contributing to Django <reporting-bugs>`.
|
||||
|
||||
I think I've found a security problem! What should I do?
|
||||
========================================================
|
||||
|
||||
If you think you've found a security problem with Django, please send a message
|
||||
to security@djangoproject.com. This is a private list only open to long-time,
|
||||
highly trusted Django developers, and its archives are not publicly readable.
|
||||
|
||||
Due to the sensitive nature of security issues, we ask that if you think you
|
||||
have found a security problem, *please* don't send a message to one of the
|
||||
public mailing lists. Django has a
|
||||
:ref:`policy for handling security issues <reporting-security-issues>`;
|
||||
while a defect is outstanding, we would like to minimize any damage that
|
||||
could be inflicted through public knowledge of that defect.
|
||||
|
||||
.. _`policy for handling security issues`: ../contributing/#reporting-security-issues
|
|
@ -0,0 +1,15 @@
|
|||
==========
|
||||
Django FAQ
|
||||
==========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
general
|
||||
install
|
||||
usage
|
||||
help
|
||||
models
|
||||
admin
|
||||
contributing
|
||||
troubleshooting
|
Loading…
Reference in New Issue