Re: how to implement a data grid? (or populate inlineformset with initial data)
Hi, Long back i had used Dojo data grid, plz go through my blog http://jayapal-d.blogspot.com/2009/08/dojo-datagrid-with-editable-cells-in.html I am sure that we can do with jquery. Lemme know if u required any help. Thanks, Jayapal On May 31, 6:39 am, snfctech wrote: > I want to display a list of records that have some editable fields and > some readonly fields, as well as asynchronously add new records to the > list. I thought the way to start would be with an InlineFormSet - but > I can't figure out how to populate my formset with initial data. E.g. > MyInlineFormset(queryset=myquery.all()) or > MyInlineFormset(data=myquery.vales()) doesn't do the trick. > > Can someone steer me in the right direction? > > Thanks. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: admin site search field
First, you did enclose doc properly. You wrote 'doc instead of 'doc'. Sort that first. I'm however not suggesting that is the solution. Regards. Sent from my BlackBerry wireless device from MTN -Original Message- From: podio Sender: django-users@googlegroups.com Date: Mon, 30 May 2011 16:24:10 To: Django users Reply-To: django-users@googlegroups.com Subject: admin site search field Hi, I'm new and I'm trying to make an app that have a field, pointing to a record of the same object class. How can a make django has a search form and show the record of the class on a popup window like http://demoweb.cibernatural.com/admin/gestion/presupuesto/add/ (user and password demo:demo) but pointing to the same class class afiliado(models.Model): def __unicode__(self): return self.nombre nombre = models.CharField("Nombre",max_length=200) fecha_nac = models.DateField("Fecha Nacimiento") doc = models.CharField("Documento",max_length=20,blank =True) obra_social = models.ForeignKey(obra_sociale) caracter = models.ForeignKey(caractere) tipo = models.ForeignKey(tipo) titular = models.CharField(max_length=200) > this field class AfiliadoAdmin(admin.ModelAdmin): fieldsets = [ (None ,{'fields': ['nombre','fecha_nac','DOCN','Nacionalidad']}), ('Datos Generales' ,{'fields': ['obra_social','caracter','tipo',"titular",'Matricula','fecha_ing']}), ('Datos de contacto',{'fields': ['Direccion',"CP","Ciudad","Provincia","Tel1","Tel2","Email"]}), ] list_display = ('nombre',"tipo") list_filter = ['Ciudad'] search_fields = ['nombre','doc] Thansk! -- 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 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-users@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: python code works in command line but not in django
On May 30, 3:54 pm, Kann wrote: > Dear all, > > I tried using python to execute some external java program in my code. > My problem is the os.system(cmd) was not working properly "not working properly" is possibly not the most informative description of your problem... What happens ? Get a traceback ? If so, please post it (here or anywhere we can read it). Else please explain what happens exactly. > when the > code was included into some view in views.py. However, executing the > code from terminal worked just fine. I am not sure what is wrong here. Very probably a permissions or env problem. > this is from my medusa package > > 1 import os > 2 > 3 def create_image(): > 4 path = os.path.abspath('tmp/medusa') > 5 medusa = os.path.abspath('mirnaworkbench/Medusa/Medusa.jar') > 6 cmd = str('java -cp ' + medusa + ' > medusa.batchoperations.BatchOperations ' + path) OT: string concatenation yield a string object, so you don't need to try and make a string from it. Also, Python as good support for string formatting, which is usually more readable than string concatenation. > 7 os.system(cmd) > And ? What happens ? -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: python code works in command line but not in django
I don't think there's any way this could work. From what I can tell Kann is trying to invoke the java interpreter ... but he does it on the server, not on the user's machine - that's why it only works when the two are the same. So he should try to invoke it somehow else, maybe embed it in a html page if it's a Applet or just link to the .jar file directly and normally the Java machine will automatically pick it up (if installed on the user's machine). Lucian On Tue, May 31, 2011 at 10:20 AM, bruno desthuilliers wrote: > > > On May 30, 3:54 pm, Kann wrote: >> Dear all, >> >> I tried using python to execute some external java program in my code. >> My problem is the os.system(cmd) was not working properly > > "not working properly" is possibly not the most informative > description of your problem... What happens ? Get a traceback ? If so, > please post it (here or anywhere we can read it). Else please explain > what happens exactly. > >> when the >> code was included into some view in views.py. However, executing the >> code from terminal worked just fine. I am not sure what is wrong here. > > Very probably a permissions or env problem. > >> this is from my medusa package >> >> 1 import os >> 2 >> 3 def create_image(): >> 4 path = os.path.abspath('tmp/medusa') >> 5 medusa = os.path.abspath('mirnaworkbench/Medusa/Medusa.jar') >> 6 cmd = str('java -cp ' + medusa + ' >> medusa.batchoperations.BatchOperations ' + path) > > OT: string concatenation yield a string object, so you don't need to > try and make a string from it. Also, Python as good support for string > formatting, which is usually more readable than string concatenation. > >> 7 os.system(cmd) >> > > And ? What happens ? > > -- > 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 > 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-users@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: Can I perform an "alter table" to remove a "not null" constraint?
On Mon, May 30, 2011 at 09:52:27PM -0700, Gchorn wrote: > It seems as though the default in Django when creating tables is to > place a constraint that doesn't allow null values (contrary to what > I've learned is the default for SQL in general). I have a model which > has a date attribute, and which I now want to be able to hold null > values, but when I tried doing this by adding 'null = True' and 'blank > = True' to the model's field options, Django generates a Use South (http://south.aeracode.org/). Or you can run ./manage.py dbshell, and ALTER TABLE yourself, for example, for PostgreSQL:: ALTER TABLE ALTER COLUMN DROP NOT NULL; -- Kirill Spitsin -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: python code works in command line but not in django
On May 31, 10:32 am, Lucian Nicolescu wrote: > I don't think there's any way this could work. Oh yes ? Why so ? > From what I can tell > Kann is trying to invoke the java interpreter ... Indeed. > but he does it on > the server, not on the user's machine And ? > - that's why it only works when the two are the same. Please think twice before posting. The OP never talked about "code working on it's own machine and not on the production server", but about "code working from within the python shell and not from the views". Not quite the same problem. FWIW, nothing prevents a java interpreter from being launched on the same machine as the django app (it's even a rather common use case), and as long as everything is correctly deployed and the env, path and perms are ok there's no reason it shouldn't work as well on a dev workstation, staging server or production server. > So he should try to invoke it somehow else, maybe embed it in a html > page if it's a Applet or just link to the .jar file directly and > normally the Java machine will automatically pick it up (if installed > on the user's machine). What makes you think the java program is supposed to run on the user machine exactly ? -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Model 'Child' is inherited from 'Parent', trying to filter to get only Child results with Parent.objects.filter(...)
Example code: class Parent(models.Model): name = models.CharField(max_length='20',blank=True) class Child(Parent): pass I want to get the result of Child.objects.all() but I DO NOT want to use Child. I want to use Parent instead, which I tried to do with: Parent.objects.filter(child__isnull=False) Which doesn't work and gives the result of Product.objects.all() instead. However If I do the following, it WORKS: Parent.objects.filter(child__name__isnull=False) Another way, if I insist on using Parent.objects.filter(child__isnull=False), is to change the Child model to the following: class Child(models.Model): parent = models.OneToOneField(Parent) Then Parent.objects.filter(child__isnull=False) would WORK The problem with the 2 solutions above is that filtering with child__name__isnull looks hackish, and I don't want to change my Child model to use OneToOneField. So is there a better way? Thanks, Robin -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: python code works in command line but not in django
Hey Bruno, Sorry if I misunderstood the initial posting, please enlighten me/us with a solution for the problem. Lucian On Tue, May 31, 2011 at 11:48 AM, bruno desthuilliers wrote: > > On May 31, 10:32 am, Lucian Nicolescu wrote: >> I don't think there's any way this could work. > > Oh yes ? Why so ? > >> From what I can tell >> Kann is trying to invoke the java interpreter ... > > Indeed. > >> but he does it on >> the server, not on the user's machine > > And ? > >> - that's why it only works when the two are the same. > > Please think twice before posting. > > The OP never talked about "code working on it's own machine and not on > the production server", but about "code working from within the python > shell and not from the views". Not quite the same problem. > > FWIW, nothing prevents a java interpreter from being launched on the > same machine as the django app (it's even a rather common use case), > and as long as everything is correctly deployed and the env, path and > perms are ok there's no reason it shouldn't work as well on a dev > workstation, staging server or production server. > > >> So he should try to invoke it somehow else, maybe embed it in a html >> page if it's a Applet or just link to the .jar file directly and >> normally the Java machine will automatically pick it up (if installed >> on the user's machine). > > What makes you think the java program is supposed to run on the user > machine exactly ? > > -- > 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 > 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-users@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: python code works in command line but not in django
Hi All, I apologize for now being specific enough. The java script should read files in "tmp/medusa" and use "Medusa.jar" as the referenced class to run. The result of the script should be a png image using data from files inside "tmp/medusa" I tested the java command via terminal and it worked fine. The PNG image was created correctly. I tested the python package using python shell by importing MedusaConnector and run the "MedusaConnector.create_image()", and the PNG image was created properly as well. Therefore, I imported the Medusa package into my views.py and try to run it using django. This time, the PNG file was created, but with and empty image unlike those 2 previous test cases. Really have no idea what's going on here... Kann On May 31, 10:48 am, bruno desthuilliers wrote: > On May 31, 10:32 am, Lucian Nicolescu wrote: > > > I don't think there's any way this could work. > > Oh yes ? Why so ? > > > From what I can tell > > Kann is trying to invoke the java interpreter ... > > Indeed. > > > but he does it on > > the server, not on the user's machine > > And ? > > > - that's why it only works when the two are the same. > > Please think twice before posting. > > The OP never talked about "code working on it's own machine and not on > the production server", but about "code working from within the python > shell and not from the views". Not quite the same problem. > > FWIW, nothing prevents a java interpreter from being launched on the > same machine as the django app (it's even a rather common use case), > and as long as everything is correctly deployed and the env, path and > perms are ok there's no reason it shouldn't work as well on a dev > workstation, staging server or production server. > > > So he should try to invoke it somehow else, maybe embed it in a html > > page if it's a Applet or just link to the .jar file directly and > > normally the Java machine will automatically pick it up (if installed > > on the user's machine). > > What makes you think the java program is supposed to run on the user > machine exactly ? -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Serving static file on Windows
Hi, I use Django 1.3. sample/ static/ js/jquery.1.6.1.min.js css/ settings.py APP_DIR = os.path.abspath(os.path.dirname(__file__)) STATIC_ROOT = os.path.join(APP_DIR, 'static/') STATIC_URL = 'http://192.168.1.141:44/static/' TEMPLATE_DIRS = ( os.path.join(APP_DIR, 'templates/') ) urls.py from django.conf.urls.defaults import patterns, include, url urlpatterns = patterns('', (r'^$', 'hydra.views.index'), ) The above settings works. Thanks Madhu On May 31, 9:44 am, Praveen Krishna R wrote: > *Pasting one of my earlier replies to the same question* > *** > * > *Please check django official docs to find out how static files are served > on production and development server. > > in the dev server include a similiar snippet into your projects > urls.py, urlpatterns: > > (r'^site_media/(?P.*)$', 'django.views.static.serve',{'document_root': > 'D:/djangoprojects/praveensprofile/templates/static'}), > > and in the templates something similar to the below text. > > > * > > > > > > > > > > On Mon, May 30, 2011 at 1:57 PM, Alagu Madhu wrote: > > urls.py > > > from django.conf.urls.defaults import patterns, include, url > > > urlpatterns = patterns('', > > (r'^$', 'hydra.views.index'), > > ) > > > On May 30, 12:28 pm, Praveen Krishna R > > wrote: > > > *could you dump your urls.py ? > > > * > > > > On Mon, May 30, 2011 at 12:19 PM, Alagu Madhu wrote: > > > > Hi, > > > > > sample/ > > > > static/ > > > > js/jquery.1.6.1.min.js > > > > css/ > > > > > settings.py > > > > > APP_DIR = os.path.abspath(os.path.dirname(__file__)) > > > > STATIC_ROOT = os.path.join(APP_DIR, 'static/') > > > > STATIC_URL = '/static/' > > > > INSTALLED_APPS = ( > > > > 'django.contrib.auth', > > > > 'django.contrib.contenttypes', > > > > 'django.contrib.sessions', > > > > 'django.contrib.sites', > > > > 'django.contrib.messages', > > > > 'django.contrib.staticfiles', > > > > ) > > > > > urls.py > > > > > urlpatterns = patterns('', > > > > (r'^$', 'hydra.views.index'), > > > > ) > > > > >http://192.168.1.141:44/static/js/jquery.1.6.1.min.js > > > > > Page not found (404) > > > > 'js\jquery.1.6.1.min.js' could not be found > > > > > Thanks > > > > > Madhu > > > > > On May 24, 9:44 pm, shofty wrote: > > > > > ignore that last comment, im clearly behind a version! > > > > > > not sure why you're needing to static.serve the static files, if > > > > > you're on django 1.3 it does that bit for you. > > > > > > On May 24, 9:22 am, AlaguMadhu wrote: > > > > > > > Hi, > > > > > > > sample/ > > > > > > media/ > > > > > > js/jquery.1.6.1.min.js > > > > > > css/ > > > > > > static/ > > > > > > js/jquery.1.6.1.min.js > > > > > > css/ > > > > > > > settings.py > > > > > > > import os > > > > > > PROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) > > > > > > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/') > > > > > > MEDIA_URL = '/media/' > > > > > > STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/') > > > > > > STATIC_URL = '/static/' > > > > > > > urls.py > > > > > > > urlpatterns = patterns('', > > > > > > (r'^media/(?P.*)$', 'django.views.static.serve', > > > > > > {'document_root': settings.MEDIA_ROOT}), > > > > > > (r'^static/(?P.*)$', 'django.views.static.serve', > > > > > > {'document_root': settings.STATIC_ROOT}), > > > > > > >http://192.168.1.141:44/static/js/jquery.1.6.1.min.js > > > > > > > Page not found (404) > > > > > > 'js\jquery.1.6.1.min.js' could not be found > > > > > > > Thanks > > > > > > >Madhu > > > > > -- > > > > 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 > > > > django-users+unsubscr...@googlegroups.com. > > > > For more options, visit this group at > > > >http://groups.google.com/group/django-users?hl=en. > > > > -- > > > Thanks and Regards, > > > *Praveen Krishna R* > > > -- > > 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 > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > Thanks and Regards, > *Praveen Krishna R* -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Problem with layout
Hi friends, recently I upgraded my django installed version to 1.3. To test it, i got a free html/css template from a page, and started a little web. The surprise came when I open development webserver, with all static files configured properly, and the resulting website (without any modification, only serving the same web template from django instead of filesystem) is wider, and some parts are malformed. I used the same html template (without modifications), and the same images and CSS (CSS only modified to get properly routes). Then, i set the same index.html and served from django server as static file (without using django routes, only servinc static html file). This file is malformed too, at the same way as serving as django page. The last test was to open that html file, from the same browsers, but this time from filesystem, instead of from django. File display correctly all layout. Any idea about what is happening? Thanks in advance -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there an HTML editor that's Django-aware
On 31 May 2011, at 00:20, AJ wrote: > If I can give my $0.02, the content can live anywhere, but how about at least > a link to the content within the initial "setting up django environment' > section? > > This way those who are just beginning programming and Django can know what do > they need to do and what are the pros and cons of an editor/ide upfront. Agreed. An editor section at the start would be useful. I'm guessing that quite a few people who are new to Django are also new to Python as well (in the same way as many new Rails users are new to Ruby) so any help in getting them started with Python as a whole as well as in a Django specific way will be helpful. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: python code works in command line but not in django
On May 31, 11:29 am, Kann wrote: > Hi All, > > I apologize for now being specific enough. The java script s/script/application/ Please let's not confuse Java with javascript ;) > should read > files in "tmp/medusa" and use "Medusa.jar" as the referenced class to > run. The result of the script should be a png image using data from > files inside "tmp/medusa" > > I tested the java command via terminal and it worked fine. The PNG > image was created correctly. > > I tested the python package using python shell bare python shell, or ./manage.py shell ? > by importing > MedusaConnector and run the "MedusaConnector.create_image()", and the > PNG image was created properly as well. > > Therefore, I imported the Medusa package into my views.py and try to > run it using django. This time, the PNG file was created, but with and > empty image unlike those 2 previous test cases. > > Really have no idea what's going on here... Check you path. FWIW: Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.getcwd() '/home/bruno' >>> os.path.abspath('tmp') '/home/bruno/tmp' >>> os.chdir('/home') >>> os.path.abspath('tmp') '/home/tmp' >>> Also are you running Django with the embedded development server (./ manage.py runserver) or behind Apache or another front web server ? In the second case, you may have issues with ENV, perms etc. 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-users@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: python code works in command line but not in django
Hi Bruno, I tested with both system's python shell and the "manage.py shell", and both of them also worked. The PNG file was created properly. I also check the path returned from os.path.abspath() and both of them are ok as well. Now I am testing using the Django embedded development server. Kann On May 31, 12:19 pm, bruno desthuilliers wrote: > On May 31, 11:29 am, Kann wrote: > > > Hi All, > > > I apologize for now being specific enough. The java script > > s/script/application/ > > Please let's not confuse Java with javascript ;) > > > should read > > files in "tmp/medusa" and use "Medusa.jar" as the referenced class to > > run. The result of the script should be a png image using data from > > files inside "tmp/medusa" > > > I tested the java command via terminal and it worked fine. The PNG > > image was created correctly. > > > I tested the python package using python shell > > bare python shell, or ./manage.py shell ? > > > by importing > > MedusaConnector and run the "MedusaConnector.create_image()", and the > > PNG image was created properly as well. > > > Therefore, I imported the Medusa package into my views.py and try to > > run it using django. This time, the PNG file was created, but with and > > empty image unlike those 2 previous test cases. > > > Really have no idea what's going on here... > > Check you path. FWIW: > > Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > > >>> import os > >>> os.getcwd() > '/home/bruno' > >>> os.path.abspath('tmp') > '/home/bruno/tmp' > >>> os.chdir('/home') > >>> os.path.abspath('tmp') > '/home/tmp' > > Also are you running Django with the embedded development server (./ > manage.py runserver) or behind Apache or another front web server ? In > the second case, you may have issues with ENV, perms etc. > > 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-users@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: Serving static file on Windows
Hi, I use Django 1.3. sample/ static/ js/jquery.1.6.1.min.js css/ settings.py APP_DIR = os.path.abspath(os.path.dirname(__file__)) STATIC_ROOT = os.path.join(APP_DIR, 'static/') STATIC_URL = 'http://192.168.1.141:44/static/' TEMPLATE_DIRS = ( os.path.join(APP_DIR, 'templates/') ) urls.py from django.conf.urls.defaults import patterns, include, url urlpatterns = patterns('', (r'^$', 'hydra.views.index'), (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root':'/django/spl/kk/static'}), ) The above settings works. Thanks Madhu -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Latching onto IPB board
Hello, I'm looking to use django just as a back-end to handle requests made from some of the programs the website develops. It is currently setup on an IPB forum and i would like to be able to access the data stored in the database in much the same way that you would if it was a django made database. Example: user = Member.objects.filter(member_id=12345) would return a class that i can read the associated data from. such as >> user.email >> user.member_group_id And all of that other interesting information. Im not looking to edit any of it, but just read from it Thanks ~Cody Woolaver -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
BadValueError: Property title is required
Hello, I'm trying to create simple method to create category. I set the model category: class Category(db.Model): title = db.StringProperty(required=True) clashes_count = db.IntegerProperty(default=0) And the class New Category as well : class NewCategoryPage(webapp.RequestHandler): def get(self): categories = Category.all().order('-title') template_values = { } path = os.path.join(os.path.dirname(__file__), 'templates', 'category_new.html') self.response.out.write(template.render(path, template_values)) def post(self): category = Category() category.title = self.request.get('title') category.put() self.redirect('/') Here is the template: {%extends "base.html"%} {%block body%} Add New Category Title: {%endblock%} The problem is that I'm getting an error BadValueError: Property title is required. Can you help me with that ? Thanks -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Passing parameters to form class
Hello, I've hit a brick wall while trying to create dynamic forms. Basically I am trying to give parameter to a class form and then based on that do a multiple choice questionaire. For example def somefunction(): formi = someForm(ids='1') class someForm(forms.Form): # get id from, use it to get some information from a model and then based on that create a multiplechoice questionnaire. Or better yet do the model querying in somefuntion and only pass the results to someForm. * Inside someForm I can create a tuple and then use this tuple to do a MultipleChoiceField but I can't for the life of me understand how I could parametrize this. So this works: C = (('a','a'), ('b','b'), ('c','c'), ('d','d'),) vaihtoehdot = forms.MultipleChoiceField(choices=C, widget=forms.CheckboxSelectMultiple) but when I try to change the C to be dynamic I get an empty form. I've tried fiddling with the __init__ function but to no avail. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to create user on mobile app for Django site?
What is the correct way to do the following: 1) Mobile App from which a user can create a user/profile on the Django site 2) Allow authenticated users to create on the site and query personalized data from the site This is what I guess I have to do: 1) Create a REST API (probably with e.g. django-piston) on at the Django site for creation and authentication How would I authenticate against the Django site? When I use URL connections from the mobile app do I always have to send the credentials or can the Django site identify me by storing session cookies on the client just like as if the mobile app would be a browser? Note: When I say mobile app I actually mean iPhone App for now, but there might be a Android version sometime in the future. Thanks for any advice! -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Why self-defined session_key got changed when save in DB?
On Sat, May 28, 2011 at 4:00 AM, Jimmy wrote: > Hi, > > I have following code to set self-defined session_key: > from django.contrib.sessions.backends.db import SessionStore from django.contrib.sessions.models import Session a = SessionStore(session_key="fwefwejfo3j20jf02jnfweojfeo") a.save() a.session_key > 'a6e020a64789b5644e923c85b80a1d0b' > > Why the session_key got changed after saved in DB? Where is my defined > session_key? > This is not a bug, it is by design. The session app is protecting you from session fixation attacks. If you try to use a session with a specified key, and no session with that key exists, django will cycle the session key to avoid a user being caught by a session fixation attack, where a malicious user attempts to get a valid user to log in using a known session key, and then accesses their session. Cheers Tom -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: admin site search field
yes, that was that I copy and didn't select de ', so when I pasted I saw only the missing bracket. On 31 mayo, 04:07, delegb...@dudupay.com wrote: > First, you did enclose doc properly. You wrote 'doc instead of 'doc'. > Sort that first. I'm however not suggesting that is the solution. > Regards. > Sent from my BlackBerry wireless device from MTN > > > > > > > > -Original Message- > From: podio > > Sender: django-users@googlegroups.com > Date: Mon, 30 May 2011 16:24:10 > To: Django users > Reply-To: django-users@googlegroups.com > Subject: admin site search field > > Hi, I'm new and I'm trying to make an app that have a field, pointing > to a record of the same object class. How can a make django has a > search form and show the record of the class on a popup window > likehttp://demoweb.cibernatural.com/admin/gestion/presupuesto/add/(user > and password demo:demo) but pointing to the same class > > class afiliado(models.Model): > def __unicode__(self): > return self.nombre > nombre = models.CharField("Nombre",max_length=200) > fecha_nac = models.DateField("Fecha Nacimiento") > doc = models.CharField("Documento",max_length=20,blank =True) > obra_social = models.ForeignKey(obra_sociale) > caracter = models.ForeignKey(caractere) > tipo = models.ForeignKey(tipo) > titular = models.CharField(max_length=200) > this > field > > class AfiliadoAdmin(admin.ModelAdmin): > fieldsets = [ > (None ,{'fields': > ['nombre','fecha_nac','DOCN','Nacionalidad']}), > ('Datos Generales' ,{'fields': > ['obra_social','caracter','tipo',"titular",'Matricula','fecha_ing']}), > ('Datos de contacto',{'fields': > ['Direccion',"CP","Ciudad","Provincia","Tel1","Tel2","Email"]}), > ] > list_display = ('nombre',"tipo") > list_filter = ['Ciudad'] > search_fields = ['nombre','doc] > > Thansk! > > -- > 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 > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://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-users@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: python code works in command line but not in django
On May 31, 12:25 pm, Kann wrote: > Hi Bruno, > > I tested with both system's python shell and the "manage.py shell", > and both of them also worked. The PNG file was created properly. Ok. > I also check the path returned from os.path.abspath() and both of them > are ok as well. Ok. > Now I am testing using the Django embedded development server. Well... If it works using django shell and not using the embedded server, you'll have to step-debug your code (you know how to use pdb ?). If it works using the embedded server and fail using Apache or another front-end web server, then it's most probably some ENV / permission problem. 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-users@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: BadValueError: Property title is required
On May 31, 11:45 am, "michal.bulla" wrote: > Hello, > > I'm trying to create simple method to create category. I set the model > category: > > class Category(db.Model): > title = db.StringProperty(required=True) > clashes_count = db.IntegerProperty(default=0) Are you sure you posted on the right newsgroup ?-) You're obviously not using Django's ORM. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Accessing request.user in formset validation
Hi all, in some of my forms and formsets I need access to request.user in form validation. With an individual form, I pass request.user as a parameter to the constructor, using code like this: class ErfasseZeitraumForm(forms.Form): von= forms.DateField(widget=AdminDateWidget()) bis= forms.DateField(widget=AdminDateWidget()) def __init__(self, User, *args, **kwargs): super(ErfasseZeitraumForm, self).__init__(*args, **kwargs) self.User = User How can I achieve the same for entire formsets? I'm still quite new to Python, and I'm unsure what to override where to make the formset factory pass the request.user to all form constructors, or even if that is the "best" and canonical way to this? Thank you very much! Best regards, Carsten -- Cafu - the open-source Game and Graphics Engine for multiplayer, cross-platform, real-time 3D Action Learn more at http://www.cafu.de -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there an HTML editor that's Django-aware
On Mon, May 30, 2011 at 2:41 PM, Jacob Kaplan-Moss wrote: > On Monday, May 30, 2011, BobX wrote: >> If anyone from the Django Project itself is listening then can I (very >> humbly) suggest that some editor recommendations would make a real >> fine addition to the info on the site (useful to n00b's like me >> anyway). > > That's a good idea - thanks! > > Where do you think such information should live? That is, at what > point in your process of learning Django would information about > editors have been helpful? Somewhere in the tutorial, or after? > Before? > > Thanks, > > Jacob > The wording on this should be very careful. The default answer to 'what editor should I use to develop with Django' should be 'the one that you know how to use and are comfortable using'. We shouldn't be suggesting that there are a couple of 'correct' choices, but perhaps providing hints and tips on how to fully use certain popular editors with Django, eg how to correctly enable syntax highlighting for django templates in various editors. We definitely should not be trying to answer the question 'what is the best editor for Django', or in any way try to suggest to noobies that they must/should learn a new editor as well as learning Django. The idea that because someone is new to Django means that they must also be new to typing to text into a file and need our help to guide them is somewhat patronizing. Cheers Tom -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there an HTML editor that's Django-aware
I would suggest a section that all that newbies can visit on the website, with links to various text editors so that they can make their own decisions depending on their own personal preference etc. Cheers JP De Villiers On Tue, May 31, 2011 at 3:26 PM, Tom Evans wrote: > On Mon, May 30, 2011 at 2:41 PM, Jacob Kaplan-Moss > wrote: > > On Monday, May 30, 2011, BobX wrote: > >> If anyone from the Django Project itself is listening then can I (very > >> humbly) suggest that some editor recommendations would make a real > >> fine addition to the info on the site (useful to n00b's like me > >> anyway). > > > > That's a good idea - thanks! > > > > Where do you think such information should live? That is, at what > > point in your process of learning Django would information about > > editors have been helpful? Somewhere in the tutorial, or after? > > Before? > > > > Thanks, > > > > Jacob > > > > The wording on this should be very careful. The default answer to > 'what editor should I use to develop with Django' should be 'the one > that you know how to use and are comfortable using'. > > We shouldn't be suggesting that there are a couple of 'correct' > choices, but perhaps providing hints and tips on how to fully use > certain popular editors with Django, eg how to correctly enable syntax > highlighting for django templates in various editors. > > We definitely should not be trying to answer the question 'what is the > best editor for Django', or in any way try to suggest to noobies that > they must/should learn a new editor as well as learning Django. > > The idea that because someone is new to Django means that they must > also be new to typing to text into a file and need our help to guide > them is somewhat patronizing. > > Cheers > > Tom > > -- > 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 > 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-users@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: Accessing request.user in formset validation
On Tue, May 31, 2011 at 2:21 PM, Carsten Fuchs wrote: > Hi all, > > in some of my forms and formsets I need access to request.user in form > validation. > > With an individual form, I pass request.user as a parameter to the > constructor, using code like this: > > class ErfasseZeitraumForm(forms.Form): > von = forms.DateField(widget=AdminDateWidget()) > bis = forms.DateField(widget=AdminDateWidget()) > > def __init__(self, User, *args, **kwargs): > super(ErfasseZeitraumForm, self).__init__(*args, **kwargs) > self.User = User > > > How can I achieve the same for entire formsets? > > I'm still quite new to Python, and I'm unsure what to override where to make > the formset factory pass the request.user to all form constructors, or even > if that is the "best" and canonical way to this? > > Thank you very much! > > Best regards, > Carsten You need to define a class which inherits from BaseFormSet class, override the __init__ method to accept the user as an argument, override the _construct_form() method to add the additional user argument to the form kwargs. Then, define a form class which accepts the user argument in its __init__ method. Finally, specify to Django to use these forms by passing them as the form and formset arguments to formset_factory or modelformset_factory - the same technique applies to both. Eg for some LogEntry model: from django.forms.models import ModelForm, BaseModelFormSet,\ modelformset_factory from models import LogEntry class LogEntryBaseFormSet(BaseModelFormSet): def __init__(self, *args, **kwargs): self.user = kwargs.pop('user') super(LogEntryBaseFormSet, self).__init__(*args, **kwargs) def _construct_form(self, i, **kwargs): kwargs['user'] = self.user return super(LogEntryBaseFormSet, self)._construct_form(i, **kwargs) class LogEntryForm(ModelForm): def __init__(self, *args, **kwargs): self.user = kwargs.pop('user') super(LogEntryForm, self).__init__(*args, **kwargs) def clean(self): # use self.user return self.cleaned_data LogEntryFormSet = modelformset_factory(LogEntry, form=LogEntryForm, formset=LogEntryBaseFormSet, extra=3, can_delete=True) Cheers Tom -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: python code works in command line but not in django
I am just new to programming and not quite familiar with pdb. But I assume that this is what you are talking about: http://docs.python.org/library/pdb.html Perhaps, I will look into it. Thanks for your suggestions. :) Kann On May 31, 3:13 pm, bruno desthuilliers wrote: > On May 31, 12:25 pm, Kann wrote: > > > Hi Bruno, > > > I tested with both system's python shell and the "manage.py shell", > > and both of them also worked. The PNG file was created properly. > > Ok. > > > I also check the path returned from os.path.abspath() and both of them > > are ok as well. > > Ok. > > > Now I am testing using the Django embedded development server. > > Well... If it works using django shell and not using the embedded > server, you'll have to step-debug your code (you know how to use > pdb ?). > > If it works using the embedded server and fail using Apache or another > front-end web server, then it's most probably some ENV / permission > problem. > > 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-users@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: Learning Django: Approach / Advice / Resources
On May 30, 9:30 pm, Robin wrote: > A little while ago, I was approached about building a basic web site > for a small store. The requirements were pretty typical and read like > a menu of web development tutorials. This was to be a data driven > site that any decent web developer could build. I, however, am not a > web developer, decent or otherwise. So, I turned the assignment down > and decided it's time I looked into learning something about web > development. > > I looked at everything from ASP to Java to PHP and even the likes of > Drupal and Joomla. I liked the ideas and patterns behind Django as a > framework ( MVC = :) ) and Python as a language. The combination > seemed like perfect middle ground to me. Things were going well as I > worked through the tutorial and explored the documentation to dig > deeper into core Django topics. Where am I today? > > I'm struggling a bit with Django, to be honest. Or maybe I'm > struggling with Python, I'm not completely certain which. Maybe it's > because I'm trying to learn web development and Python at the same > time. I'm certainly no genius, but I'm not a bonehead either...at > least my mother doesn't think so. ;) > > The individual technical ideas are presented well and I can always > find enough information to learn more. But Django as a whole feels > less cohesive. Or maybe it's that Django sometimes feels...TOO > flexible? There are certainly a lot of choices in terms of how much > Django to use and how much to roll yourself. Guidance seems to be > offered on a per-module basis. Maybe that's just how it is and I'm > looking for structure where there is none available. > > I'm not sure what to override...when to call the super classes > corresponding method. Do I have to concern myself with the test > cookie idea? Should I name my URLs? Is mixing positional and keyword > arguments OK? Are generic views the best way, or just the quickest > way? > > I guess it boils down to a concern over making poor choices and > learning bad habits. If I'm going to spend any amount of time with > this web development hing, I want to do it right. I'm also fighting > my urge to build everything myself. Sure it would be plenty flexible, > but it would also take longer and wouldn't leverage the great work > done by all of Django's contributors. > > So, what am I rattling on about then? > > Judging by some of the posts I've read since joining the group, I'm > sure there are a bunch of folks who would appreciate some guidance > and / or best practices from the more experienced Django developers. > I understand everyone learns and progresses differently, but I would > really appreciate your take on things. > > How much do you use built in Django functionality? Are there > components you tend to avoid? Do you use Django only for certain > types of projects? Do you struggle with Python or Django? Is the > source code a good place to spend some time? Is your authentication > system home-grown? Have you been bitten in the behind by using too > much Django? Not enough? > > I realize this is a lot to ask, but I think it's a good thing that we > help newer developers do things the right way. I certainyl want to > become a contributing member of this group, but not until I won't give > bad advice and flat out wrong answers. ;) > > I've gone through a good chunk of the Django Book online. Is this a > good resource or do you have other recommendations? There aren't all > that many books on Django, but there are a few. Do any do a better > job than the others of guiding you to the best way to build web > sites / apps? I sure wish there was a book that kept pace with the > changes and the miost recent version. Is the fact that there isn't > much available a bad sign? > > Just jump in and adjust as I learn my lessons? > > Regards, > > Robin Hi Robin Not sure I can address all your issues, so I will just pick up on a few... One thing from the start -> " If I'm going to spend any amount of time with this web development thing, I want to do it right." You will - eventually. Its often really hard to do it right first time because you do not have enough experience to know if you're making a mistake! Getting going, doing stuff and maybe putting out in public the parts you are most concerned/unsure about is the best way to get the experience... "struggling with Python" I cannot say that its essential to know Python in depth before starting web programming, but I would say it would be a huge help. Its not clear what programming experience you have. If none, then its worth starting with the basics of programming. If you have some, then try and find a comparison between the language you used and Python (pref. written by a Python person). Some useful "getting started" tutorials: * http://docs.activestate.com/activepython/2.5/easytut/index.html * http://www.gidnetwork.com/b-26.html After reading and trying out what someone else has done, try and build st
Re: python code works in command line but not in django
On May 31, 4:06 pm, Kann wrote: > I am just new to programming and not quite familiar with pdb. But I > assume that this is what you are talking about: > > http://docs.python.org/library/pdb.html Yes, that's it. This and the logging module are tools that are really worth spending some time learning, as they will save you way more time in the long run. Note that there are similar tools for Java, if you ever need to trace code execution in the Java program. Also and while we're at it, you may want to at least check the return code from the os.system code (or replace the call to os.system with some subprocess function or method that allow you to catch and check the stderr of the Java process). -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to implement a data grid? (or populate inlineformset with initial data)
Thanks, Jayapal. I was hoping there was a little less java/ more django way to do this by utilizing a Django ModelForm or InlindeFormSet and rendering partial views. So am I missing the point of InlineFormSets? Can these not be populated with data so they can be used to edit a set of existing records? Thanks. Tony On May 31, 12:03 am, jai_python wrote: > Hi, > Long back i had used Dojodatagrid, plz go through my > bloghttp://jayapal-d.blogspot.com/2009/08/dojo-datagrid-with-editable-cel... > > I am sure that we can do with jquery. > > Lemme know if u required any help. > > Thanks, > Jayapal > > On May 31, 6:39 am, snfctech wrote: > > > I want to display a list of records that have some editable fields and > > some readonly fields, as well as asynchronously add new records to the > > list. I thought the way to start would be with an InlineFormSet - but > > I can't figure out how to populate my formset with initialdata. E.g. > > MyInlineFormset(queryset=myquery.all()) or > > MyInlineFormset(data=myquery.vales()) doesn't do the trick. > > > Can someone steer me in the right direction? > > > Thanks. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to I create download link of some file using django
Dear all, I am a bit confused about how to set the MEDIA_URL variable here. Currently, I am testing the web using Django embedded webserver and doesn't have a proper url yet. Should my MEDIA_URL be something like... http://my_machine_name:8000/media/ Kann On May 26, 12:42 pm, Boštjan Mejak wrote: > Fix some_file = open('bla/bla/bla/', "rw") to some_file = > open('bla/bla/bla/', "r") > > Fix that "rw" to just "r". You just want the user to read (a.k.a. get) the > file, not have write access to it. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to implement a data grid? (or populate inlineformset with initial data)
On Tue, May 31, 2011 at 9:20 AM, snfctech wrote: > I was hoping there was a little less java/ more django way to do this i haven't seen any Java around Dojo toolkit -- Javier -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to I create download link of some file using django
Hi did you read this documentation about serving static files? In generally you don’t want serve files through django, but through your actual webserver (e.g. Apache, nginx, lighttpd...). However during development you can make django serve them. See: Serving static files in development https://docs.djangoproject.com/en/dev/howto/static-files/ Since it can become a bit cumbersome to define this URL pattern, Django ships with a small URL helper function static() that takes as parameters the prefix such as MEDIA_URL and a dotted path to a view, such as 'django.views.static.serve'. Any other function parameter will be transparently passed to the view. An example for serving MEDIA_URL ('/media/') during development: from django.conf import settings from django.conf.urls.static import static urlpatterns = patterns('', # ... the rest of your URLconf goes here ... ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) cheers On May 31, 2011, at 4:24 PM, Kann wrote: > Dear all, > > I am a bit confused about how to set the MEDIA_URL variable here. > Currently, I am testing the web using Django embedded webserver and > doesn't have a proper url yet. Should my MEDIA_URL be something > like... http://my_machine_name:8000/media/ > > Kann > > On May 26, 12:42 pm, Boštjan Mejak wrote: >> Fix some_file = open('bla/bla/bla/', "rw")tosome_file = >> open('bla/bla/bla/', "r") >> >> Fix that "rw" to just "r". You just want the user to read (a.k.a. get) the >> file, not have write access to it. > > -- > 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 > 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-users@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: How to I create download link of some file using django
> I am a bit confused about how to set the MEDIA_URL variable here. > Currently, I am testing the web using Django embedded webserver and > doesn't have a proper url yet. Should my MEDIA_URL be something > like... http://my_machine_name:8000/media/ yes, but so in your template you do: > ### in the template > download Your: > http://groups.google.com/group/django-users?hl=en.
Re: how to implement a data grid? (or populate inlineformset with initial data)
On Tuesday, 31 May 2011 15:20:11 UTC+1, snfctech wrote: > > Thanks, Jayapal. > > I was hoping there was a little less java/ more django way to do this > by utilizing a Django ModelForm or InlindeFormSet and rendering > partial views. > > So am I missing the point of InlineFormSets? Can these not be > populated with data so they can be used to edit a set of existing > records? > > Thanks. > > Tony > No, you're not missing the point - that is exactly what model formsets are for. But you haven't read the documentation very closely: InlineFormsets are meant for editing only those elements that are related via ForeignKey to a specific object, so it is that related object that you pass to the formset via the `instance` parameter. The documentation shows this clearly: https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#inline-formsets If you want to edit the elements of a queryset that aren't necessarily all related to the same object, you just use a standard ModelFormset, which does take a `queryset` argument - again, as shown in the docs: https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#using-a-custom-queryset -- DR. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Does django 1.3 has a ubuntu deb package released!
You can always install the debian package from: http://packages.debian.org/wheezy/python-django which seems to work fine... On Apr 30, 3:29 am, Korobase wrote: > Does django 1.3 has a ubuntu deb package released ! > I have googled but get none,Any one have done this? > Thanks. > > -- -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: admin site search field
I found one solutions: field = models.OneToOneField("self") Im now searching how have a search form instead of a combo box. On 31 mayo, 10:10, podio wrote: > yes, that was that I copy and didn't select de ', so when I pasted I > saw only the missing bracket. > > On 31 mayo, 04:07, delegb...@dudupay.com wrote: > > > > > > > > > First, you did enclose doc properly. You wrote 'doc instead of 'doc'. > > Sort that first. I'm however not suggesting that is the solution. > > Regards. > > Sent from my BlackBerry wireless device from MTN > > > -Original Message- > > From: podio > > > Sender: django-users@googlegroups.com > > Date: Mon, 30 May 2011 16:24:10 > > To: Django users > > Reply-To: django-users@googlegroups.com > > Subject: admin site search field > > > Hi, I'm new and I'm trying to make an app that have a field, pointing > > to a record of the same object class. How can a make django has a > > search form and show the record of the class on a popup window > > likehttp://demoweb.cibernatural.com/admin/gestion/presupuesto/add/(user > > and password demo:demo) but pointing to the same class > > > class afiliado(models.Model): > > def __unicode__(self): > > return self.nombre > > nombre = models.CharField("Nombre",max_length=200) > > fecha_nac = models.DateField("Fecha Nacimiento") > > doc = models.CharField("Documento",max_length=20,blank =True) > > obra_social = models.ForeignKey(obra_sociale) > > caracter = models.ForeignKey(caractere) > > tipo = models.ForeignKey(tipo) > > titular = models.CharField(max_length=200) > this > > field > > > class AfiliadoAdmin(admin.ModelAdmin): > > fieldsets = [ > > (None ,{'fields': > > ['nombre','fecha_nac','DOCN','Nacionalidad']}), > > ('Datos Generales' ,{'fields': > > ['obra_social','caracter','tipo',"titular",'Matricula','fecha_ing']}), > > ('Datos de contacto',{'fields': > > ['Direccion',"CP","Ciudad","Provincia","Tel1","Tel2","Email"]}), > > ] > > list_display = ('nombre',"tipo") > > list_filter = ['Ciudad'] > > search_fields = ['nombre','doc] > > > Thansk! > > > -- > > 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 > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://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-users@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: Accessing request.user in formset validation
Hi Tom, wow, perfect!! A thousand thanks for your help and example code! :-D Best regards, Carsten -- Cafu - the open-source Game and Graphics Engine for multiplayer, cross-platform, real-time 3D Action Learn more at http://www.cafu.de -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to I create download link of some file using django
Thanks for your help Ivo, I have another question here. It seems that django.contrib.staticfiles can be used to handle some static files during the 'debug' mode while using the embedded 'runserver' from django. However, would it be possible if I just develop my website using the system's Apache and not using the django.contrib.staticfiles? Kann On May 31, 4:51 pm, Ivo Brodien wrote: > > I am a bit confused about how to set the MEDIA_URL variable here. > > Currently, I am testing the web using Django embedded webserver and > > doesn't have a proper url yet. Should my MEDIA_URL be something > > like...http://my_machine_name:8000/media/ > > yes, but so in your template you do: > > > ### in the template > > download > > Your:> http://groups.google.com/group/django-users?hl=en.
Re: How to create user on mobile app for Django site?
On May 31, 4:35 am, Ivo Brodien wrote: > What is the correct way to do the following: > > 1) Mobile App from which a user can create a user/profile on the Django site > 2) Allow authenticated users to create on the site and query personalized > data from the site My approach would be to: 1) Build a regular site using django-registration and django-profiles to handle signups, passwords as usual. 2) Build an HTML mobile site off of that (you need one anyway, even if you're going to have an app). There are lots of tutorials out there on delivering mobile versions of content with Django. 3) Use something like Sencha or Phonegap to compile the mobile site as iPhone and Android apps. ./s -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Learning Django: Approach / Advice / Resources
You guys are spectacular! Thanks! I'll give these replies a few reads and just keep plugging along. I'm going to sort of circle back and see if it wouldn't be a good idea to restart my project with a fresh set of eyes now that I've spent a bit of time with Django. Derek, The test cookie thing is -- as I understand it -- you place a test cookie, then check if it's there. It's basically a check to see if the browser accepts cookies. I'm just not entirely sure when I should and shouldn't make the check when using parts of the built-in auth moduel. I guess if I'm using the login view, it's will test for me. I sort of started with the whole auth system, then backed out of using the form and the view just to learn how it works on a basic level. And in browsing the code, I saw the test cookie functions and did some research. Thanks again! Robin On May 31, 8:07 am, Derek wrote: > On May 30, 9:30 pm, Robin wrote: > > > > > > > > > > > A little while ago, I was approached about building a basic web site > > for a small store. The requirements were pretty typical and read like > > a menu of web development tutorials. This was to be a data driven > > site that any decent web developer could build. I, however, am not a > > web developer, decent or otherwise. So, I turned the assignment down > > and decided it's time I looked into learning something about web > > development. > > > I looked at everything from ASP to Java to PHP and even the likes of > > Drupal and Joomla. I liked the ideas and patterns behind Django as a > > framework ( MVC = :) ) and Python as a language. The combination > > seemed like perfect middle ground to me. Things were going well as I > > worked through the tutorial and explored the documentation to dig > > deeper into core Django topics. Where am I today? > > > I'm struggling a bit with Django, to be honest. Or maybe I'm > > struggling with Python, I'm not completely certain which. Maybe it's > > because I'm trying to learn web development and Python at the same > > time. I'm certainly no genius, but I'm not a bonehead either...at > > least my mother doesn't think so. ;) > > > The individual technical ideas are presented well and I can always > > find enough information to learn more. But Django as a whole feels > > less cohesive. Or maybe it's that Django sometimes feels...TOO > > flexible? There are certainly a lot of choices in terms of how much > > Django to use and how much to roll yourself. Guidance seems to be > > offered on a per-module basis. Maybe that's just how it is and I'm > > looking for structure where there is none available. > > > I'm not sure what to override...when to call the super classes > > corresponding method. Do I have to concern myself with the test > > cookie idea? Should I name my URLs? Is mixing positional and keyword > > arguments OK? Are generic views the best way, or just the quickest > > way? > > > I guess it boils down to a concern over making poor choices and > > learning bad habits. If I'm going to spend any amount of time with > > this web development hing, I want to do it right. I'm also fighting > > my urge to build everything myself. Sure it would be plenty flexible, > > but it would also take longer and wouldn't leverage the great work > > done by all of Django's contributors. > > > So, what am I rattling on about then? > > > Judging by some of the posts I've read since joining the group, I'm > > sure there are a bunch of folks who would appreciate some guidance > > and / or best practices from the more experienced Django developers. > > I understand everyone learns and progresses differently, but I would > > really appreciate your take on things. > > > How much do you use built in Django functionality? Are there > > components you tend to avoid? Do you use Django only for certain > > types of projects? Do you struggle with Python or Django? Is the > > source code a good place to spend some time? Is your authentication > > system home-grown? Have you been bitten in the behind by using too > > much Django? Not enough? > > > I realize this is a lot to ask, but I think it's a good thing that we > > help newer developers do things the right way. I certainyl want to > > become a contributing member of this group, but not until I won't give > > bad advice and flat out wrong answers. ;) > > > I've gone through a good chunk of the Django Book online. Is this a > > good resource or do you have other recommendations? There aren't all > > that many books on Django, but there are a few. Do any do a better > > job than the others of guiding you to the best way to build web > > sites / apps? I sure wish there was a book that kept pace with the > > changes and the miost recent version. Is the fact that there isn't > > much available a bad sign? > > > Just jump in and adjust as I learn my lessons? > > > Regards, > > > Robin > > Hi Robin > > Not sure I can address all your issues, so I will just pick up on a > few... >
Re: How to I create download link of some file using django
you are welcome! > I have another question here. It seems that django.contrib.staticfiles > can be used to handle some static files during the 'debug' mode while > using the embedded 'runserver' from django. However, would it be > possible if I just develop my website using the system's Apache and > not using the django.contrib.staticfiles? Of course and this is even better, because this is how the setup should be on real server. You have to configure Apache to serve for example everything under http://mydomain.com/static/ as a simple file without talking to django at all. The static stuff is good for static files like CSS and JavaScript. BTW: although this goes beyond the question I just want to mention it for completeness. On the other hand the {{MEDIA_URL }} and MEDIA_ROOT is more for server/user generated files. You can still have Apache serve the file after authorizing it against Django. The keyword here is: x-sendfile http://stackoverflow.com/questions/1156246/having-django-serve-downloadable-files What you were doing with open the file probably only makes sense if you need to process the contents of the file in any way. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Chained forms
Hi!, I'm writing an admin action. This action needs to collect some information before execute the "final task". In order to collect this information the user should fill 3 consecutive forms, (once they submitted one, another is rendered). My question is, How can I store the form fields state submitted on each form, and retrieve this fields states on the final form, before execute the 'final task'? Thanks! -- Marc -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
apache+mod_wsgi, redirect to https
Hello guys and girls. I have a question. In my apache configuration I have this: WSGIScriptAlias /misite "rute_to_file.wsgi" The users can access from: http://mysite/ and https://mysite/ I need to enable the access only from "https://mysite/";. Every access from "http://mysite/"; must to be redirected to "https://mysite/";. How can i do this? Normally I use mod_rewrite, and thats works fine for the static files, php, etc, but I don't have idea how do this with mod_wsgi. Additionaly, can be very helpful if somebody now how configure an "Require Auth" with mod_wsgi. Sometime ago somebody asked the same in stackoverflow, without get answers. Thanks for read, and sorry for my poor english. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to implement a data grid? (or populate inlineformset with initial data)
Thanks for your reply, Daniel. I read the docs, but did not understand them properly. Your explanation makes sense, but doesn't seem to be working for me, for some reason. I followed the docs from https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#inline-formsets precisely, but am getting and error that my relation does not exist. I think it may have something to do with not using a default database. The funny thing is, I can access the related records fine from the parent instance (i.e. user.josjeventsregistration_set). Do you need to explicitly tell inlineformset to use a non-default DB somehow? In [1]: from django.forms.models import inlineformset_factory In [2]: from classes.models import JosUsers, JosJeventsRegistration In [3]: RegistrationFormSet = inlineformset_factory(JosUsers, JosJeventsRegistration) In [4]: user = JosUsers.objects.using('mydevdb').get(pk='1234') In [5]: fs = RegistrationFormSet(instance=user) ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (13, 0)) --- DatabaseError Traceback (most recent call last) /home/tony/sandbox/django/dashboard/ in () /home/tony/sandbox/django/env/lib/python2.6/site-packages/django/forms/ models.pyc in __init__(self, data, files, instance, save_as_new, prefix, queryset) 680 qs = queryset.filter(**{self.fk.name: self.instance}) 681 super(BaseInlineFormSet, self).__init__(data, files, prefix=prefix, --> 682 queryset=qs) 683 684 def initial_form_count(self): /home/tony/sandbox/django/env/lib/python2.6/site-packages/django/forms/ models.pyc in __init__(self, data, files, auto_id, prefix, queryset, **kwargs) 413 defaults = {'data': data, 'files': files, 'auto_id': auto_id, 'prefix': prefix} 414 defaults.update(kwargs) --> 415 super(BaseModelFormSet, self).__init__(**defaults) 416 417 def initial_form_count(self): /home/tony/sandbox/django/env/lib/python2.6/site-packages/django/forms/ formsets.pyc in __init__(self, data, files, auto_id, prefix, initial, error_class) 45 self._non_form_errors = None 46 # construct the forms in the formset ---> 47 self._construct_forms() 48 49 def __unicode__(self): /home/tony/sandbox/django/env/lib/python2.6/site-packages/django/forms/ formsets.pyc in _construct_forms(self) 105 # instantiate all the forms and put them in self.forms 106 self.forms = [] --> 107 for i in xrange(self.total_form_count()): 108 self.forms.append(self._construct_form(i)) 109 /home/tony/sandbox/django/env/lib/python2.6/site-packages/django/forms/ formsets.pyc in total_form_count(self) 81 return self.management_form.cleaned_data[TOTAL_FORM_COUNT] 82 else: ---> 83 initial_forms = self.initial_form_count() 84 total_forms = initial_forms + self.extra 85 # Allow all existing related objects/inlines to be displayed, /home/tony/sandbox/django/env/lib/python2.6/site-packages/django/forms/ models.pyc in initial_form_count(self) 685 if self.save_as_new: 686 return 0 --> 687 return super(BaseInlineFormSet, self).initial_form_count() 688 689 /home/tony/sandbox/django/env/lib/python2.6/site-packages/django/forms/ models.pyc in initial_form_count(self) 418 """Returns the number of forms that are required in this FormSet.""" 419 if not (self.data or self.files): --> 420 return len(self.get_queryset()) 421 return super(BaseModelFormSet, self).initial_form_count() 422 /home/tony/sandbox/django/env/lib/python2.6/site-packages/django/db/ models/query.pyc in __len__(self) 80 self._result_cache = list(self._iter) 81 else: ---> 82 self._result_cache = list(self.iterator()) 83 elif self._iter: 84 self._result_cache.extend(self._iter) /home/tony/sandbox/django/env/lib/python2.6/site-packages/django/db/ models/query.pyc in iterator(self) 271 model = self.model 272 compiler = self.query.get_compiler(using=db) --> 273 for row in compiler.results_iter(): 274 if fill_cache: 275 obj, _ = get_cached_row(model, row, /home/tony/sandbox/django/env/lib/python2.6/site-packages/django/db/ models/sql/compiler.pyc in results_iter(self) 678 fields = None 679 has_aggregate_select = bool(self.query.aggregate_select) --> 680 for rows in self.execute_sql(MULTI): 681 for row in rows: 682 if resolve_columns: /home/tony/sandbox/django/env/lib/
Re: How to create user on mobile app for Django site?
Thanks for sharing your opinion! Your approach is probably good for many website/applications, but since I want to make use of InApp Purchases and Camara Overlays and Custom Controls, I don’t think this is the right way to go. I was impressed by PhoneGap though... 2 or 3 years ago I was seeing their affords which where great, but know it seems to have gotten quite big in terms of features and system support. thanks > My approach would be to: > > 1) Build a regular site using django-registration and django-profiles > to handle signups, passwords as usual. > > 2) Build an HTML mobile site off of that (you need one anyway, even if > you're going to have an app). There are lots of tutorials out there on > delivering mobile versions of content with Django. > > 3) Use something like Sencha or Phonegap to compile the mobile site as > iPhone and Android apps. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Chained forms
On Tue, May 31, 2011 at 12:55 PM, Marc Aymerich wrote: > Hi!, > I'm writing an admin action. > This action needs to collect some information before execute the "final > task". > In order to collect this information the user should fill 3 consecutive > forms, (once they submitted one, another is rendered). > My question is, > How can I store the form fields state submitted on each form, and retrieve > this fields states on the final form, before execute the 'final task'? > Thanks! > -- > Marc You should read the docs about Form Wizard: https://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/ -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Multiple inheritance from models.Model and admin.ModelAdmin
I'm trying to create a class that inherits from both models.Model and admin.ModelAdmin, so that I can use models.ManyToManyField and save_model() from admin.ModelAdmin. Unfortunately this combination gives "metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases". I've googled on the error message and tried a couple of the suggestions but with no luck. Anyone know the correct way of doing this? Thanks for any help. Lee -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: apache+mod_wsgi, redirect to https
I usually set up two virtual hosts, one listening on port 80 and the other on 443. The virtual host listening on port 80 just redirects to the other one: ServerAdmin ad...@example.com ServerName domain.com HostnameLookups Off UseCanonicalName On ServerSignature Off Redirect / https://domain.com/ SSLEngine on ServerAdmin ad...@example.com ServerName domain.com HostnameLookups Off UseCanonicalName On ServerSignature Off WSGIScriptAlias / /opt/apache/wsgi_start.py WSGIPassAuthorization On ... I haven't tried it, but would think that you could use mod_rewrite along with mod_wsgi, but it's possible that WSGI gets called first automagically. Hope this helps! Mike -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: apache+mod_wsgi, redirect to https
Thanks men, I did this: -- ... ... RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} ... Works ok to me. Now I must to test the "Require Auth". Bye. On 31 mayo, 13:33, Michael Scovetta wrote: > I usually set up two virtual hosts, one listening on port 80 and the other > on 443. The virtual host listening on port 80 just redirects to the other > one: > > > ServerAdmin ad...@example.com > ServerName domain.com > > HostnameLookups Off > UseCanonicalName On > ServerSignature Off > > Redirect /https://domain.com/ > > > > SSLEngine on > > ServerAdmin ad...@example.com > ServerName domain.com > > HostnameLookups Off > UseCanonicalName On > ServerSignature Off > > WSGIScriptAlias / /opt/apache/wsgi_start.py > WSGIPassAuthorization On > ... > > > I haven't tried it, but would think that you could use mod_rewrite along > with mod_wsgi, but it's possible that WSGI gets called first automagically. > > Hope this helps! > > Mike -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
"invalid label' as it pertains to application name
I am getting a pretty non-descript error reading "Caught RuntimeError while rendering: invalid label: cigar-wizard" when i go to a certain url on my website. This isn't a form label... it's referring to an application name. Any ideas what that means? -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django DATETIME_FORMAT Localization
On Wed, May 25, 2011 at 10:46:30AM -0700, jrs_66 wrote: > How can I do something like strptime(request.POST["start-date"], > mycurrent_DATETIME_FORMAT)... There's got to be an undocumented way of > referencing the constant currently being used? I guess you need `django.utils.formats.date_format` function. -- Kirill Spitsin -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
FreeBSD fastcgi rc.d script
It took me a bit to figure out the particulars of this, but I thought I'd give it to the community, in case someone comes looking for the same solution. #!/bin/sh # # PROVIDE: myapp # REQUIRE: DAEMON # KEYWORD: shutdown # # Notes on usage: Just adjust the location and name of your app as needed. . /etc/rc.subr name="myapp" rcvar=`set_rcvar` load_rc_config $name # # DO NOT CHANGE THESE DEFAULT VALUES HERE # SET THEM IN THE /etc/rc.conf FILE # myapp_enable=${myapp_enable-"NO"} myapp_pidfile=${myapp_pidfile-"/var/run/myapp.pid"} command_interpreter="/usr/local/bin/python2.7" #Set this to whatever works for you pidfile="${utility_pidfile}" command="/path/to/app/manage.py" command_args="runfcgi method=threaded host=127.0.0.1 port=3033 pidfile=$utility$ run_rc_command "$1" -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
how to display a property in a ModelFormSet?
I'm using a ModelFormSet to display and edit multiple records. Some of those records have related attributes that I want to display, but not edit. E.g. lineitem.quantity [editable] lineitem.product.description [not editable] So I thought I would add a property to my LineItem class in order to render that in a ModelFormSet, like so: def _get_product_description(self): return self.product.description product_description = property(_get_product_description) But that wont get displayed when I render my FormSet. Any tips on how to deal with this problem? Thanks. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Multiple inheritance from models.Model and admin.ModelAdmin
Discovered that save_model() is still available even if I don't inherit admin.ModelAdmin, which avoids the metaclass conflict. On May 31, 10:36 am, Lee wrote: > I'm trying to create a class that inherits from both models.Model and > admin.ModelAdmin, so that I can use models.ManyToManyField and > save_model() from admin.ModelAdmin. Unfortunately this combination > gives "metaclass conflict: the metaclass of a derived class must be a > (non-strict) subclass of the metaclasses of all its bases". I've > googled on the error message and tried a couple of the suggestions but > with no luck. Anyone know the correct way of doing this? > > Thanks for any help. > > Lee -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Auditing Record Changes in All Admin Tables
Thanks for that tip Ryan. Here's the relevant models.py code I used to get this to _almost_ work: - class AuditedTable(models.Model): created = models.DateTimeField(auto_now_add=True) created_by = models.CharField(blank=True,max_length=20) updated = models.DateTimeField(auto_now=True) updated_by = models.CharField(blank=True,max_length=20) class Meta: abstract = True def save_model(self, request, obj, form, change): if change: updated_by = request.user else: created_by = request.user class Entity1(AuditedTable): title = models.CharField(max_length=20) def __unicode__(self): return self.title The initial record creation works great, but on update, the user ID is returned by request.user instead of the user name. Anybody have ideas how to fix that? On May 29, 12:37 am, Ryan wrote: > This will show you how to achieve this in the django > admin:https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contr... -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Auditing Record Changes in All Admin Tables
That code is supposed to go in the models admin definition like so: admin.py: -- class AuditAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): obj.user = request.user obj.save() Ryan -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django-profiles and get_absolute_url
Hi All, I am having trouble getting an absolute URL using the django-profiles module with usernames that have periods in them (for instance "/ profiles/user.1"). Here is my profile class: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) web_site = models.URLField(blank=True, null=True, verify_exists=False) @models.permalink def get_absolute_url(self): return ('profiles_profile_detail', (), {'username': unicode(self.user.username)}) If the user name does not have a period in it, it returns a desirable URL (for instance "/profiles/user1" and "/profiles/user_1" work). I've tried forcing to unicode, to str, and leaving blank. I've even forced UTF coding in the database using PRAGMA encoding="UTF-8"; Running out of ideas here...any thoughts? -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-profiles and get_absolute_url
Hi, Could you share the URL rule for profiles_profile_detail? Matías Excerpts from Andrew Sledge's message of Tue May 31 17:37:20 -0300 2011: > Hi All, > > I am having trouble getting an absolute URL using the django-profiles > module with usernames that have periods in them (for instance "/ > profiles/user.1"). > > Here is my profile class: > > class UserProfile(models.Model): > user = models.ForeignKey(User, unique=True) > web_site = models.URLField(blank=True, null=True, > verify_exists=False) > > @models.permalink > def get_absolute_url(self): > return ('profiles_profile_detail', (), {'username': > unicode(self.user.username)}) > > If the user name does not have a period in it, it returns a desirable > URL (for instance "/profiles/user1" and "/profiles/user_1" work). > > I've tried forcing to unicode, to str, and leaving blank. I've even > forced UTF coding in the database using PRAGMA encoding="UTF-8"; > > Running out of ideas here...any thoughts? -- Matías Aguirre -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-profiles and get_absolute_url
Don't think that has anything to do with it, but here goes... url(r'^profiles/', include('profiles.urls')), The remaining url config is provided by django-profiles. On May 31, 4:46 pm, Matías Aguirre wrote: > Hi, > > Could you share the URL rule for profiles_profile_detail? > > Matías > > Excerpts from Andrew Sledge's message of Tue May 31 17:37:20 -0300 2011: > > > > > > > > > Hi All, > > > I am having trouble getting an absolute URL using the django-profiles > > module with usernames that have periods in them (for instance "/ > > profiles/user.1"). > > > Here is my profile class: > > > class UserProfile(models.Model): > > user = models.ForeignKey(User, unique=True) > > web_site = models.URLField(blank=True, null=True, > > verify_exists=False) > > > @models.permalink > > def get_absolute_url(self): > > return ('profiles_profile_detail', (), {'username': > > unicode(self.user.username)}) > > > If the user name does not have a period in it, it returns a desirable > > URL (for instance "/profiles/user1" and "/profiles/user_1" work). > > > I've tried forcing to unicode, to str, and leaving blank. I've even > > forced UTF coding in the database using PRAGMA encoding="UTF-8"; > > > Running out of ideas here...any thoughts? > > -- > Matías Aguirre -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
spawning threads within test cases in django test framework
I've got a django app with a periodically scheduled background task that updates the database. I've written a bunch of tests for its principal class that are run as part of the django unit test framework. I want to convert the class to do its work using multiple threads, but I'm having trouble getting the tests to run against the multi-threaded version. I've tried sqlite3 and postgres as back-ends, but to no avail. Is there a problem where the testing framework uses transactions to rollback any changes from one test to the next and so the evolving state of the database in that transaction is hidden from the other threads? Can the database connection (and hence transaction) be shared between the threads? Has anyone encountered this problem before? (And, ideally, came up with a really neat solution...) Thanks, Brian -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Passing parameters to form class
Yes, you will want to do this within the __init__ method. Run the super class's init method first so that everything's initialized as normal. Then you will have to grab the field for that instance within the __init__ method (self.fields['vaihtoehdot']) and set the choices property for it. On May 31, 3:09 am, skyde wrote: > Hello, > > I've hit a brick wall while trying to create dynamic forms. > Basically I am trying to give parameter to a class form and then based > on that do a multiple choice questionaire. > > For example > > def somefunction(): > formi = someForm(ids='1') > > class someForm(forms.Form): > # get id from, use it to get some information from a model and then > based on that create a multiplechoice questionnaire. Or better yet do > the model querying in somefuntion and only pass the results to > someForm. > > * > Inside someForm I can create a tuple and then use this tuple to do a > MultipleChoiceField but I can't for the life of me understand how I > could parametrize this. > > So this works: > C = (('a','a'), ('b','b'), ('c','c'), ('d','d'),) > vaihtoehdot = forms.MultipleChoiceField(choices=C, > widget=forms.CheckboxSelectMultiple) > > but when I try to change the C to be dynamic I get an empty form. I've > tried fiddling with the __init__ function but to no avail. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-profiles and get_absolute_url
This is the value for such url definition: url(r'^(?P\w+)/$', views.profile_detail, name='profiles_profile_detail'), the rule uses \w+ which doesn't match the dot character. Example: >>> import re >>> r = re.compile('(\w+)') >>> r.match('name.1').groups() ('name',) >>> r.match('.') >>> So, basically, django-profiles doesn't support usernames with dots characters, you might need to override such URL. url(r'^profiles/(?P[\w\.]+)/$', views.profile_details, name='profiles_profile_detail'), url(r'^profiles/', include('profiles.urls')), Makes sense? Matías Excerpts from Andrew Sledge's message of Tue May 31 17:51:15 -0300 2011: > Don't think that has anything to do with it, but here goes... > > url(r'^profiles/', include('profiles.urls')), > > The remaining url config is provided by django-profiles. > > On May 31, 4:46 pm, Matías Aguirre wrote: > > Hi, > > > > Could you share the URL rule for profiles_profile_detail? > > > > Matías > > > > Excerpts from Andrew Sledge's message of Tue May 31 17:37:20 -0300 2011: > > > > > > > > > > > > > > > > > Hi All, > > > > > I am having trouble getting an absolute URL using the django-profiles > > > module with usernames that have periods in them (for instance "/ > > > profiles/user.1"). > > > > > Here is my profile class: > > > > > class UserProfile(models.Model): > > > user = models.ForeignKey(User, unique=True) > > > web_site = models.URLField(blank=True, null=True, > > > verify_exists=False) > > > > > @models.permalink > > > def get_absolute_url(self): > > > return ('profiles_profile_detail', (), {'username': > > > unicode(self.user.username)}) > > > > > If the user name does not have a period in it, it returns a desirable > > > URL (for instance "/profiles/user1" and "/profiles/user_1" work). > > > > > I've tried forcing to unicode, to str, and leaving blank. I've even > > > forced UTF coding in the database using PRAGMA encoding="UTF-8"; > > > > > Running out of ideas here...any thoughts? > > > > -- > > Matías Aguirre > -- Matías Aguirre -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-profiles and get_absolute_url
Thank you Matias. Your syntax was a little off, but you did solve it. Here is the correct syntax: import profiles ... ... ... url(r'^profiles/(?P[\w\.]+)/$', 'profiles.views.profile_detail', name='profiles_profile_detail'), I will submit a patch to django-profiles to support the characters "@/./+/-/_". On May 31, 5:00 pm, Matías Aguirre wrote: > This is the value for such url definition: > > url(r'^(?P\w+)/$', views.profile_detail, > name='profiles_profile_detail'), > > the rule uses \w+ which doesn't match the dot character. Example: > > >>> import re > >>> r = re.compile('(\w+)') > >>> r.match('name.1').groups() > ('name',) > >>> r.match('.') > >>> > > So, basically, django-profiles doesn't support usernames with dots characters, > you might need to override such URL. > > url(r'^profiles/(?P[\w\.]+)/$', views.profile_details, > name='profiles_profile_detail'), > url(r'^profiles/', include('profiles.urls')), > > Makes sense? > > Matías > > Excerpts from Andrew Sledge's message of Tue May 31 17:51:15 -0300 2011: > > > > > > > > > Don't think that has anything to do with it, but here goes... > > > url(r'^profiles/', include('profiles.urls')), > > > The remaining url config is provided by django-profiles. > > > On May 31, 4:46 pm, Matías Aguirre wrote: > > > Hi, > > > > Could you share the URL rule for profiles_profile_detail? > > > > Matías > > > > Excerpts from Andrew Sledge's message of Tue May 31 17:37:20 -0300 2011: > > > > > Hi All, > > > > > I am having trouble getting an absolute URL using the django-profiles > > > > module with usernames that have periods in them (for instance "/ > > > > profiles/user.1"). > > > > > Here is my profile class: > > > > > class UserProfile(models.Model): > > > > user = models.ForeignKey(User, unique=True) > > > > web_site = models.URLField(blank=True, null=True, > > > > verify_exists=False) > > > > > @models.permalink > > > > def get_absolute_url(self): > > > > return ('profiles_profile_detail', (), {'username': > > > > unicode(self.user.username)}) > > > > > If the user name does not have a period in it, it returns a desirable > > > > URL (for instance "/profiles/user1" and "/profiles/user_1" work). > > > > > I've tried forcing to unicode, to str, and leaving blank. I've even > > > > forced UTF coding in the database using PRAGMA encoding="UTF-8"; > > > > > Running out of ideas here...any thoughts? > > > > -- > > > Matías Aguirre > > -- > Matías Aguirre -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Auditing Record Changes in All Admin Tables
Moved it to admin.py but it ignores the auto_now parameters (leaving timestamps blank) and doesn't populate the created_by/updated_by fields either: class AuditAdmin(admin.ModelAdmin): created = models.DateTimeField(auto_now_add=True) created_by = models.CharField(blank=True,max_length=20) updated = models.DateTimeField(auto_now=True) updated_by = models.CharField(blank=True,max_length=20) def save_model(self, request, obj, form, change): if change: obj.updated_by = request.user else: obj.created_by = request.user obj.save() class Entity1Admin(AuditAdmin): inlines = (JoinTableInline,) admin.site.register(Entity1,Entity1Admin) - I inserted a sys.exit() line to dump request.user, and it has the correct value, but it's not getting pushed to the database record. Thanks very much for your help, do you have other ideas? -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Does django 1.3 has a ubuntu deb package released!
In Ubuntu 10.04 repository stlll 1.1 version. =/ 2011/5/31 Tobias Quinn > You can always install the debian package from: > > http://packages.debian.org/wheezy/python-django > > which seems to work fine... > > On Apr 30, 3:29 am, Korobase wrote: > > Does django 1.3 has a ubuntu deb package released ! > > I have googled but get none,Any one have done this? > > Thanks. > > > > -- > > -- > 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 > 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-users@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: Is there an HTML editor that's Django-aware
On Tue, 2011-05-31 at 14:26 +0100, Tom Evans wrote: > > Where do you think such information should live? That is, at what > > point in your process of learning Django would information about > > editors have been helpful? Somewhere in the tutorial, or after? > > Before? > > > > Thanks, > > > > Jacob > > > > The wording on this should be very careful. The default answer to > 'what editor should I use to develop with Django' should be 'the one > that you know how to use and are comfortable using'. there is this page: https://code.djangoproject.com/wiki/Emacs I would suggest expanding this to include other editors and putting a link to it in the docs - somewhere near the links to learning python. -- regards KG http://lawgon.livejournal.com Coimbatore LUG rox http://ilugcbe.techstud.org/ -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Model 'Child' is inherited from 'Parent', trying to filter to get only Child results with Parent.objects.filter(...)
Shall I report the inability of using Parent.objects.filter(child__isnull=False) as a bug? -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Model 'Child' is inherited from 'Parent', trying to filter to get only Child results with Parent.objects.filter(...)
This worked on on Django 1.2.5: Parent.objects.exclude(child__isnull=True) Does it work for you? Excerpts from robin's message of Tue May 31 05:53:26 -0300 2011: > Example code: > >class Parent(models.Model): > name = models.CharField(max_length='20',blank=True) > > class Child(Parent): > pass > > I want to get the result of Child.objects.all() but I DO NOT want to > use Child. > I want to use Parent instead, which I tried to do with: > > Parent.objects.filter(child__isnull=False) > > Which doesn't work and gives the result of Product.objects.all() > instead. > However If I do the following, it WORKS: > > Parent.objects.filter(child__name__isnull=False) > > Another way, if I insist on using > Parent.objects.filter(child__isnull=False), is to change the Child > model to the following: > > class Child(models.Model): > parent = models.OneToOneField(Parent) > > Then Parent.objects.filter(child__isnull=False) would WORK > > The problem with the 2 solutions above is that filtering with > child__name__isnull looks hackish, and I don't want to change my Child > model to use OneToOneField. > > So is there a better way? > > Thanks, > Robin -- Matías Aguirre -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.