Re: Admin interface using CharField as a primary key
Forgot: In the trunk the problem also exists. 2006/3/30, Daniel Bimschas <[EMAIL PROTECTED]>: > If have a model like this: > > class Article(meta.Model): > cite_key = meta.CharField(maxlength=255, primary_key=True) > ... > > where "cite_key" is a unique string used in a bibtex-file. The problem > now are the links to the edit pages created by the admin interface. > The html-code is for example: > > > > which should link to > "http://host/bibtexapp/admin/bib/articles/AAMG:05/; but the browser > interpretes this as "aamg:05/" because of the colons in the url. So > the thing would be to url-encode the key I think. > > I was using 0.91 before, but switched to the trunk now. > > > > > > 2006/3/30, Andy Dustman <[EMAIL PROTECTED]>: > > > > On 3/30/06, Daniel Bimschas <[EMAIL PROTECTED]> wrote: > > > > > > Hi there! > > > > > > I'm currently trying to convert an old webapp written in PHP into a > > > django-based app. The PHP-System used VARCHAR-Fields as primary keys > > > in the MySQL - DB. > > > > > > Now, if i convert the data for the new tables created by Django, I > > > have the problem that the admin interface can't edit any entries where > > > the title contains colons (":"), because the admin interface uses the > > > primary keys in the url created. > > > > > > I'm currently using Django 0.92. > > > > What sort of field (i.e. models.XXXField) are you using for your > > primary key? Sounds like maybe a SlugField? Unless you are using the > > default primary key (implicit id = models.AutoField(), which is > > INTEGER AUTO_INCREMENT)? You might then need to set primary_key in > > Meta to prevent the default PK from being created. See the model-api > > docs. > > > > (All this assumes you are using the magic-removal branch, because you > > did say 0.92.) > > > > -- > > The Pythonic Principle: Python works the way it does > > because if it didn't, it wouldn't be Python. > > > > > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Admin interface using CharField as a primary key
If have a model like this: class Article(meta.Model): cite_key = meta.CharField(maxlength=255, primary_key=True) ... where "cite_key" is a unique string used in a bibtex-file. The problem now are the links to the edit pages created by the admin interface. The html-code is for example: which should link to "http://host/bibtexapp/admin/bib/articles/AAMG:05/; but the browser interpretes this as "aamg:05/" because of the colons in the url. So the thing would be to url-encode the key I think. I was using 0.91 before, but switched to the trunk now. 2006/3/30, Andy Dustman <[EMAIL PROTECTED]>: > > On 3/30/06, Daniel Bimschas <[EMAIL PROTECTED]> wrote: > > > > Hi there! > > > > I'm currently trying to convert an old webapp written in PHP into a > > django-based app. The PHP-System used VARCHAR-Fields as primary keys > > in the MySQL - DB. > > > > Now, if i convert the data for the new tables created by Django, I > > have the problem that the admin interface can't edit any entries where > > the title contains colons (":"), because the admin interface uses the > > primary keys in the url created. > > > > I'm currently using Django 0.92. > > What sort of field (i.e. models.XXXField) are you using for your > primary key? Sounds like maybe a SlugField? Unless you are using the > default primary key (implicit id = models.AutoField(), which is > INTEGER AUTO_INCREMENT)? You might then need to set primary_key in > Meta to prevent the default PK from being created. See the model-api > docs. > > (All this assumes you are using the magic-removal branch, because you > did say 0.92.) > > -- > The Pythonic Principle: Python works the way it does > because if it didn't, it wouldn't be Python. > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Admin interface using CharField as a primary key
Hi there! I'm currently trying to convert an old webapp written in PHP into a django-based app. The PHP-System used VARCHAR-Fields as primary keys in the MySQL - DB. Now, if i convert the data for the new tables created by Django, I have the problem that the admin interface can't edit any entries where the title contains colons (":"), because the admin interface uses the primary keys in the url created. I'm currently using Django 0.92. I really need some help here, or a bugfix or sth. I've put quite a lot of work into this now :( Regards, Daniel --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Assigning default value for field in admin
Hey that looks great! Thanks a lot, it will do for my purposes! 2006/3/27, tonemcd <[EMAIL PROTECTED]>: > > This looks like it might help, > http://lukeplant.me.uk/blog.php?id=1107301634 although it's not exactly > what you're after... > > Cheers, > Tone > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Assigning default value for field in admin
Hmm, really seems to be a problem. Does anybody know if the _post_save()-method is called BEFORE or AFTER the data is written to the django_admin_log-table? You could solve this issue by querying the django_admin_log-table and receiving the newest entry for the newly created or updated object. There, you'll find the user_id. Not a nice solution, but for some it could work... Regards, Daniel arthur debert schrieb: > If I read you right: > http://www.djangoproject.com/documentation/faq/#how-do-i-automatically-set-a-field-s-value-to-the-user-who-last-edited-the-object-in-the-admin > > I've solved almost this problem in an app, but that's because I would > get the user from the session cookie and put it on the request for the > form to be "auto-filled". It seems there's no out of the box way to > achieve this. > > -arthur > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Assigning default value for field in admin
Hi there, i'm currently writing my first Django application. I must say that Django is really what i've been searchin for for years. Right now I have a problem concerning the usage of the admin interface. I have a model like this: from django.core import meta from django.models.auth import users class Series(meta.Model): name = meta.CharField(maxlength=255, primary_key=True) contributor = meta.ForeignKey(users.User) #... When editing or creating a new object of class Series i would like Django to automatically insert the current logged in user as the "contributor". I dont see any way to do this inside the class definition. Hope you guys can help me here. Thanks a lot in advance, Daniel --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---