mirror of
https://github.com/django/django.git
synced 2024-11-21 19:09:18 +01:00
Changed more imports from absolute to relative
This commit is contained in:
parent
4b369049ad
commit
914bb62661
@ -130,7 +130,7 @@ the action and its registration would look like::
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from myapp.models import Article
|
||||
from .models import Article
|
||||
|
||||
|
||||
@admin.action(description="Mark selected stories as published")
|
||||
|
@ -109,7 +109,7 @@ For example::
|
||||
|
||||
from django.shortcuts import render
|
||||
|
||||
from myapp.models import MyModel
|
||||
from .models import MyModel
|
||||
|
||||
|
||||
def my_view(request, slug):
|
||||
|
@ -89,7 +89,7 @@ Other topics
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from myapp.models import Author
|
||||
from .models import Author
|
||||
|
||||
|
||||
class AuthorAdmin(admin.ModelAdmin):
|
||||
@ -510,7 +510,7 @@ subclass::
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
|
||||
from myapp.models import Person
|
||||
from .models import Person
|
||||
|
||||
|
||||
class PersonForm(forms.ModelForm):
|
||||
@ -543,8 +543,8 @@ subclass::
|
||||
from django.db import models
|
||||
|
||||
# Import our custom widget and our model from where they're defined
|
||||
from myapp.models import MyModel
|
||||
from myapp.widgets import RichTextEditorWidget
|
||||
from .models import MyModel
|
||||
from .widgets import RichTextEditorWidget
|
||||
|
||||
|
||||
class MyModelAdmin(admin.ModelAdmin):
|
||||
@ -2254,7 +2254,8 @@ information.
|
||||
inlines to a model by specifying them in a ``ModelAdmin.inlines``::
|
||||
|
||||
from django.contrib import admin
|
||||
from myapp.models import Author, Book
|
||||
|
||||
from .models import Author, Book
|
||||
|
||||
|
||||
class BookInline(admin.TabularInline):
|
||||
@ -2563,7 +2564,8 @@ If you want to display many-to-many relations using an inline, you can do
|
||||
so by defining an ``InlineModelAdmin`` object for the relationship::
|
||||
|
||||
from django.contrib import admin
|
||||
from myapp.models import Group
|
||||
|
||||
from .models import Group
|
||||
|
||||
|
||||
class MembershipInline(admin.TabularInline):
|
||||
@ -2696,7 +2698,7 @@ any other inline. In your ``admin.py`` for this example app::
|
||||
from django.contrib import admin
|
||||
from django.contrib.contenttypes.admin import GenericTabularInline
|
||||
|
||||
from myapp.models import Image, Product
|
||||
from .models import Image, Product
|
||||
|
||||
|
||||
class ImageInline(GenericTabularInline):
|
||||
@ -3169,7 +3171,7 @@ to reference your :class:`AdminSite` subclass.
|
||||
|
||||
from django.urls import path
|
||||
|
||||
from myapp.admin import admin_site
|
||||
from .admin import admin_site
|
||||
|
||||
urlpatterns = [
|
||||
path("myadmin/", admin_site.urls),
|
||||
|
@ -855,7 +855,7 @@ extend these forms in this manner::
|
||||
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
|
||||
from myapp.models import CustomUser
|
||||
from .models import CustomUser
|
||||
|
||||
|
||||
class CustomUserCreationForm(UserCreationForm):
|
||||
|
@ -259,7 +259,7 @@ in ``myapp``::
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from myapp.models import BlogPost
|
||||
from .models import BlogPost
|
||||
|
||||
content_type = ContentType.objects.get_for_model(BlogPost)
|
||||
permission = Permission.objects.create(
|
||||
@ -299,7 +299,7 @@ the user from the database. For example::
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
||||
from myapp.models import BlogPost
|
||||
from .models import BlogPost
|
||||
|
||||
|
||||
def user_gains_perms(request, user_id):
|
||||
|
@ -245,7 +245,7 @@ works with an API-based workflow as well as 'normal' form POSTs::
|
||||
from django.http import JsonResponse
|
||||
from django.views.generic.edit import CreateView
|
||||
|
||||
from myapp.models import Author
|
||||
from .models import Author
|
||||
|
||||
|
||||
class JsonableResponseMixin:
|
||||
|
@ -683,7 +683,7 @@ Once you've written your model admin definitions, they can be
|
||||
registered with any ``Admin`` instance::
|
||||
|
||||
from django.contrib import admin
|
||||
from myapp.models import Author, Book, Publisher
|
||||
from .models import Author, Book, Publisher
|
||||
|
||||
# Import our custom ModelAdmin and TabularInline from where they're defined.
|
||||
from myproject.admin import MultiDBModelAdmin, MultiDBTabularInline
|
||||
|
@ -965,7 +965,7 @@ use the management form inside the template. Let's look at a sample view::
|
||||
from django.forms import formset_factory
|
||||
from django.shortcuts import render
|
||||
|
||||
from myapp.forms import ArticleForm
|
||||
from .forms import ArticleForm
|
||||
|
||||
|
||||
def manage_articles(request):
|
||||
@ -1052,7 +1052,7 @@ a look at how this might be accomplished::
|
||||
from django.forms import formset_factory
|
||||
from django.shortcuts import render
|
||||
|
||||
from myapp.forms import ArticleForm, BookForm
|
||||
from .forms import ArticleForm, BookForm
|
||||
|
||||
|
||||
def manage_articles(request):
|
||||
|
@ -216,7 +216,7 @@ sophisticated, but will produce incorrect results for some languages::
|
||||
|
||||
from django.utils.translation import ngettext
|
||||
|
||||
from myapp.models import Report
|
||||
from .models import Report
|
||||
|
||||
count = Report.objects.count()
|
||||
if count == 1:
|
||||
|
@ -92,7 +92,7 @@ your view class, for example::
|
||||
|
||||
from django.views.generic import ListView
|
||||
|
||||
from myapp.models import Contact
|
||||
from .models import Contact
|
||||
|
||||
|
||||
class ContactListView(ListView):
|
||||
@ -140,7 +140,7 @@ function to paginate a queryset::
|
||||
from django.core.paginator import Paginator
|
||||
from django.shortcuts import render
|
||||
|
||||
from myapp.models import Contact
|
||||
from .models import Contact
|
||||
|
||||
|
||||
def listing(request):
|
||||
|
@ -193,7 +193,7 @@ signals sent by some model::
|
||||
from django.db.models.signals import pre_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
from myapp.models import MyModel
|
||||
from .models import MyModel
|
||||
|
||||
|
||||
@receiver(pre_save, sender=MyModel)
|
||||
|
@ -26,7 +26,7 @@ transaction to provide isolation::
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from myapp.models import Animal
|
||||
from .models import Animal
|
||||
|
||||
|
||||
class AnimalTestCase(TestCase):
|
||||
|
@ -1247,7 +1247,7 @@ subclass::
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from myapp.models import Animal
|
||||
from .models import Animal
|
||||
|
||||
|
||||
class AnimalTestCase(TestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user