The idea:
Users can enter books into a database. The books can be accessed as
follows: http://website.com/<username>/<slug>

Here's a simple model:
class Book(models.Model):
        title = models.CharField(maxlength=200)
        author = models.CharField(maxlength=200)
        slug = models.SlugField(prepopulate_from=("title",), unique=True)
        review = models.TextField(blank=True)
        user = models.ForeignKey(User)
        timestamp = models.DateTimeField(auto_now=True)

Two problems here:
I don't have a problem with two or three or ten users entering Harry
Potter into the database; annoyingly though, all but the first user
will get an error saying the slug must be unique. Can I define the
slug as having to be unique for the user?

The other problem is in those cases where there will be a duplicate
slug. I don't want the users to worry about it, so is there a way to
automatically 'fix' the slug if it's a duplicate? Say, by adding a
number to it to make it unique?

Sorry if this has been asked before, I did a search and all I could
find were questions about modifying user profiles. That's what 'unique
user' gets you anyway.

Thanks alot,
Björn

P.S. I threw in the timestamp field since I vaguely remember reading
somewhere that auto_now is deprecated. So here's hoping someone will
tell me off and guide me to a preferred practice.


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

Reply via email to