code
stringlengths
1
1.72M
language
stringclasses
1 value
""" A few bits of helper functions for comment views. """ import urllib import textwrap from django.http import HttpResponseRedirect from django.core import urlresolvers from django.shortcuts import render_to_response from django.template import RequestContext from django.core.exceptions import ObjectDoesNotExist from...
Python
from django import http from django.conf import settings from utils import next_redirect, confirmation_view from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.db import models from django.shortcuts import render_to_response from django.template import RequestContext from django.template....
Python
import time import datetime from django import forms from django.forms.util import ErrorDict from django.conf import settings from django.contrib.contenttypes.models import ContentType from models import Comment from django.utils.crypto import salted_hmac, constant_time_compare from django.utils.encoding import force_...
Python
import datetime from django.contrib.auth.models import User from django.contrib.comments.managers import CommentManager from django.contrib.contenttypes import generic from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.db import models from django.core im...
Python
""" A generic comment-moderation system which allows configuration of moderation options on a per-model basis. To use, do two things: 1. Create or import a subclass of ``CommentModerator`` defining the options you want. 2. Import ``moderator`` from this module and register one or more models, passing the model...
Python
""" Signals relating to comments. """ from django.dispatch import Signal # Sent just before a comment will be posted (after it's been approved and # moderated; this can be used to modify the comment (in place) with posting # details or other such actions. If any receiver returns False the comment will be # discarded a...
Python
from django.conf import settings from django.contrib.syndication.views import Feed from django.contrib.sites.models import Site from django.contrib import comments from django.utils.translation import ugettext as _ class LatestCommentFeed(Feed): """Feed of latest comments on the current site.""" def title(sel...
Python
from django.db import models from django.contrib.contenttypes.models import ContentType from django.utils.encoding import force_unicode class CommentManager(models.Manager): def in_moderation(self): """ QuerySet for all comments currently in the moderation queue. """ return self.ge...
Python
from django.conf.urls.defaults import * urlpatterns = patterns('django.contrib.comments.views', url(r'^post/$', 'comments.post_comment', name='comments-post-comment'), url(r'^posted/$', 'comments.comment_done', name='comments-comment-done'), url(r'^flag/(\d+)/$', 'moderation....
Python
from django import template from django.template.loader import render_to_string from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.contrib import comments from django.utils.encoding import smart_unicode register = template.Library() class BaseCommentNode(template.N...
Python
from django.contrib import admin from django.contrib.comments.models import Comment from django.utils.translation import ugettext_lazy as _, ungettext from django.contrib.comments import get_model from django.contrib.comments.views.moderation import perform_flag, perform_approve, perform_delete class CommentsAdmin(adm...
Python
from django.conf import settings from django.core import urlresolvers from django.core.exceptions import ImproperlyConfigured from django.contrib.comments.models import Comment from django.contrib.comments.forms import CommentForm from django.utils.importlib import import_module DEFAULT_COMMENTS_APP = 'django.contrib....
Python
""" Create a superuser from the command line. Deprecated; use manage.py createsuperuser instead. """ if __name__ == "__main__": from django.core.management import call_command call_command("createsuperuser")
Python
from django.contrib.auth.models import User from django.contrib.auth import authenticate from django.contrib.auth.tokens import default_token_generator from django.contrib.sites.models import get_current_site from django.template import Context, loader from django import forms from django.utils.translation import ugett...
Python
from django.utils.functional import lazy, memoize, SimpleLazyObject from django.contrib import messages # PermWrapper and PermLookupDict proxy the permissions system into objects that # the template system can understand. class PermLookupDict(object): def __init__(self, user, module_name): self.user, self...
Python
from django.db import connection from django.contrib.auth.models import User, Permission class ModelBackend(object): """ Authenticates against django.contrib.auth.models.User. """ supports_object_permissions = False supports_anonymous_user = True supports_inactive_user = True # TODO: Mode...
Python
import datetime import urllib from django.contrib import auth from django.contrib.auth.signals import user_logged_in from django.core.exceptions import ImproperlyConfigured from django.db import models from django.db.models.manager import EmptyManager from django.contrib.contenttypes.models import ContentType from dja...
Python
from mod_python import apache import os def authenhandler(req, **kwargs): """ Authentication handler that checks against Django's auth database. """ # mod_python fakes the environ, and thus doesn't process SetEnv. This fixes # that so that the following import works os.environ.update(req.subp...
Python
from django.dispatch import Signal user_logged_in = Signal(providing_args=['request', 'user']) user_logged_out = Signal(providing_args=['request', 'user'])
Python
import warnings from django.conf import settings from django.contrib.auth.models import User, Group, Permission, AnonymousUser from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ImproperlyConfigured from django.db import connection from django.test import TestCase from django...
Python
from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm from django.db import connection from django.test import TestCase from django.utils import unittest class UserCreationFormTest...
Python
from django.conf import settings from django.test import TestCase from django.contrib.auth.models import User, SiteProfileNotAvailable class ProfileTestCase(TestCase): fixtures = ['authtestdata.json'] def setUp(self): """Backs up the AUTH_PROFILE_MODULE""" self.old_AUTH_PROFILE_MODULE = getattr...
Python
from django.test import TestCase from django.contrib.auth import signals class SignalTestCase(TestCase): urls = 'django.contrib.auth.tests.urls' fixtures = ['authtestdata.json'] def listener_login(self, user, **kwargs): self.logged_in.append(user) def listener_logout(self, user, **kwargs): ...
Python
from django.test import TestCase from django.contrib.auth.models import User, AnonymousUser from django.core.management import call_command from StringIO import StringIO class BasicTestCase(TestCase): def test_user(self): "Check that users can be created and can set their password" u = User.objects...
Python
try: from cStringIO import StringIO except ImportError: from StringIO import StringIO from django.contrib.auth.management import create_permissions from django.contrib.auth import models as auth_models from django.contrib.contenttypes import models as contenttypes_models from django.core.management import call...
Python
from django.conf.urls.defaults import patterns from django.contrib.auth.urls import urlpatterns from django.contrib.auth.views import password_reset from django.contrib.auth.decorators import login_required from django.http import HttpResponse from django.template import Template, RequestContext from django.views.decor...
Python
from datetime import datetime from django.conf import settings from django.contrib.auth.backends import RemoteUserBackend from django.contrib.auth.models import User from django.test import TestCase class RemoteUserTest(TestCase): urls = 'django.contrib.auth.tests.urls' middleware = 'django.contrib.auth.mid...
Python
from django.conf import settings from django.contrib.auth.decorators import login_required from django.contrib.auth.tests.views import AuthViewsTestCase class LoginRequiredTestCase(AuthViewsTestCase): """ Tests the login_required decorators """ urls = 'django.contrib.auth.tests.urls' def testCalla...
Python
from datetime import date, timedelta from django.conf import settings from django.contrib.auth.models import User, AnonymousUser from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.test import TestCase class TokenGeneratorTest(TestCase): def test_make_token(self): """ ...
Python
import os import re import urllib from django.conf import settings from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME from django.contrib.auth.forms import AuthenticationForm from django.contrib.sites.models import Site, RequestSite from django.contrib.auth.models import User from django.test import Test...
Python
from django.contrib.auth.tests.auth_backends import (BackendTest, RowlevelBackendTest, AnonymousUserBackendTest, NoAnonymousUserBackendTest, NoBackendsTest, InActiveUserBackendTest, NoInActiveUserBackendTest) from django.contrib.auth.tests.basic import BasicTestCase from django.contrib.auth.tests.decorators imp...
Python
# These URLs are normally mapped to /admin/urls.py. This URLs file is # provided as a convenience to those who want to deploy these URLs elsewhere. # This file is also used to provide a reliable view deployment for test purposes. from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^login/$', 'dj...
Python
from django.contrib import auth from django.core.exceptions import ImproperlyConfigured class LazyUser(object): def __get__(self, request, obj_type=None): if not hasattr(request, '_cached_user'): from django.contrib.auth import get_user request._cached_user = get_user(request) ...
Python
import urlparse try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.4 fallback. from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME from django.utils.decorators import available_attrs def user_passes_test(test_func, login...
Python
from django.db import transaction from django.conf import settings from django.contrib import admin from django.contrib.auth.forms import UserCreationForm, UserChangeForm, AdminPasswordChangeForm from django.contrib.auth.models import User, Group from django.contrib import messages from django.core.exceptions import Pe...
Python
""" Management utility to create superusers. """ import getpass import re import sys from optparse import make_option from django.contrib.auth.models import User from django.core import exceptions from django.core.management.base import BaseCommand, CommandError from django.utils.translation import ugettext as _ RE_V...
Python
from django.core.management.base import BaseCommand, CommandError from django.contrib.auth.models import User import getpass class Command(BaseCommand): help = "Change a user's password for django.contrib.auth." requires_model_validation = False def _get_pass(self, prompt="Password: "): p = getpa...
Python
""" Creates permissions for all installed apps that need permissions. """ from django.contrib.auth import models as auth_app from django.db.models import get_models, signals def _get_permission_codename(action, opts): return u'%s_%s' % (action, opts.object_name.lower()) def _get_all_permissions(opts): "Retu...
Python
from datetime import date from django.conf import settings from django.utils.hashcompat import sha_constructor from django.utils.http import int_to_base36, base36_to_int from django.utils.crypto import constant_time_compare, salted_hmac class PasswordResetTokenGenerator(object): """ Strategy object used to ge...
Python
import urlparse from django.conf import settings from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, QueryDict from django.shortcuts import render_to_response from django.template import RequestContext from django.utils.http import urlsafe_base64_decode from django.utils.translat...
Python
import datetime from warnings import warn from django.core.exceptions import ImproperlyConfigured from django.utils.importlib import import_module from django.contrib.auth.signals import user_logged_in, user_logged_out SESSION_KEY = '_auth_user_id' BACKEND_SESSION_KEY = '_auth_user_backend' REDIRECT_FIELD_NAME = 'next...
Python
from django.db import models from django.contrib.sites.models import Site from django.utils.translation import ugettext_lazy as _ class Redirect(models.Model): site = models.ForeignKey(Site) old_path = models.CharField(_('redirect from'), max_length=200, db_index=True, help_text=_("This should be an ab...
Python
from django.contrib.redirects.models import Redirect from django import http from django.conf import settings class RedirectFallbackMiddleware(object): def process_response(self, request, response): if response.status_code != 404: return response # No need to check for a redirect for non-404 re...
Python
from django.contrib import admin from django.contrib.redirects.models import Redirect class RedirectAdmin(admin.ModelAdmin): list_display = ('old_path', 'new_path') list_filter = ('site',) search_fields = ('old_path', 'new_path') radio_fields = {'site': admin.VERTICAL} admin.site.register(Redirect, R...
Python
# Empty models.py to allow for specifying admindocs as a test label.
Python
from django.db import models class CustomField(models.Field): description = "A custom field type" class DescriptionLackingField(models.Field): pass
Python
from django.contrib.admindocs import views from django.db.models import fields as builtin_fields from django.utils import unittest import fields class TestFieldType(unittest.TestCase): def setUp(self): pass def test_field_name(self): self.assertRaises(AttributeError, views.get_re...
Python
from django.conf.urls.defaults import * from django.contrib.admindocs import views urlpatterns = patterns('', url('^$', views.doc_index, name='django-admindocs-docroot' ), url('^bookmarklets/$', views.bookmarklets, name='django-admindocs-bookmarklets' ), url('^tags/$...
Python
"Misc. utility functions/classes for admin documentation generator." import re from email.Parser import HeaderParser from email.Errors import HeaderParseError from django.utils.safestring import mark_safe from django.core.urlresolvers import reverse from django.utils.encoding import smart_str try: import docutils....
Python
from django import template, templatetags from django.template import RequestContext from django.conf import settings from django.contrib.admin.views.decorators import staff_member_required from django.db import models from django.shortcuts import render_to_response from django.core.exceptions import ImproperlyConfigur...
Python
from django.db import models from django.utils.translation import ugettext_lazy as _ SITE_CACHE = {} class SiteManager(models.Manager): def get_current(self): """ Returns the current ``Site`` based on the SITE_ID in the project's settings. The ``Site`` object is cached the first ...
Python
from django.conf import settings from django.contrib.sites.models import Site, RequestSite, get_current_site from django.core.exceptions import ObjectDoesNotExist from django.http import HttpRequest from django.test import TestCase class SitesFrameworkTests(TestCase): def setUp(self): Site(id=settings.SI...
Python
from django.conf import settings from django.db import models from django.db.models.fields import FieldDoesNotExist class CurrentSiteManager(models.Manager): "Use this to limit objects to those associated with the current site." def __init__(self, field_name=None): super(CurrentSiteManager, self).__ini...
Python
from django.contrib import admin from django.contrib.sites.models import Site class SiteAdmin(admin.ModelAdmin): list_display = ('domain', 'name') search_fields = ('domain', 'name') admin.site.register(Site, SiteAdmin)
Python
""" Creates the default Site object. """ from django.db.models import signals from django.db import router from django.contrib.sites.models import Site from django.contrib.sites import models as site_app def create_default_site(app, created_models, verbosity, db, **kwargs): # Only create the default sites in data...
Python
from django.contrib.admin.filterspecs import FilterSpec from django.contrib.admin.options import IncorrectLookupParameters from django.contrib.admin.util import quote, get_fields_from_path from django.core.exceptions import SuspiciousOperation from django.core.paginator import InvalidPage from django.db import models f...
Python
try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.4 fallback. from django.utils.translation import ugettext as _ from django.contrib.admin.forms import AdminAuthenticationForm from django.contrib.auth.views import login from django.contrib.auth import RE...
Python
from django import forms from django.contrib.auth import authenticate from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.models import User from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. " ...
Python
from django.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.auth.models import User from django.contrib.admin.util import quote from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_unicode from django.utils.safestring import mark...
Python
#!/usr/bin/env python import os import optparse import subprocess import sys here = os.path.dirname(__file__) def main(): usage = "usage: %prog [file1..fileN]" description = """With no file paths given this script will automatically compress all jQuery-based files of the admin app. Requires the Google Closure...
Python
""" FilterSpec encapsulates the logic for displaying filters in the Django admin. Filters are specified in models with the "list_filter" option. Each filter subclass knows how to display a filter for a field that passes a certain test -- e.g. being a DateField or ForeignKey. """ from django.db import models from djan...
Python
from django import template register = template.Library() def prepopulated_fields_js(context): """ Creates a list of prepopulated_fields that should render Javascript for the prepopulated fields for both the admin form and inlines. """ prepopulated_fields = [] if context['add'] and 'adminform'...
Python
from django.template import Library from django.templatetags.static import PrefixNode register = Library() @register.simple_tag def admin_media_prefix(): """ Returns the string contained in the setting ADMIN_MEDIA_PREFIX. """ return PrefixNode.handle_simple("ADMIN_MEDIA_PREFIX")
Python
from django import template from django.contrib.admin.models import LogEntry register = template.Library() class AdminLogNode(template.Node): def __init__(self, limit, varname, user): self.limit, self.varname, self.user = limit, varname, user def __repr__(self): return "<GetAdminLog Node>" ...
Python
import datetime from django.conf import settings from django.contrib.admin.util import lookup_field, display_for_field, label_for_field from django.contrib.admin.views.main import (ALL_VAR, EMPTY_CHANGELIST_VALUE, ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR) from django.core.exceptions import ObjectDoesNotExis...
Python
from django.db import models from django.db.models.sql.constants import LOOKUP_SEP from django.db.models.deletion import Collector from django.db.models.related import RelatedObject from django.forms.forms import pretty_name from django.utils import formats from django.utils.html import escape from django.utils.safestr...
Python
from django.core.exceptions import ImproperlyConfigured from django.db import models from django.db.models.fields import FieldDoesNotExist from django.forms.models import (BaseModelForm, BaseModelFormSet, fields_for_model, _get_foreign_key) from django.contrib.admin.util import get_fields_from_path, NotRelationFiel...
Python
from django import forms from django.conf import settings from django.contrib.admin.util import (flatten_fieldsets, lookup_field, display_for_field, label_for_field, help_text_for_field) from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist from django.db.m...
Python
from django import forms, template from django.forms.formsets import all_valid from django.forms.models import (modelform_factory, modelformset_factory, inlineformset_factory, BaseInlineFormSet) from django.contrib.contenttypes.models import ContentType from django.contrib.admin import widgets, helpers from django....
Python
import re from django import http, template from django.contrib.admin import ModelAdmin, actions from django.contrib.admin.forms import AdminAuthenticationForm from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.contenttypes import views as contenttype_views from django.views.decorators.csrf import ...
Python
""" Form Widget classes specific to the Django admin site. """ import django.utils.copycompat as copy from django import forms from django.forms.widgets import RadioFieldRenderer from django.forms.util import flatatt from django.utils.html import escape from django.utils.text import truncate_words from django.utils.t...
Python
# ACTION_CHECKBOX_NAME is unused, but should stay since its import from here # has been referenced in documentation. from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL from django.contrib.admin.options import StackedInline, TabularInli...
Python
""" Built-in, globally-available admin actions. """ from django import template from django.core.exceptions import PermissionDenied from django.contrib.admin import helpers from django.contrib.admin.util import get_deleted_objects, model_ngettext from django.db import router from django.shortcuts import render_to_resp...
Python
import cStringIO, zipfile from django.conf import settings from django.http import HttpResponse from django.template import loader def compress_kml(kml): "Returns compressed KMZ from the given KML string." kmz = cStringIO.StringIO() zf = zipfile.ZipFile(kmz, 'a', zipfile.ZIP_DEFLATED) zf.writestr('doc....
Python
from django.db import connection if (hasattr(connection.ops, 'spatial_version') and not connection.ops.mysql): # Getting the `SpatialRefSys` and `GeometryColumns` # models for the default spatial backend. These # aliases are provided for backwards-compatibility. SpatialRefSys = connection.ops.spat...
Python
from django.core import urlresolvers from django.contrib.sitemaps import Sitemap class GeoRSSSitemap(Sitemap): """ A minimal hook to produce sitemaps for GeoRSS feeds. """ def __init__(self, feed_dict, slug_dict=None): """ This sitemap object initializes on a feed dictionary (as would b...
Python
from django.core import urlresolvers from django.contrib.sitemaps import Sitemap from django.contrib.gis.db.models.fields import GeometryField from django.db import models class KMLSitemap(Sitemap): """ A minimal hook to produce KML sitemaps. """ geo_format = 'kml' def __init__(self, locations=Non...
Python
from django.http import HttpResponse, Http404 from django.template import loader from django.contrib.sites.models import get_current_site from django.core import urlresolvers from django.core.paginator import EmptyPage, PageNotAnInteger from django.contrib.gis.db.models.fields import GeometryField from django.db import...
Python
# Geo-enabled Sitemap classes. from django.contrib.gis.sitemaps.georss import GeoRSSSitemap from django.contrib.gis.sitemaps.kml import KMLSitemap, KMZSitemap
Python
from django.contrib.gis.geos import \ GEOSGeometry as Geometry, \ GEOSException as GeometryException
Python
from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.utils.importlib import import_module geom_backend = getattr(settings, 'GEOMETRY_BACKEND', 'geos') try: module = import_module('.%s' % geom_backend, 'django.contrib.gis.geometry.backend') except ImportError, e: ...
Python
import re # Regular expression for recognizing HEXEWKB and WKT. A prophylactic measure # to prevent potentially malicious input from reaching the underlying C # library. Not a substitute for good Web security programming practices. hex_regex = re.compile(r'^[0-9A-F]+$', re.I) wkt_regex = re.compile(r'^(SRID=(?P<srid...
Python
from django.contrib.gis.geos import GEOSGeometry, LinearRing, Polygon, Point from django.contrib.gis.maps.google.gmap import GoogleMapException from math import pi, sin, cos, log, exp, atan # Constants used for degree to radian conversion, and vice-versa. DTOR = pi / 180. RTOD = 180. / pi class GoogleZoom(object): ...
Python
from django.utils.safestring import mark_safe from django.contrib.gis.geos import fromstr, Point, LineString, LinearRing, Polygon class GEvent(object): """ A Python wrapper for the Google GEvent object. Events can be attached to any object derived from GOverlayBase with the add_event() call. For ...
Python
""" This module houses the GoogleMap object, used for generating the needed javascript to embed Google Maps in a Web page. Google(R) is a registered trademark of Google, Inc. of Mountain View, California. Example: * In the view: return render_to_response('template.html', {'google' : GoogleMap(key="...
Python
from django.conf import settings from django.contrib.gis import geos from django.template.loader import render_to_string from django.utils.safestring import mark_safe class GoogleMapException(Exception): pass from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker, GIcon # The default Google ...
Python
from django.contrib.syndication.feeds import Feed as BaseFeed, FeedDoesNotExist from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed class GeoFeedMixin(object): """ This mixin provides the necessary routines for SyndicationFeed subclasses to produce simple GeoRSS or W3C Geo elements. """ ...
Python
""" Utilities for manipulating Geometry WKT. """ def precision_wkt(geom, prec): """ Returns WKT text of the geometry according to the given precision (an integer or a string). If the precision is an integer, then the decimal places of coordinates WKT will be truncated to that number: >>> pnt =...
Python
""" This module houses the GeoIP object, a ctypes wrapper for the MaxMind GeoIP(R) C API (http://www.maxmind.com/app/c). This is an alternative to the GPL licensed Python GeoIP interface provided by MaxMind. GeoIP(R) is a registered trademark of MaxMind, LLC of Boston, Massachusetts. For IP-based geolocation, t...
Python
""" This module is for inspecting OGR data sources and generating either models for GeoDjango and/or mapping dictionaries for use with the `LayerMapping` utility. Author: Travis Pinney, Dane Springmeyer, & Justin Bronn """ from itertools import izip # Requires GDAL to use. from django.contrib.gis.gdal import DataSourc...
Python
""" This module includes some utility functions for inspecting the layout of a GDAL data source -- the functionality is analogous to the output produced by the `ogrinfo` utility. """ from django.contrib.gis.gdal import DataSource from django.contrib.gis.gdal.geometries import GEO_CLASSES def ogrinfo(data_source, num_...
Python
# LayerMapping -- A Django Model/OGR Layer Mapping Utility """ The LayerMapping class provides a way to map the contents of OGR vector files (e.g. SHP files) to Geographic-enabled Django models. For more information, please consult the GeoDjango documentation: http://geodjango.org/docs/layermapping.html """ impo...
Python
""" This module contains useful utilities for GeoDjango. """ # Importing the utilities that depend on GDAL, if available. from django.contrib.gis.gdal import HAS_GDAL if HAS_GDAL: from django.contrib.gis.utils.ogrinfo import ogrinfo, sample from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect ...
Python
from django.contrib.gis.gdal import SpatialReference from django.db import connections, DEFAULT_DB_ALIAS def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None, database=DEFAULT_DB_ALIAS): """ This function takes a GDAL SpatialReference system and adds its information ...
Python
from django.contrib.gis.sitemaps import GeoRSSSitemap, KMLSitemap, KMZSitemap from models import City, Country from feeds import feed_dict sitemaps = {'kml' : KMLSitemap([City, Country]), 'kmz' : KMZSitemap([City, Country]), 'georss' : GeoRSSSitemap(feed_dict), }
Python
from django.contrib.gis.db import models from django.contrib.gis.tests.utils import mysql, spatialite # MySQL spatial indices can't handle NULL geometries. null_flag = not mysql class Country(models.Model): name = models.CharField(max_length=30) mpoly = models.MultiPolygonField() # SRID, by default, is 4326 ...
Python
import re from django.db import connection from django.contrib.gis import gdal from django.contrib.gis.geos import fromstr, GEOSGeometry, \ Point, LineString, LinearRing, Polygon, GeometryCollection from django.contrib.gis.measure import Distance from django.contrib.gis.tests.utils import \ no_mysql, no_oracle,...
Python
from django.contrib.gis import feeds from django.contrib.gis.tests.utils import mysql from models import City, Country class TestGeoRSS1(feeds.Feed): link = '/city/' title = 'Test GeoDjango Cities' def items(self): return City.objects.all() def item_link(self, item): return '/city/%s/...
Python
from django.conf.urls.defaults import * from feeds import feed_dict urlpatterns = patterns('', (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feed_dict}), ) from sitemaps import sitemaps urlpatterns += patterns('django.contrib.gis.sitemaps.views', (r'^sitemap.xml$', 'index', ...
Python
from django.contrib.gis.db import models class City3D(models.Model): name = models.CharField(max_length=30) point = models.PointField(dim=3) objects = models.GeoManager() def __unicode__(self): return self.name class Interstate2D(models.Model): name = models.CharField(max_length=30) l...
Python