Re: /admin weirdness
It is because your admin models are registered in models.py. If you register them in admin.py you will not observe this problem. Just move the RecordAdmin class and the registration into admin.py (although if you want to, I'm pretty sure only the registration has to be in admin.py if you import the Record and RecordAdmin). Hope this helps, Casey On 03/17/2011 05:35 PM, chris hendrix wrote: admin models are registered in models.py for each app. Some people say to use an admin.py file but I've never had to do that before. currently using: Django 1.2.3 (mod_wsgi 3.2/Python 2.6) and hosting at webfaction There's nothing special about the model view. Here's one of them: from datetime import datetime from Client.models import Record as CRecord class Record (models.Model): id = models.AutoField (primary_key=True) title = models.CharField (max_length=128, blank=False) date = models.BigIntegerField (blank=False) client_id = models.ForeignKey(CRecord,db_index=True, blank=False) specialEventDate = models.IntegerField (blank=False) comments = models.TextField (blank=False) al_number = models.CharField (max_length=128, blank=False) lastOpened = models.BigIntegerField (blank=False) whenSubmitted = models.BigIntegerField (blank=False) source = models.CharField (max_length=255, blank=False) class RecordAdmin(admin.ModelAdmin): def Client_Firstname(self, obj): return obj.client_id.firstName def Client_Lastname(self, obj): return obj.client_id.lastName def OrderDate(self, obj): return datetime.fromtimestamp(obj.date) def DateSubmitted(self, obj): return datetime.fromtimestamp(obj.whenSubmitted) list_display = ('id','Client_Firstname','Client_Lastname','client_id','OrderDate','DateSubmitted') search_fields = ['client_id__firstName','client_id__lastName','client_id__id','title','status','comments','source'] admin.site.register(Record,RecordAdmin) any ideas? On 03/17/2011 03:50 PM, Casey Greene wrote: Where are you registering your models for the admin site and what does that code look like? Casey On 03/17/2011 03:14 PM, chris hendrix wrote: yeah the urls file looks fine... it only happens randomly but seems tied to DEBUG=False for some reason... not sure why that would make a difference. On 03/17/2011 03:09 PM, werefr0g wrote: Hi Bobby, Maybe some mistake on your url.py, for example if you have an app named "app" and a model named "model", you'll try to get this url to add a new "model" /admin/app/model/add/ Usually, you'll write your urls.py like this: (r'^app/', include('app.urls')), (r'^admin/', include(admin.site.urls)), If you forget the "^" before app/, the url for adding a new model will match the regex 'app/', and the admin will be shorcut, Just a guess against the material you brought ;) Regards, -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: /admin weirdness
admin models are registered in models.py for each app. Some people say to use an admin.py file but I've never had to do that before. currently using: Django 1.2.3 (mod_wsgi 3.2/Python 2.6) and hosting at webfaction There's nothing special about the model view. Here's one of them: from datetime import datetime from Client.models import Record as CRecord class Record (models.Model): id = models.AutoField (primary_key=True) title = models.CharField (max_length=128, blank=False) date = models.BigIntegerField (blank=False) client_id = models.ForeignKey(CRecord,db_index=True, blank=False) specialEventDate = models.IntegerField (blank=False) comments = models.TextField (blank=False) al_number = models.CharField (max_length=128, blank=False) lastOpened = models.BigIntegerField (blank=False) whenSubmitted = models.BigIntegerField (blank=False) source = models.CharField (max_length=255, blank=False) class RecordAdmin(admin.ModelAdmin): def Client_Firstname(self, obj): return obj.client_id.firstName def Client_Lastname(self, obj): return obj.client_id.lastName def OrderDate(self, obj): return datetime.fromtimestamp(obj.date) def DateSubmitted(self, obj): return datetime.fromtimestamp(obj.whenSubmitted) list_display = ('id','Client_Firstname','Client_Lastname','client_id','OrderDate','DateSubmitted') search_fields = ['client_id__firstName','client_id__lastName','client_id__id','title','status','comments','source'] admin.site.register(Record,RecordAdmin) any ideas? On 03/17/2011 03:50 PM, Casey Greene wrote: Where are you registering your models for the admin site and what does that code look like? Casey On 03/17/2011 03:14 PM, chris hendrix wrote: yeah the urls file looks fine... it only happens randomly but seems tied to DEBUG=False for some reason... not sure why that would make a difference. On 03/17/2011 03:09 PM, werefr0g wrote: Hi Bobby, Maybe some mistake on your url.py, for example if you have an app named "app" and a model named "model", you'll try to get this url to add a new "model" /admin/app/model/add/ Usually, you'll write your urls.py like this: (r'^app/', include('app.urls')), (r'^admin/', include(admin.site.urls)), If you forget the "^" before app/, the url for adding a new model will match the regex 'app/', and the admin will be shorcut, Just a guess against the material you brought ;) Regards, -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: /admin weirdness
Where are you registering your models for the admin site and what does that code look like? Casey On 03/17/2011 03:14 PM, chris hendrix wrote: yeah the urls file looks fine... it only happens randomly but seems tied to DEBUG=False for some reason... not sure why that would make a difference. On 03/17/2011 03:09 PM, werefr0g wrote: Hi Bobby, Maybe some mistake on your url.py, for example if you have an app named "app" and a model named "model", you'll try to get this url to add a new "model" /admin/app/model/add/ Usually, you'll write your urls.py like this: (r'^app/', include('app.urls')), (r'^admin/', include(admin.site.urls)), If you forget the "^" before app/, the url for adding a new model will match the regex 'app/', and the admin will be shorcut, Just a guess against the material you brought ;) Regards, -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: /admin weirdness
yeah the urls file looks fine... it only happens randomly but seems tied to DEBUG=False for some reason... not sure why that would make a difference. On 03/17/2011 03:09 PM, werefr0g wrote: Hi Bobby, Maybe some mistake on your url.py, for example if you have an app named "app" and a model named "model", you'll try to get this url to add a new "model" /admin/app/model/add/ Usually, you'll write your urls.py like this: (r'^app/', include('app.urls')), (r'^admin/', include(admin.site.urls)), If you forget the "^" before app/, the url for adding a new model will match the regex 'app/', and the admin will be shorcut, Just a guess against the material you brought ;) Regards, -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: /admin weirdness
Hi Bobby, Maybe some mistake on your url.py, for example if you have an app named "app" and a model named "model", you'll try to get this url to add a new "model" /admin/app/model/add/ Usually, you'll write your urls.py like this: (r'^app/', include('app.urls')), (r'^admin/', include(admin.site.urls)), If you forget the "^" before app/, the url for adding a new model will match the regex 'app/', and the admin will be shorcut, Just a guess against the material you brought ;) Regards, -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.