Re: making slug field unique
On 1/17/06, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > > On Tuesday 17 Jan 2006 9:04 pm, Bryan Murdock wrote: > > OK, so as a database dummy, how exactly is this done? Do I pipe > > the output of 'manage.py sqlreset myapp' to psql, or is there a > > less drastic way since I know I've only changed this one thing? > > I don't have any real data in the database yet, but I guess > > eventually I probably will and will need to make changes without > > loosing it. > > its explained in the faq Ahh, I see. Thanks. Bryan
Re: making slug field unique
On Tuesday 17 Jan 2006 9:04 pm, Bryan Murdock wrote: > OK, so as a database dummy, how exactly is this done? Do I pipe > the output of 'manage.py sqlreset myapp' to psql, or is there a > less drastic way since I know I've only changed this one thing? > I don't have any real data in the database yet, but I guess > eventually I probably will and will need to make changes without > loosing it. its explained in the faq -- regards kg http://www.livejournal.com/users/lawgon tally ho! http://avsap.org.in ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!
Re: making slug field unique
On Tuesday 17 Jan 2006 3:53 pm, Jordi Funollet wrote: > > Afaik Django enforces uniqueness at the application level, but > > you could always add it to the database: > > Ouch. Really? So Django is assuming that we are going to work > with their database *exclusively* through Django, and doesn't > protect us from doing silly things to the data when integrating > with other applications. > > This restriction should be on database, shouldn't it? restriction has to be in the database, but django checks at it's level in the admin, but in the main site, if you forget to check, you will get an ugly 'programming error' from the database. And i have noticed that if you have 'unique_together' then django apparently doesnt check at it's level -- regards kg http://www.livejournal.com/users/lawgon tally ho! http://avsap.org.in ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!
Re: making slug field unique
On 1/17/06, Jordi Funollet <[EMAIL PROTECTED]> wrote: > This restriction should be on database, shouldn't it? I'd think this would run into compatibility problems with the various supported backends. For example, SQLite supports UNIQUE, but not FOREIGN KEY constraints (its official docs say that it parses them but doesn't enforce them). This means that, even if Django created tables with the appropriate syntax to tell the DB to enforce things, there'd be a chance that the DB wouldn't do that, so you're kind of stuck having Django enforce things for you. -- "May the forces of evil become confused on the way to your house." -- George Carlin
Re: making slug field unique
Julio Nobrega dixit: > Afaik Django enforces uniqueness at the application level, but you > could always add it to the database: Ouch. Really? So Django is assuming that we are going to work with their database *exclusively* through Django, and doesn't protect us from doing silly things to the data when integrating with other applications. This restriction should be on database, shouldn't it? -- ## ### Jordi Funollet ### http://www.terraquis.net
Re: making slug field unique
Afaik Django enforces uniqueness at the application level, but you could always add it to the database: ALTER TABLE table ADD UNIQUE (slug) I don't think it's a bad idea at all, it all depends ;) On 1/16/06, Bryan Murdock <[EMAIL PROTECTED]> wrote: > > I think I want my model's SlugField to be unique (let me know if this > is a Bad Idea for any reason). So I edit my model and change > slug=meta.SlugField() to slug=meta.SlugField(unique=True). Do I need > to do anything to update the database now? > > Thanks, > > Bryan >
making slug field unique
I think I want my model's SlugField to be unique (let me know if this is a Bad Idea for any reason). So I edit my model and change slug=meta.SlugField() to slug=meta.SlugField(unique=True). Do I need to do anything to update the database now? Thanks, Bryan