Auto Increment Primary_Key
Hi, I am in a trouble and need help. We have an application developed in Django and has a custom defined (Char Type) primary key. Due to few new features, we need to change the primary key to a AutoGenerated Key. We manually added a column named id, a sequence and a trigger (same naming convention as Django creates since doing syncdb for existing tables doesn't work). The problem the we are facing is- 1) The application works fine when "id" is added in the Job class in models (models.CharField(max_length=200, primary_key=True)). While saving, a job object, job.id or job.pk (job is the model name) returns None although "id" is generated in Db. 2) If we remove "id" from Job class (w/o removing the db column, sequence and trigger), the application works fine but its extremely slow. The query which takes .08 seconds is taking 31 seconds to execute. We face the same issue, if we replace the "id" as AutoField. The performance is very slow. We can live with approach 1 but while running unit tests, it fails since it doesnt create the sequence and trigger on its own (note in approach 1, auto field is not specified) and by specifying auto field, tests work fine but the application is very slow. We need to fix this and its a bottle neck for us now. Any help on this will be highly appreciated. Thanks in advance.! Rakesh -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Auto Increment Primary_Key
This might not work for you but I would consider South. You might be able to rework the schema and migrate the data. On 19/09/2010, at 4:40 PM, "hellowrakesh...@gmail.com" wrote: > Hi, > I am in a trouble and need help. We have an application developed in > Django and has a custom defined (Char Type) primary key. Due to few > new features, we need to change the primary key to a AutoGenerated > Key. We manually added a column named id, a sequence and a trigger > (same naming convention as Django creates since doing syncdb for > existing tables doesn't work). The problem the we are facing is- > 1) The application works fine when "id" is added in the Job class in > models (models.CharField(max_length=200, primary_key=True)). While > saving, a job object, job.id or job.pk (job is the model name) > returns None although "id" is generated in Db. > 2) If we remove "id" from Job class (w/o removing the db column, > sequence and trigger), the application works fine but its extremely > slow. The query which takes .08 seconds is taking 31 seconds to > execute. We face the same issue, if we replace the "id" as AutoField. > The performance is very slow. > > We can live with approach 1 but while running unit tests, it fails > since it doesnt create the sequence and trigger on its own (note in > approach 1, auto field is not specified) and by specifying auto field, > tests work fine but the application is very slow. > > We need to fix this and its a bottle neck for us now. Any help on this > will be highly appreciated. > Thanks in advance.! > Rakesh > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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-us...@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: Auto Increment Primary_Key
Did you do any database migrations, or just add the new field? Just adding the new field to the model doesn't undo the groundwork laid by your original syncdb, which has set up the other field as the primary key in the database itself. Although your Django model is the way you want it, your database almost certainly is not. http://south.aeracode.org/ South should help you do what you want. You'll probably need to do it in multiple steps. I've not had to switch around primary keys in a Django project yet, so hopefully someone else will weigh in on this. But it'll look something like the following: 1. Add the new auto-number field in a schema migration (leave out "primary key" bit for now). 2. Remove "primary key" from the old field and add it to the new field, and create another schema migration from this. 3. Delete the old field (if desired) from the model and run another schema migration. All this is assuming that no other models have a foreign key reference to this model -- that will require a lot more work. If all else fails, you could create a whole new model, create a data migration with South to transfer all the data from the old model, then delete the old model. Hopefully you can get by without doing that, but if your production database is in an uncertain state then it may be safer. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Auto Increment Primary_Key
Thanks for replying. By rework you mean i need to change the schema. I have production data in the existing table where i have to add the primary key. With approach 1, we have been able to get everything working except tests as it doesnt create the sequence and triggers. Approach 2 works fine but the performance is very slow, any idea why the query takes too long to execute. There is no error but only performance issue. On Sun, Sep 19, 2010 at 1:49 AM, Mike Dewhirst wrote: > This might not work for you but I would consider South. > > You might be able to rework the schema and migrate the data. > > > > On 19/09/2010, at 4:40 PM, "hellowrakesh...@gmail.com" < > hellowrakesh...@gmail.com> wrote: > > > Hi, > > I am in a trouble and need help. We have an application developed in > > Django and has a custom defined (Char Type) primary key. Due to few > > new features, we need to change the primary key to a AutoGenerated > > Key. We manually added a column named id, a sequence and a trigger > > (same naming convention as Django creates since doing syncdb for > > existing tables doesn't work). The problem the we are facing is- > > 1) The application works fine when "id" is added in the Job class in > > models (models.CharField(max_length=200, primary_key=True)). While > > saving, a job object, job.id or job.pk (job is the model name) > > returns None although "id" is generated in Db. > > 2) If we remove "id" from Job class (w/o removing the db column, > > sequence and trigger), the application works fine but its extremely > > slow. The query which takes .08 seconds is taking 31 seconds to > > execute. We face the same issue, if we replace the "id" as AutoField. > > The performance is very slow. > > > > We can live with approach 1 but while running unit tests, it fails > > since it doesnt create the sequence and trigger on its own (note in > > approach 1, auto field is not specified) and by specifying auto field, > > tests work fine but the application is very slow. > > > > We need to fix this and its a bottle neck for us now. Any help on this > > will be highly appreciated. > > Thanks in advance.! > > Rakesh > > > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > > To post to this group, send email to django-us...@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-us...@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. > > -- Rakesh Sinha -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Auto Increment Primary_Key
Thanks. I added the fields and wrote a Db migraton script to populate the primary key and update all foreign key references. Everything works fine except the tests. By just removing "id" from model class application as well as tests work but performance is very slow. I will have a look at south as well. On Sun, Sep 19, 2010 at 1:57 AM, Shawn Milochik wrote: > Did you do any database migrations, or just add the new field? > > Just adding the new field to the model doesn't undo the groundwork laid by > your original syncdb, which has set up the other field as the primary key in > the database itself. Although your Django model is the way you want it, your > database almost certainly is not. > > http://south.aeracode.org/ > > South should help you do what you want. You'll probably need to do it in > multiple steps. I've not had to switch around primary keys in a Django > project yet, so hopefully someone else will weigh in on this. But it'll look > something like the following: > > 1. Add the new auto-number field in a schema migration (leave out "primary > key" bit for now). > 2. Remove "primary key" from the old field and add it to the new field, and > create another schema migration from this. > 3. Delete the old field (if desired) from the model and run another schema > migration. > > All this is assuming that no other models have a foreign key reference to > this model -- that will require a lot more work. > > If all else fails, you could create a whole new model, create a data > migration with South to transfer all the data from the old model, then > delete the old model. Hopefully you can get by without doing that, but if > your production database is in an uncertain state then it may be safer. > > Shawn > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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. > -- Rakesh Sinha -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Need help selecting a distinct set of values from a queryset
Hi folks, some of you may remember I'm working on a site for birders where they can enter and keep track of their observations of various birds. Multiple viewings of a species can be entered at different observation locations, so for the ranking page (which considers only the number of distinct species), I need to find the set of observed species with multiple viewing dropped from the set. I've tried something like this: birds_observed = {} for o in observations: birds_observed[o.bird.id] = 1 number_of observations = len(birds_observed) and then repeat that loop for every observer in the database. Using the excellent debug snippet from djangosnippets.org, I've found this creates about 3,000 sql queries total on the database of the form select bird_id from club300_birds where . for each and every observation in the above set, rinse and repeat for every observer being ranked. My question: Is it possible to have Django select the distinct() bird_ids from a set of observations for a given observer? I've tried using raw SQL queries, but it feels and looks like a hack and a definite break of the DRY principle, and usage of the django distinct() query function sadly eludes me. Thanks in advance for your comments, Uwe -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Automatically update images
I'd like to implement a functionality in an app of mine, but I don't know how to go about it. What I want is this: I have a model class that uses imagekit to save its images, and I'd like to have the users being able to update the images easily for the vehicles without having to edit each respective vehicle record. How they'll do this is that there will be a folder containing sub- folders for each vehicle in the format /PUBLIC, then if a user moves images into the PUBLIC folder for a vehicle, when the script is executed, it'll compare those images with the current ones and update them if those in the PUBLIC folder are newer. If the record has no images, then they will be added. Also, if the vehicle's record has images that have been deleted from the site_media directory, then their links should be deleted from the database. How can I go about this in an efficient way? I have no idea on how to go about this so any help would be appreciated. My models are as below: class Photo(ImageModel): name = models.CharField(max_length = 100) original_image = models.ImageField(upload_to = 'photos') num_views = models.PositiveIntegerField(editable = False, default=0) position = models.ForeignKey(PhotoPosition) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') class IKOptions: spec_module = 'vehicles.specs' cache_dir = 'photos' image_field = 'original_image' save_count_as = 'num_views' class Vehicle(models.Model): objects = VehicleManager() stock_number = models.CharField(max_length=6, blank=False, unique=True) vin = models.CharField(max_length=17, blank=False) images = generic.GenericRelation('Photo', blank=True, null=True) Thank you. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Need help selecting a distinct set of values from a queryset
Sorry to follow up on my own drivel, but I think I've found a solution in the fine django docs: obs = Observation.objects.filter(observer=o.id,location__location_area__area_country__country_abbrev=country_code).values("bird_id").annotate(Count("bird")) seems to do the job nicely for all combinations of areas, countries and so on. The key seems to be the usage of the Count() aggregate function. Thanks for listening, Uwe -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Password Field but clear text in UI
Is it possible to have a Password field, but in the UI let the user type the clear text as it is and not essentially 'hide' it? -V- -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Password Field but clear text in UI
On Sun, Sep 19, 2010 at 8:12 AM, Venkatraman S wrote: > Is it possible to have a Password field, but in the UI let the user type > the clear text as it is and not essentially 'hide' it? Simply do not user the PasswordInput widget for your password field. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: django-registration0.8 args on /activation/complete/
Use registration signals http://stackoverflow.com/questions/1910359/creating-a-extended-user-profile http://docs.b-list.org/django-registration/0.8/signals.html#registration.signals.user_registered On Aug 20, 1:17 pm, Alex wrote: > Hi, > Thanks for great package - just stuck now on how to update app > specific user profile on /activate/complete/ > > Although I have seen the code (re ln 80 in django-registration/ > registration/views.py) I don't understand how to write the correct url > pattern and view params to pick up the activated user in my view so as > I can add some app specific data for each user. > > In the url pattern I have: > > url(r'^accounts/activate/complete/$' ,'myapp.views.profile', > name='registration_activation_complete'), > > and in the view I want this sort of thing so as I can complete the > UserProfile(this fails because the request.user is empty): > > def profile(request): > new_user = request.user > profile = UserProfile(user= new_user) > > and in the model: > > class UserProfile(models.Model): > user = models.OneToOneField(User) > st = models.DateTimeField(auto_now_add=True) > ... > > I think the problem is not understanding what my view receives from > the 'activate' redirect: > > if success_url is None: > to, args, kwargs = > backend.post_activation_redirect(request, account) > return redirect(to, *args, **kwargs) > > I have tried setting a username parameter in the url pattern and view > with no success. How should this be done? I need a - oh that's how it > works - moment. > > Any help very appreciated. > > Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Help :django registration - the account activation gives error messages
HI All, I still have a problem with the last step of django-registration v 0.8. After I enter the activation code, the registration indeed sets user account to active and even sent me activation signal. But the activation_complete.html template checks the presence of the account variable but can't find it So it shows me a an errr message. I scanned a source code and found that registratin calls the post_activation_redirect function to get redirection url and then the default backend empties all params before doing the redirect. Please help Lev On Sep 16, 4:05 pm, failuch wrote: > Hello, all. > I have a problem with django registration v 0.8. > I use register and activate signals and I indeed got these signals > and my functions worked well, except that account activation produces > an error message. > > This error message gets printed if template did not have account > variable. > > I really do not understand this, please advice > > ThX -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Strange query string/doubled value?
Hi, I'm getting the following value-error on a production site (extract from the error message): Traceback (most recent call last): File "/.../django/core/handlers/base.py", line 100, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/.../work/views.py", line 23, in artwork pictures.insert(0, pictures.pop(int(request.GET['picture']) -1)) ValueError: invalid literal for int(): 4?picture=5 ... 'HTTP_HOST': 'dorthegoeden.de', ... 'QUERY_STRING': 'picture=4?picture=5', 'REDIRECT_STATUS': '200', 'REDIRECT_URI': '/django.fcgi/arbeiten/raumbezogene-arbeiten/horch-was-waechst/?picture=4?picture=5', ... 'REQUEST_METHOD': 'GET', 'REQUEST_URI': '/arbeiten/raumbezogene-arbeiten/horch-was-waechst/?picture=4?picture=5', ... Here is the code in question: views.py: def artwork(request, category, artwork): artworks = Artwork.objects.filter(category__slug=category) artwork = get_object_or_404(Artwork, slug=artwork) pictures = list(artwork.picture_set.all()) for picture in pictures: picture.position = pictures.index(picture) + 1 if 'picture' in request.GET: try: pictures.insert(0, pictures.pop(int(request.GET['picture']) -1)) except IndexError: pass context = {'artwork': artwork, 'artworks': artworks, 'pictures': pictures} return render_to_response('work/artwork.html', context, context_instance=RequestContext(request)) artwork.html: {% for picture in pictures %} {% if forloop.first %} {% else %} {% endif %} {% endfor %} I understand that I get a ValueError if the value that I pass int() is something like '4?picture=5'... But how comes that from that code a URL like 'http://dorthegoeden.de/arbeiten/raumbezogene-arbeiten/horch-was-waechst/?picture=4?picture=5' can be constructed by a user clicking around that page in the first place? Or is this perhaps a bot's work? I can think of two possible solutions for that problem: 1: Pass the ValueError like this: if 'picture' in request.GET: try: pictures.insert(0, pictures.pop(int(request.GET['picture']) -1)) except IndexError: pass except ValueError: pass 2: Construct the URL differently like this: By attaching '&' to the 'picture'-value, the strangely constructed URLs would look like this, which I think would work: 'http://dorthegoeden.de/arbeiten/raumbezogene-arbeiten/horch-was-waechst/?picture=4?&picture=5&;' Thanks for any hints on what's best or other advice, Benjamin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Why does extending a class create so much overhead?
I'm still a newbie to django but I think I want to start working on my first real project and I'm kind of confused about extending another application's features without creating overhead. I started to investigate flat pages because I planned to have a few flat pages however I wanted to add a few fields like meta keywords and a meta description. In this post: http://stackoverflow.com/questions/1021487/add-functionality-to-django-flatpages-without-changing-the-original-django-app One of the comment authors said that doing it this way will create some overhead and from a newbie's POV the original method listed seemed like the most intuitive solution. It pretty much follows the same path as most of the tutorials/books. Then I decided to poke around the contrib.FlatPages app and realized the meat of the functionality is just a basic model. That makes me believe that perhaps I should just roll my own FlatPages, maybe even with a parent->child structure for menu items (future projects). But then I thought I can see myself wanting to use meta keywords/ description in every single page, no question about it. Then I asked myself what the real difference is between adding those options directly in the django source and extending it and I couldn't answer it beyond the obvious problems like upgrading django may cause problems, so I'm posting it here. The comment author hinted that it creates a new table for all extended options but I'm curious why the new model fields can't just be added to the original table when you sync db? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
{% url %} template and javascript Get with callback
I'm trying to do a javascript post to an internal api and use a callback to process the JSON result. I'm referencing the api using, {% url %}, which returns a path url relative to my domain ( /api/... instead of http://localhost/api/... for the dev site). The problem is js does not recognize that the relative / path url returned by {% url %} is on the same domain current page, and refuses to execute the callback. I could mess around with JSONP, but I'd rather just put the full url in the template. Is there a convenient way to do this, or am I missing something? I could just add manually add the full url to the request context, but it seems like everyone who uses django with JS callbacks would have this problem, and there should be a simpler way. -Ben (and I'm sure the sites are on the same domain -- if I hardcode the full url, the callback works fine). -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Strange query string/doubled value?
En/na Benjamin Buch ha escrit: 1: Pass the ValueError like this: if 'picture' in request.GET: try: pictures.insert(0, pictures.pop(int(request.GET['picture']) -1)) except IndexError: pass except ValueError: pass As a rule of thumb you must always validate values coming from the user before using them. With the first approach you perform some kind of (implicit) validation, so I think that it is preferable over the second. I case that it fits in your app, a third approach would be to change the URL schema and let django deal with tampered URLs: http://dorthegoeden.de/.../horch-was-waechst/4/ With the appropriate urlpattern/urlconf your view will be called only with valid input (an string of digits). In case of URLs like: http://dorthegoeden.de/.../horch-was-waechst/4/5/ http://dorthegoeden.de/.../horch-was-waechst/notanumber/ django will return a Not Found response. HTH -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: {% url %} template and javascript Get with callback
On 9/19/2010 12:52 PM, Ben Kraft wrote: > I'm trying to do a javascript post to an internal api and use a > callback to process the JSON result. I'm referencing the api using, > > {% url %}, > > which returns a path url relative to my domain ( /api/... instead of > http://localhost/api/... for the dev site). > > The problem is js does not recognize that the relative / path url > returned by {% url %} is on the same domain current page, and refuses > to execute the callback. I could mess around with JSONP, but I'd > rather just put the full url in the template. Is there a convenient > way to do this, or am I missing something? I could just add manually > add the full url to the request context, but it seems like everyone > who uses django with JS callbacks would have this problem, and there > should be a simpler way. > > -Ben > (and I'm sure the sites are on the same domain -- if I hardcode the > full url, the callback works fine). > SERVER_NAME and SERVER_PORT are available in HttpRequest.META if you want to construct full URLs. regards Steve -- DjangoCon US 2010 September 7-9 http://djangocon.us/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
change ordering of objects/rows on change list view on admin
Hi there !, How to change ordering of objects/rows on change list view on admin ? --Rahul -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: change ordering of objects/rows on change list view on admin
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.ordering On Sep 19, 10:56 pm, rahul jain wrote: > Hi there !, > > How to change ordering of objects/rows on change list view on admin ? > > --Rahul -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: change ordering of objects/rows on change list view on admin
I mean graphically/directly on the UI itself. On Sun, Sep 19, 2010 at 2:29 PM, Sævar Öfjörð wrote: > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.ordering > > On Sep 19, 10:56 pm, rahul jain wrote: > > Hi there !, > > > > How to change ordering of objects/rows on change list view on admin ? > > > > --Rahul > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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-us...@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.
Mutli-column composite keys
Someone here wrote: "Mutli-column composite keys are not currently supported by Django. Adding support for multi-column keys (primary or otherwise) is something that has been long discussed, and there is agreement that it is a desirable feature" My problem is that I absolutely must have multi-column keys to create a unique primary key. My primary table consists of a name and part of another column. Other tables are derived from this main table. I have no idea of how to overcome this obstacle. The table consists of the names of companies which are repeated so they're not unique. The entity that would make for a unique key is the name of a company and the product id. Does anyone have a suggestion how I can achieve this unique primary key in Django without resorting to creating another column with the company name plus the product id? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Mutli-column composite keys
On Sep 19, 1:50 pm, "J. P. Smyth" wrote: > Someone here wrote: > > "Mutli-column composite keys are not currently supported by Django. > Adding support for multi-column keys (primary or otherwise) is > something that has been long discussed, and there is agreement that it > is a desirable feature" > > My problem is that I absolutely must have multi-column keys to create > a unique primary key. > > My primary table consists of a name and part of another column. Other > tables are derived from this main table. > > I have no idea of how to overcome this obstacle. The table consists of > the names of companies which are repeated so they're not unique. The > entity that would make for a unique key is the name of a company and > the product id. > > Does anyone have a suggestion how I can achieve this unique primary > key in Django without resorting to creating another column with the > company name plus the product id? You don't really say why the default of an integer autofield (Django's default PK) won't work for you. Given that, by your own admission, you don't know where to start with multi-column keys, your not likely to have a pleasant time hacking into Django's core to do something unsupported in the ORM layer. -Preston -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.