Here's the elections model: class Election(models.Model): uuid = UUIDField(primary_key=True, editable=False) election_name = models.CharField(max_length=100, unique=True) slug = models.SlugField(prepopulate_from=("election_name",), unique=True) election_date = models.DateField()
class Meta: ordering = ('-election_date',) class Admin: list_display = ('election_name', 'election_date') list_per_page = 20 def __unicode__(self): return self.election_name def get_absolute_url(self): return ('django.views.generic.list_detail.object_detail', (), { 'slug': self.slug, }) get_absolute_url = permalink(get_absolute_url) Here's the precincts model: class Precinct(models.Model): precinct_number = models.CharField(max_length=4, blank=True) precinct_name = models.CharField(max_length=100) slug = models.SlugField(prepopulate_from=("precinct_number","precinct_name",),) precinct_location = models.CharField(max_length=100) precinct_address = models.CharField(max_length=100) precinct_photo = models.ImageField(upload_to="images/ precincts",blank=True) precinct_map = models.ImageField(upload_to="images/precincts/ maps",blank=True) precinct_status = models.BooleanField("Active",default=True) class Meta: ordering = ('precinct_number',) unique_together = [("precinct_number", "precinct_name")] class Admin: list_display = ('precinct_number','precinct_name','precinct_status') list_display_links = ('precinct_number', 'precinct_name') list_filter = ('precinct_status',) list_per_page = 20 search_fields = ('precinct_name','precinct_location','precinct_address') fields = ( (None, { 'fields': (('precinct_number', 'precinct_name'), 'slug', 'precinct_location', 'precinct_address', 'precinct_status') }), ('Media', { 'classes': 'collapse', 'fields': ('precinct_photo','precinct_map') }) ) def __unicode__(self): return '%s %s' % (self.precinct_number, self.precinct_name) def get_absolute_url(self): return ('django.views.generic.list_detail.object_detail', (), { 'slug': self.slug, }) get_absolute_url = permalink(get_absolute_url) On Apr 21, 9:39 pm, Michael <[EMAIL PROTECTED]> wrote: > You interested in answering the first part of my post? I can't really help > you with information like this... > > 2008/4/21 jeffself <[EMAIL PROTECTED]>: > > > > > I don't think thats it because if I reverse the order of the url's in > > the root urls.py file and put precincts before elections, then > > precincts items work correctly but the election items point to > > precincts rather than elections. > > > On Apr 21, 3:52 pm, Michael <[EMAIL PROTECTED]> wrote: > > > How are you getting the URL? Is there something in your models that is > > > defining the absolute URL? or are you using the Revese lookup? > > > > Chances are because they are just copies of one another that you forgot > > to > > > change one of the files and they still have the get_absolute_url > > referring > > > to the elections one, > > > > Michael > > > > On Mon, Apr 21, 2008 at 12:48 PM, 小龙 <[EMAIL PROTECTED]> wrote: > > > > Show me ------ Settings.py > > > > > 2008/4/21, jeffself <[EMAIL PROTECTED]>: > > > > > > I've got a project that contains two apps (elections and precincts). > > > > > My root urls.py looks like this: > > > > > from django.conf.urls.defaults import * > > > > > urlpatterns = patterns('', > > > > > (r'^elections/', include('elections.urls')), > > > > > (r'^precincts/', include('precincts.urls')), > > > > > (r'^admin/', include('django.contrib.admin.urls')), > > > > > ) > > > > > > My elections urls.py looks like this: > > > > > from django.conf.urls.defaults import * > > > > > from elections.models import Election > > > > > from django.views.generic import list_detail > > > > > election_list_info = { > > > > > 'queryset': Election.objects.all(), > > > > > 'allow_empty': True, > > > > > } > > > > > election_detail_info = { > > > > > "queryset" : Election.objects.all(), > > > > > "template_object_name" : "election", > > > > > } > > > > > urlpatterns = patterns('', > > > > > (r'^$', list_detail.object_list, election_list_info), > > > > > ) > > > > > urlpatterns += patterns('django.views.generic.list_detail', > > > > > (r'(?P<slug>[\w-]+)/$', 'object_detail', election_detail_info), > > > > > ) > > > > > > Each item on the elections page works correctly and has the correct > > > > > URL. > > > > > > My precincts urls.py file looks identical to the elections urls.py > > > > > file except it imports the precincts model and I changed the code > > from > > > > > election to precinct where necessary. I can bring up the Precincts > > > > > page but the items on the page have the wrong url. Instead of > > having > > > > > a url likehttp://localhost:8000/precincts/0001, the url looks like > > > > >http://localhost:8000/elections/0001. I can see that its looking > > back > > > > > at the root urls.py first and chooses the elections pattern. But > > why > > > > > is this? > > > > > > What do I need to change to make it look at precincts instead of > > > > > elections? I need to understand this so I can continue to separate > > my > > > > > program into separate apps as much as possible. Thanks! > > > > > -- > > > > deSign thE fuTure > > > >http://www.freeis.cn/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---