Re: urls.py usage

2011-03-02 Thread Vladimir
Thank you very much!!! It works!
I followed "Python Web Development with Django. J.Forcier, P.Bissex,
W.Chun" (I used russian edition). They instruct readers to include
registration statement in model.py:
Chapter 2 (my reverse translation from russian into English): Open
file mysite/blog/models.py, add admin application import statement and
then add in the end of file your model registration statement.
from django.db import models
from django.contrib import admin
class BlogPost(models.Model):
title = models.CarField(max_length=150)
body=models.TextField()
timestamp=models.DateTimeField()
admin.site.register(BlogPost)

Later they develop this model: Add to your file mysite/blog/models.py
a new class BlogPostAdmin and add this name to registration method
call:
class BlogPostAdmin(admin.ModelAdmin):
list_display = ('title', 'timestamp')
admin.site.register(BlogPost, BlogPostAdmin)

In other projects they instruct us similarly. No admin.py files!

-- 
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: urls.py usage

2011-03-01 Thread Daniel Roseman
On Monday, February 28, 2011 7:29:17 PM UTC, Vladimir wrote:
>
> I only followed manuals! Please, Mr. Daniel, give me more details!


Well I don't know which manuals you followed. The online documentation 
(http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#modeladmin-objects) 
states this clearly:

"The ModelAdmin class is the representation of a model in the admin 
interface. These are stored in a file named admin.py in your application."

So do as it says and move your ModelAdmin class into admin.py, along with 
the call to admin.site.register, and all should be fine.
--
DR.

-- 
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: urls.py usage

2011-02-28 Thread Vladimir
I only followed manuals! Please, Mr. Daniel, give me more details!

-- 
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: urls.py usage

2011-02-28 Thread Daniel Roseman
On Monday, February 28, 2011 4:26:57 PM UTC, Vladimir wrote:
>
>
> >   That you have duplicate registration of one model in your admin.py 
> > somewhere (I believe, I may be wrong). 
> There is no admin.py file in this project. 
>

Well, why not? That is the cause of your problem. Putting admin registration 
in models.py will frequently lead to this error, which is the whole reason 
for having a separate admin.py.
--
DR.

-- 
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: urls.py usage

2011-02-28 Thread Vladimir

>   That you have duplicate registration of one model in your admin.py
> somewhere (I believe, I may be wrong).
There is no admin.py file in this project.
Model.py file contains:
from django.db import models
from django.contrib import admin
class BlogPost(models.Model):
title = models.CharField(max_length=150)
body = models.TextField()
timestamp = models.DateTimeField()
class Meta:
ordering = ('-timestamp',)
class BlogPostAdmin(admin.ModelAdmin):
list_display = ('title', 'timestamp')
admin.site.register(BlogPost, BlogPostAdmin)

-- 
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: urls.py usage

2011-02-28 Thread Jirka Vejrazka
> AlreadyRegistered at /blog/
> The model BlogPost is already registered

  That you have duplicate registration of one model in your admin.py
somewhere (I believe, I may be wrong).

  Cheers

Jirka

-- 
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: urls.py usage

2011-02-28 Thread Vladimir
What does this message (it appears after web browser entering) means:

AlreadyRegistered at /blog/
The model BlogPost is already registered

?

-- 
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.



urls.py usage

2011-02-27 Thread Vladimir
2. Studying example (CMS) in "Python Web Development with Django.
J.Forcier, P.Bissex, W.Chun" I have got an error:
https://docs.google.com/leaf?id=0B5W4njXO9ND_Mzg1M2U0ZGItYzZiMS00Y2Qx...

adding detailes. I study CMS project in Chapter 8 in that book.
Following authors I wrote:
1) project level cmsproject/urls.py:
from django.contrib import admin
from django.conf.urls.defaults import *
admin.autodiscover()
urlpatterns = patterns('',
# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
# url(r'^admin/(.*)', admin.site.root),
url(r'^admin/(.*)', admin.site.urls),
url(r'^cms/', include('cmsproject.cms.urls')),
# Example:
# Uncomment the admin/doc line below to enable admin
documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
)

2) application level cmsproject/cms/urls.py:
from django.conf.urls.defaults import *
from cms.models import Story
from cms.models import Category
info_dict = {'queryset': Story.objects.all(), 'template_object_name':
'story'}
urlpatterns = patterns('cmsproject.cms.views',
url(r'^category/(?P[-\w]+)/$', 'category', name="cms-
category"),
url(r'^search/$', 'search', name="cms-search"),
)
urlpatterns += patterns('django.views.generic.list_detail',
url(r'^(?P[-\w]+)/$', 'object_detail', info_dict, name="cms-
story"),
url(r'^$', 'object_list', info_dict, name="cms-home"),
)

error message is: TemplateSyntaxError at /admin/
Caught AlreadyRegistered while rendering: The model Category is
already registered

I also don't understand why cmsproject/cms/urls.py contains = but not
+= in the statement
urlpatterns = patterns...

-- 
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.