Re: Inserting further fields of a foreignkey object into change list view
Great, it works! Thanks a lot Collin Ciao from Rome Vittorio Il giorno 21/ott/2014, alle ore 18:00, Collin Anderson ha scritto: > Hi Vittorio, > > Would this work? > > class OperationAdmin(admin.ModelAdmin): > list_display = ('patient','date_of_operation') > fields = ('patient', 'patient_address', 'patient_city_zip', > 'date_of_operation') > readonly_field = ['patient_address', 'patient_city_zip'] > inlines= [DetailsInline] > order_by= ['-date_of_operation'] > > def patient_address(self, operation): > return operation.patient.address > > def patient_city_zip(self, operation): > return '%s %s' % (operation.patient.city, operation.patient.zipcode) > > Collin > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/66CAAEC2-9C17-43F8-8915-24AC69FFE43B%40de-martino.it. For more options, visit https://groups.google.com/d/optout.
Inserting further fields of a foreignkey object into change list view
Dear Experts, Under Django 1.7 I have, among other things, the following: ### models.py class Patients(models.Model): surname = models.CharField(max_length=60, db_index=True) name = models.CharField(max_length=60, db_index=True) address = models.CharField(max_length=150) city = models.CharField(max_length=120) zipcode = models.CharField(max_length=15) def __unicode__(self): return u"%s %s" % (self.surname, self.name) class Meta: db_table = u'patients' ordering=['surname', 'name'] class Operation(models.Model): date_of_operation=models.DateTimeField(db_index=True) patient=models.ForeignKey(Patients,default=1) class Meta: db_table = u'operation' verbose_name_plural = "Warehouse IN/OUT" ordering=['-date_of_operation'] class Details(models.Model): type = models.ForeignKey(Operation) item_description = models.CharField(maxlength=100) class Meta: db_table = u'details' ### admin.py class DetailsInline(admin.TabularInline): fields = ('type','item_description') model=Details class DetailsOption(admin.ModelAdmin): list_per_page = 500 list_display = ('type', 'item_description') fields=(('type', 'item_description')) class OperationOption(admin.ModelAdmin): list_display = ('patient','date_of_operation') fields=('patient','date_of_operation') inlines=[DetailsInline] order_by=['-date_of_operation',] Now, focusing on Operation and its inline DetailsInline, when I go to the admin change list view I see on top the date_of_operation field and the surname and name of the patient (as specified in the def unicode) followed by the change list of all Items description (as tabularinline) of that specific operation. Now I would like to have on top of the admin change list view besides the surname and name of the patient also the address, city, zipcode of that patient. As you can see these pieces of info are fields of the table used as ForeignKey (see model Patients). What is the quickest and neat way of getting this result? Ciao Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/096D8757-913D-4A2F-AD28-BA0F0364F3A7%40de-martino.it. For more options, visit https://groups.google.com/d/optout.
Problems connecting to an oracle legacy db
I have an Ubuntu linux server on which I installed the oracle instanclient stuff to run a client of a remote legacy oracle database. It works great! #TNSNAMES.ORA my_db= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 46.128.3.178)(PORT = 1521)) ) (CONNECT_DATA = (SID = DANT) ) ) Trying with SQLPlus victor@ubuntu:~$ sqlplus my_user/my_passw@my_db SQL*Plus: Release 12.1.0.1.0 Production on Wed Jun 4 09:57:04 2014 Copyright (c) 1982, 2013, Oracle. All rights reserved Connected to: Oracle Database 11g Release 11.2.0.3.0 - 64bit Production SQL> ... and with Python >>> import cx_Oracle >>> con = cx_Oracle.connect('my_user', 'my_passw', '46.128.3.178:/DANT') >>> cur = con.cursor() >>> cur.execute('select * from noema.magazzino_vista_lista') > >>> >>> for result in cur: ... print result ... (12, 'MAG0005240', '0005240', 1) (12, 'MAG946', '946', 2) (12, 'MAG0001930', '0001930', 3) (17, 'MAGCARPIE008', 'CARPIE008', 1) (17, 'MAGLETTEL0002', 'LETTEL0002', 1) >>> That's all ok! Now, on the same server, I have a django 1.6.2 project named 'myorac' and an application called 'noematica' #settings.py .. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.oracle', 'NAME': 'my_db', 'USER': 'my_user', 'PASSWORD': 'my_passw', 'HOST': '46.128.3.178', 'PORT': '1521', }, } #models.py ... class magazzino_vista_lista(models.Model): id_ordine = models.IntegerField(null=False, blank=False, db_column='ID_ORDINE') cod_magazzino_galileo = models.CharField(max_length=48, db_column='COD_MAGAZZINO_GALILEO') cod_magazzino_ext = models.CharField(max_length=48, db_column='COD_MAGAZZINO_EXT') qta = models.IntegerField(null=False, blank=False, db_column='QTA') class Meta: managed = False db_table = u'noema.magazzino_vista_lista' verbose_name_plural = "CC specifica ordini vista" * See the real oracle table is named 'noema.magazzino_vista_lista' as in the sql I called before under python * #admin.py . admin.site.register(magazzino_vista_lista) When I start my application via python manage.py runserver I get the following error in the browser at the very beginning DatabaseError at /noematica/ ORA-00942: table or view does not exist Request Method: GET Request URL: http://10.20.0.1:7600/noematica/ Django Version: 1.6.2 Exception Type: DatabaseError Exception Value: ORA-00942: table or view does not exist Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/backends/oracle/base.py in execute, line 815 Why is that? I can't figure out what I made it wrong in the definition of the database in settings.py or in the db_table definition in models.py Please help Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4E45C150-CF81-4927-B304-13D446260EDE%40de-martino.it. For more options, visit https://groups.google.com/d/optout.
Re: django 1.6.1 raw_id_fields open a 'change' popup instead of 'select' popup
Il giorno 05/mar/2014, alle ore 03:54, Camilo Torres ha scritto: > On Tuesday, March 4, 2014 4:47:58 AM UTC-4:30, Vittorio wrote: > In an admin form I input all data for a specific invoice (client, date of > issue, number of invoice) and, by means of inlines, the ordered items. In > these inlines I defined a raw_id_fields referring to the 'items' model which > is showing correctly in the form, BUT ... when I click on it a "change" > page is often (not always) popping up instead of the expected "select" one. > Tis happens both in development and in production. > > Surfing the net I saw a message with the same subject as mine > http://stackoverflow.com/questions/21009319/django-1-6-1-raw-id-fields-open-a-change-popup-instead-of-select-popup > with a somewhat cryptic only answer... > Hello, > > Try to delete your browser cache. > No, it isn't a matter of browser cache. Let's narrow the problem focusing on the linux machine only where there's myapp and the apache2 server. If I run my app via "python manage.py runserver 192.168.100.100:8000" it all works correctly: "GET /warehouse/warehouse/invoice/ HTTP/1.1" 200 2145 "GET /warehouse/jsi18n/ HTTP/1.1" 200 2005 "GET /warehouse/warehouse/invoice/5/ HTTP/1.1" 200 22551 "GET /warehouse/warehouse/items/?t=code&_popup=1 HTTP/1.1" 200 21793 and the correct select popup window's shown. Whilst, *** using the same settings.py file ***, and Apache2 (see the enabled-site conf file below) in production I get a change popup window only and a nasty /?e=1 appears at the and of the http called page. Please help, I'm really stranded here. Thanks a lot Vittorio = #settings.py import os ABSOLUTE_PATH='%s/' % os.path.abspath(os.path.dirname(locals.__name__)).replace('\\','/') DEBUG = True ALLOWED_HOSTS=['*'] ADMINS = ( ('Amministratore', 'wa...@gmail.com'), ) EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'wa...@gmail.com' EMAIL_HOST_PASSWORD = 'AbsolutelyFake99' MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2',#, 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'warehouse', # Or path to database file if using sqlite3. 'USER': 'mycompany', # Not used with sqlite3. 'PASSWORD': 'mycompany', # Not used with sqlite3. 'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. }, 'noematica': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'noematica', # Or path to database file if using sqlite3. 'USER': 'mycompany', # Not used with sqlite3. 'PASSWORD': 'mycompany', # Not used with sqlite3. 'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. }, } TIME_ZONE = 'Europe/Rome' LANGUAGE_CODE = 'it-it' DECIMAL_SEPARATOR=',' THOUSAND_SEPARATOR='.' SITE_ID = 1 USE_I18N = True USE_L10N = True USE_TZ = True MEDIA_ROOT='' MEDIA_URL = '/media/' STATIC_ROOT = '' STATIC_URL = '/static/' STATICFILES_DIRS = ( ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) SECRET_KEY = 'b(%_qs2$sk3_ht&+@9+6=%t1ff$ey@f9$rrydsqw&r$-z)xbk%*' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ) CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } } MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCacheMiddleware',
django 1.6.1 raw_id_fields open a 'change' popup instead of 'select' popup
django==1.6.1 python==2.7.6 Mac OS X 10.7.5 (development) & UBUNTU Linux 13.04 (production -- Apache 2.2.server) Browsers==(Mac OS X) Safari, Firefox,Chrome; (Linux) Firefox To put in a nutshell in my app (I'm translating from Italian into English) 'warehouse' I have a model 'invoice' and a model 'items'. I use the admin interface only. In an admin form I input all data for a specific invoice (client, date of issue, number of invoice) and, by means of inlines, the ordered items. In these inlines I defined a raw_id_fields referring to the 'items' model which is showing correctly in the form, BUT ... when I click on it a "change" page is often (not always) popping up instead of the expected "select" one. Tis happens both in development and in production. Surfing the net I saw a message with the same subject as mine http://stackoverflow.com/questions/21009319/django-1-6-1-raw-id-fields-open-a-change-popup-instead-of-select-popup with a somewhat cryptic only answer... In my case the pop up window instead of being called by : http://localhost:8000/warehouse/warehouse/items/?_popup=1 (which - I tested - works great showing a 'select' page) is called by: http://localhost:8000/warehouse/warehouse/items/?e=1 (which shows a change page) Why is that and what should I do? Thanks a lot Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CFFDC421-4743-4868-950D-43ABD4D35858%40de-martino.it. For more options, visit https://groups.google.com/groups/opt_out.
Freezing records in a model after a set time
I would like to enable a user to insert and modify a record in a django model for a specific stretch of time, say one hour, and,when this time's up (for that specific record), the user shouldn't be allowed to modify or delete the record. Another user (kind of a superuser) with higher permissions should be enabled to modify or delete the record after that time has elapsed Before starting to code a python script to obtain that I would like to know if there is any Github or other "out-of-the-box"django package doing something like that. Thanks a lot Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/71B6B30D-DF62-44D1-9DB6-EAB32D0E4029%40de-martino.it. For more options, visit https://groups.google.com/groups/opt_out.
Unable to save records in a table
Context: Mac OS X 10.7.5, Django 1.5.4 In a multidatabase project (two databases':default' and 'noe') I have the following model in 'default' database class MovimentoOrdineDettaglio(models.Model): id_ordine = models.ForeignKey(MovimentoOrdine,db_column='id_ordine') codarticolo = models.ForeignKey(ArticoliLista, db_index=True,verbose_name='Articolo') numerounita = models.IntegerField(db_column='NumeroUnita',blank=True,default=0, verbose_name=u'Numero Unità ') and the following in 'noe' database class specifica_noe(models.Model): nome_db = 'noe' id_ordine = models.ForeignKey(ordini_magazzino, db_column='ID_ORDINE', to_field='id_ordine') cod_magazzino_ext = models.CharField(max_length=48, db_column='COD_MAGAZZINO_EXT') qta = models.IntegerField(null=False, blank=False, db_column='QTA') def __unicode__(self): return u"%s art. %s" % (self.id_ordine, self.cod_magazzino_ext) I draw your attention on field 'id_ordine' and 'codarticolo' of model MovimentoOrdineDettaglio which are connected via foreign keys to a model MovimentoOrdine and ArticoliLista also in 'default' database. I'm trying to load records using data from model specifica_noe in 'noe' database by means of a loop intoMovimentoOrdineDettaglio in 'default' . In doing so I create the instances art and ord (see below) to take into account the ForeignKey fields. I've introduced two print commands to check if everything is ok. Here it is a snippet of my shell session. --- >>> det = specifica_noe.objects.all() >>> # >>> for d in det: ... art = ArticoliLista.objects.get(codice=d.cod_magazzino_ext) ... ord = MovimentoOrdine.objects.get(id_ordine=d.id_ordine_id) ... if not MovimentoOrdineDettaglio.objects.filter(id_ordine=d.id_ordine_id, codarticolo=d.cod_magazzino_ext): ... print("Order %s for article %s does not exist-load now") % (d.id_ordine_id,d.cod_magazzino_ext) ... rec = MovimentoOrdineDettaglio(id_ordine=ord, codarticolo=art,numerounita=d.qta) ... print('%s %s %s') % (rec.id_ordine,rec.codarticolo,rec.numerounita) ... rec.save() ... # ... Order 1 for article 0005201 does not exist-load now Ord.1 per BONAPARTE NAPOLEONE ABBA*12BUST 875MG+125MG 10 Order 1 for article MAS105 does not exist-load now Ord.1 per BONAPARTE NAPOLEONE ACTISORB 10,5X10,5CM 5 Order 3 for article 004 does not exist-load now Ord.3 per MANZONI ALESSANDRO ADALAT CRONO 30MG 14 CPR RIV. 7 Order 3 for article 006140 does not exist-load now Ord.3 per MANZONI ALESSANDRO ACQUA OSSIGENATA 10VOL 1000ML 1 Order 2 for article 0005201 does not exist-load now Ord.2 per CESARE GIULIO ABBA*12BUST 875MG+125MG 8 Order 6 for article 006140 does not exist-load now Ord.6 per MANZONI ALESSANDRO ACQUA OSSIGENATA 10VOL 1000ML 2 Order 5 for article MAS105 does not exist-load now Ord.5 per LINCOLN ABRAMO ACTISORB 10,5X10,5CM 15 Order 5 for article MAS190 does not exist-load now Ord.5 per LINCOLN ABRAMO ACTISORB 10,5X19 12 Order 4 for article 8016629001115 does not exist-load now Ord.4 per EINAUDI LUIGI ABBASSALINGUA IN LEGNO DOC N/ST CF.100 25 >>> --- Everything seems ok for instance, just to doublecheck, for the last rec of the loop I have >>> rec.id_ordine >>> rec.codarticolo >>> rec.numerounita 25 >>> BUT if I issue: >>> f=MovimentoOrdineDettaglio.objects.all() >>> f [] No records at all in the table! Nothing anomalous is signalled by python/django. Help please. Ciao from Rome Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/609C9977-68D5-4909-AFBD-5D0C4D5DB8B9%40de-martino.it. For more options, visit https://groups.google.com/groups/opt_out.
Re: Unable to load a modified tabular.html
It helped indeed. Thank you very much! Vittorio Il giorno 24/ott/2013, alle ore 19:00, Pantelis Petridis ha scritto: > You don't have to create any custom view. Just set the template in your > inline model > > class MyInline(admin.TabularInline): > template = 'path/to/the/template.html' > > Hope this helps! > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/30E2F659-ED44-4E85-8881-D60A62783CB2%40de-martino.it. For more options, visit https://groups.google.com/groups/opt_out.
Unable to load a modified tabular.html
Context: Mac OS X 10.7, Django 1.5.4 using Admin I was able to taylor the admin/edit_inline/tabular.html to eliminate some redundant info (such as the obsessive label indicating from which Object is extracted the inline record, repeated record by record!) in my many inlines putting the revised tabular.html under $MYPROJECT/templates/admin/edit_inline/. It works like a charm! Now, for a specific model only I need to modify tabular.html eliminating the 'delete?' label and the relating little boxes in each record of the inline model. Therefore I created a mytabular.html file and put it under myproject/templates/admin/ then in # views.py def mytabular(request): return render_to_response('mytabular.html') # urls.py urlpatterns = patterns('', . url(r'^magazzino/', include(admin.site.urls)), url(r'^movimentoordine/(\d+)/$', 'magazzino.views.mytabular', name='mytabular'), ) [The called url is e.g. 'http://localhost:8000/magazzino/magazzino/movimentoordine/2/'] Unfortunately django doesn't seem to take my desire into account and invariably calls admin/edit_inline/tabular.html instead of mytabular.html as debug_toolbar says. I tried also to put mytabular.html under $MYPROJECT/templates/admin/edit_inline/ to no avail. Please help. Ciao Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6B9BD4FB-8B4A-4C7A-9D5E-2B8345938865%40de-martino.it. For more options, visit https://groups.google.com/groups/opt_out.
admin.py: putting "if condition" in ModelAdmin according to username
For the sake of simplicity let's suppose I have models.py class Book(models.Model): title = models.CharField(max_length=100) authors = models.ManyToManyField(Author) publisher = models.ForeignKey(Publisher) Under admin I would like that some username (say "vic" and "lucky") can edit every field of the change form while other users ("tom","sue") can only visualize the same data without modification. I think to put some "if condition" in admin.py of this kind class BookOption(admin.ModelAdmin): if username in ["tom", "sue"]: readonly_fields = ['title','authors','publisher'] fields=(('title'),('authors', 'publisher')).. . admin.site.register(Book,BookOption) How can I do it? Ciao Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F0A087D2-8E11-4B0B-8D95-6FC131854994%40de-martino.it. For more options, visit https://groups.google.com/groups/opt_out.
Template unable to show media files in production
*Context: Ubuntu linux server 12, Apache 2.2 server, django 1.5.3* * * My project, /home/victor/magazantea is dealt with by admin and it works fine in the development environment (/manage.py runserver 192.168.1.19:8000). I built a view which gets data from the following fields from model "Articoli" *models.py* class Articoli(models.Model): . codice = models.CharField(primary_key=True,db_index=True,max_length=15,db_column='Codice') descrizione = models.CharField(max_length=255, db_column='Descrizione', db_index=True) categoria = models.IntegerField(choices=categoria, db_column='Categoria',default=2) @property def codice_a_barre(self): self.codice = self.codice.strip() cod= self.codice.replace(" ", "_").replace("/","_") return (str(cod)+ '.png') and produces a template *"listarticoli.html" *where* *codice, descrizione,categoria are listed together with the image of the png file referred to by the string codice_a_barre, got from the media dir "/home/victor/magazantea/magazantea/media". It works like a charm in development but when I put it *in production the png files aren't shown* (instead a small blue square whit a question mark inside is shown in each line). These are the relevant files in production: *settings.py * import os ABSOLUTE_PATH='%s/' % os.path.abspath(os.path.dirname(locals.__name__)).replace('\\','/') DEBUG = False ALLOWED_HOSTS=['*'] ... MEDIA_ROOT='/home/victor/magazantea/magazantea/media/' MEDIA_URL = '/media/' STATIC_ROOT = '' STATIC_URL = '/static/' . ROOT_URLCONF = 'magazantea.urls' ... .. *urls.py* from django.conf.urls import patterns, include, url # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^magazzino/', include(admin.site.urls)), url(r'^listarticoli/', 'magazzino.views.listbarcode', name='listbarcode'), url(r'^listarticoli/(?P.*)$', 'django.views.static.serve',{'document_root': '/home/victor/magazantea/magazantea/media/'}), ) And finally the *Apache config* Listen 8000 WSGIScriptAlias / /home/victor/magazantea/django.wsgi WSGIPythonPath /home/victor/magazantea AliasMatch ^/([^/]*\.css) /home/victor/magazantea/magazantea/static/ AliasMatch ^/([^/]*\.png) /home/victor/magazantea/magazantea/media/ Alias /media/ /home/victor/magazantea/magazantea/media/ Alias /static/ /home/victor/magazantea/magazantea/static/ Alias /templates/ /home/victor/magazantea/magazantea/templates/ Order deny,allow Allow from all Order deny,allow Allow from all Order deny,allow Allow from all ServerAdmin webmaster@localhost Order deny,allow Allow from all -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: Geodjango on Windows issue
Hi Danny, I'm having the same issue, I tried with virtual environments and didn't work, did you find something to fix it? appreciate it. On Tuesday, August 7, 2012 11:23:55 AM UTC-6, Danny Im wrote: > > Hello all, > > I'm hoping to get some assistance on this. > > Issue: > A user can upload a shapefile to the django application once upon a fresh > apache restart. Any subsequent shapefile upload by any other user results > in the server not giving any response back to the client. Other uploads go > through fine. Shapefile uploads make use of GDAL (in particular, the code > will hang on a call to OGRGeometry.transform), other uploads do not. > > What I think is happening: > A python thread will hang whenever a user uploads a shapefile (and thus > calling a GDAL library function), given that another thread has previously > used a GDAL function. > > What I've done so far: > From the geodjango documentation ( > https://docs.djangoproject.com/en/1.4/ref/contrib/gis/deployment/), no > threading should be used for webserver deployment as GDAL is not thread > safe. However, since I'm using apache on windows, it appears that the mpm > used creates multiple threads for each request > http://httpd.apache.org/docs/2.2/mod/mpm_winnt.html > > My question: Is there any way to use apache on windows for geodjango > applications? I'm assuming my problem will be solved if I can have each > request be handled by a separate process - are there any other webservers > that I should look into? I'd prefer solutions that would work on Windows. > > Relevant software used: > Windows Server 2008 R2 > Apache HTTP Server version 2.2.22 > GDAL/OGR 1.9.1 > Django 1.4 > MapServer CGI 6.0.3 > > Thanks! > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Modifying a field in another model
My (newbye) problem is as follows: Suppose class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) address = models.CharField(max_length=100) class Lent_Book(models.Model): title = models.CharField(max_length=100) to_whom = models.ForeignKey(Person) last_known_address= >>>>HERE I WOULD LIKE TO SHOW AND, IF NECESSARY, MODIFY Person.address In a nutshell, my problem is: when I run admin and open Lent_book I would like to have a changeable field 'last-know_address' that modifies Person.address in one shot (without having to open Person). Is that possible and how? An example would be highly appreciated. Ciao from Rome Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Modifying a field in another model
My (newbye) problem is as follows: Suppose class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) address = models.CharField(max_length=100) class Lent_Book(models.Model): title = models.CharField(max_length=100) to_whom = models.ForeignKey(Person) last_known_address= >>>>HERE I WOULD LIKE TO SHOW AND, IF NECESSARY, MODIFY Person.address In a nutshell, my problem is: when I run admin and open Lent_book I would like to have a changeable field 'last-know_address' that modifies Person.address in one shot (without having to open Person). Is that possible and how? An example would be highly appreciated. Ciao from Rome Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Problem with intermediary table from legacy database
Thanks a lot Russ Magee, now it works. Ciao Vittorio Il giorno 04/apr/2013, alle ore 14:24, Russell Keith-Magee ha scritto: > > > On Thu, Apr 4, 2013 at 6:48 PM, Tom Evans wrote: > On Thu, Apr 4, 2013 at 11:35 AM, Russell Keith-Magee > wrote: > > > > > > On Thu, Apr 4, 2013 at 5:28 PM, Vittorio wrote: > >> > >> Under Django 1.5.1 I'm having a go at using ManyToManyField (see below > >> models.py and admin.py files) referring to an Sqlite3 legacy db. > >> > >> I'm receiving the following fatal error message in admin > >> > >> Exception Value: > >> > >> 'LibroOption.fields' can't include the ManyToManyField field > >> > >> 'autore' because 'autore' manually specifies a 'through' model > > > > > > The error is telling you exactly what the problem is. You can't put autore > > in the list of admin-displayed fields (or, for that matter, the list of > > filter_horizontal) because it uses a through model. > > > > There's a very simple reason for this - a through model exists to allow you > > to specify additional data on a relation. The basic m2m widget (in any of > > it's forms, including raw_id_field and filter_horizontal/vertical) only > > allow you to define the "other" object that you want a relation with. You > > can't set up a 'through' relation without specifying the extra data as > > well, so you're prohibited from using the basic m2m widgets on m2m > > relations with a through model. > > > > If you want to have an admin representation for an m2m relation with a > > through model, you need to add an inline to represent the through model. > > See [1] for more details. > > > > That said, if I'm reading your models correctly, it looks like the > > "through" model isn't actually required, it's just been introspected that > > way -- it's easier for the introspector to create a model for *every* > > table, rather than try to work out which tables are actually m2m tables. > > > > It should be possible to remove the explicit definition of the LibriAutori > > model, and replace the autori m2m relation with: > > > >autori = models.ForeignKey(Autore,db_column='autori', > > db_table='LibriAutori') > > > > This should be a ManyToMany field with the same options, no? > > /facepalm > > You are completely correct. I lose my keyboard privileges for the evening :-) > > Yours > Russ Magee %-) > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Problem with intermediary table from legacy database
Under Django 1.5.1 I'm having a go at using ManyToManyField (see below models.py and admin.py files) referring to an Sqlite3 legacy db. I'm receiving the following fatal error message in admin Exception Value: 'LibroOption.fields' can't include the ManyToManyField field 'autore' because 'autore' manually specifies a 'through' model (I've also tried to let Django to automagically define the intermediary table eliminating from models.py the through option, and it works like a charm: that is, when as admin I open the Libri model I see the autore field horizontally filtered.) How can I solve this problem having to necessarily use this legacy db and its tables which are fed by a Filemaker procedure too? Thanks from Rome Vittorio models.py from django.db import models # Create your models here. class Autore(models.Model): nome = models.CharField(db_index=True,max_length=50) cognome = models.CharField(db_index=True,max_length=50) def __unicode__(self): return u"%s %s" % (self.nome, self.cognome) class Meta: verbose_name_plural = "Autori" db_table="Autori" ordering=['cognome', 'nome'] ... ... class Libro(models.Model): titolo = models.CharField(db_index=True,max_length=200) autore = models.ManyToManyField(Autore,through='LibriAutori') def __unicode__(self): return self.titolo class Meta: verbose_name_plural = "Libri" db_table="Libri" ordering=['titolo'] class LibriAutori(models.Model): libro = models.ForeignKey(Libro,db_column='libro') autori = models.ForeignKey(Autore,db_column='autori') class Meta: verbose_name_plural = "LibriAutori" db_table='LibriAutori' = admin.py from django.contrib import admin from biblio.models import * from django import forms # class LibroOption(admin.ModelAdmin): list_display = ('titolo','autore') fields=(('titolo'),'autore') filter_horizontal = ['autore', ] order_by= ['titolo', ] admin.site.register(Autore) admin.site.register(Libro, LibroOption) admin.site.register(LibriAutori) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
manytomany field and intermediary table from a legacy database
I know that when I define a manytomany field automagically "behind the scene Django creates an intermediary join table to represent the many-to-many relationship". Now I have a legacy MySQL db, feeded by an existing procedure built in Filemaker via ODBC, which I would like to use with django too. In this legacy db the "intermediary join table" already exists but with a different name and with different name fields. How can I tell Django to use that table without creating a new one? An example would be very useful. Bye from Rome Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Defining a different name for the key field in ForeignKey
I'm working on a legacy mysql db (under Mac OS X with Django 1.4.3) whose structure I cannot modify because other applications are already happily referring to it (FileMaker pro, PHP,etc.). After issuing the 'python manage.py inspectdb' I created the first tentative models.py that I'm now refining specifically to take into account foreign keys. Now, manage.py both syncdb and runserver don't signal anything abnormal but when I browse the table articoli as admin the following two tables and classes are arising a problem because (1054, "Unknown column 'articoli.categoria_id_id' in 'field list'") ... class Categorie(models.Model): idCategoria = models.IntegerField(primary_key=True) descrizione = models.CharField(max_length=150, db_column='Descrizione') # Field name made lowercase. def __unicode__(self): return self.descrizione class Meta: db_table = u'Categorie' verbose_name_plural='categorie' ordering=['descrizione'] class Articoli(models.Model): id = models.IntegerField(primary_key=True) categoria_id = models.ForeignKey(Categorie) codice = models.CharField(max_length=90, unique=True, db_column='Codice') ... ... How can I specify in categoria_id of class Articoli that the key field to refer to is idCategoria of Categorie? Ciao Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Cannot find ../django/contrib/admin/media
As a newbye I'm using django 1.4.3 under Mac OS X. Reading the tutorials (and an Italian book on django by Marco Beri), I was able to set up my app 'home' using a legacy mysql db, and play with it as admin by means of the server 'python manage.py runserver'. Nice layout indeed! I modified my apache2 httpd.conf in order to run the same app adding: VirtualHost *:8000> ServerAdmin webmaster@localhost SetHandler python-program PythonHandler django.core.handlers.modpython PythonPath "['/home/vittorio','/home/vittorio/miosito/home'] + sys.pat$ SetEnv DJANGO_SETTINGS_MODULE home.settings PythonDebug On OR (an alternative httpd.conf) WSGIScriptAlias / /home/vittorio/miosito/home/django.wsgi WSGIPythonPath /home/vittorio/miosito/home Order deny,allow Allow from all Both work but their layout is simply awful, not at all elegant like that obtained by means of runserver. My point is that I would like to fix this and have the same elegant layout of the standard python manage.py runserver leafing thru this list I understand that I should have added an alias reference to the directory of the django media that im my case, according to the many mails (very old indeed, usually referring to django 1.0), should be /Library/Python/2.7/site-packages/django/contrib/admin/media which simply does not exist (also under FreeBSD which I use too) What wrong with it and how can I solve this problem Ciao Vittorio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.