Re: New python, django user... having issues
Hey, thank you guys so much for your help. I was able to get everything installed. Appreciate it lots. On Apr 16, 2:40 pm, Łukasz Rekuckiwrote: > On 16 April 2011 16:36, Walt wrote: > > > Windows 64 does make things interesting, but just to summarize > > what I do to install on Windows: > > > Install mod_python for python 2.5: > > Do yourself a favour and switch to something else then mod_python. > It's a dead project (that's why it probably won't work with newer > Python). Use mod_wsgi, uwsgi or gunicorn (or any other WSGI server). > > > The reason for using 2.5 is that mod_python or windows and > > the MySQL Python connector only support that version, at > > least as far as I have been able to find. > > The PyPI page says otherwise[1]. You probably mean that there is no > binary packages for newer Python versions. If you trust random blogs, > here are some packages [2][3]. > > [1]:http://pypi.python.org/pypi/MySQL-python/1.2.3 > [2]:http://www.codegood.com/archives/4 > [3]:http://www.codegood.com/archives/129 > > -- > Łukasz Rekucki -- 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: Using composition in Django
On Sat, Apr 16, 2011 at 1:35 PM, Guevarawrote: > Hello! > I have two class, Person and employee, i need make a composition for > this (Prefer composition over inheritance): > > class Person(models.Model): >name = models.CharField(max_length=50) >date_inclusion = models.DateField() ># others fields > > class Employee(models.Model): >person = models.OneToOneField(Person, primary_key=True) >address = models.OneToOneField(Address, primary_key=True) > > > The SQL generate is: > > > BEGIN; > CREATE TABLE "person_person" ( >"id" serial NOT NULL PRIMARY KEY, >"name" varchar(50) NOT NULL, >"date_inclusion" date NOT NULL, > ) > ; > CREATE TABLE "employee_employee" ( >"person_id" integer NOT NULL PRIMARY KEY, >"address_id" integer NOT NULL PRIMARY KEY, > ) > ; > > > This is correct? Should generate the id of the employee? > I don't think it's correct -- a database table shouldn't have two distinct primary keys. It's the "primary_key=True" part of your Employee model fields that is doing this, and is also stopping an "id" field from being automatically generated. If you write Employee like this: class Employee(models.Model): person = models.OneToOneField(Person) address = models.OneToOneField(Address) Then it will generate SQL like this: CREATE TABLE "employee_employee" ( "id" serial NOT NULL PRIMARY KEY, "person_id" integer NOT NULL, "address_id" integer NOT NULL ) ; which is probably closer to what you're expecting. -- Regards, Ian Clelland -- 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: 'Context' object has no attribute 'render_context'
Thanks Walt. I'm not sure why the code is misbehaving either but render_to_response works so I'll roll with that. Cheers On Apr 16, 10:22 am, Waltwrote: > I'm not sure I know why your code is misbehaving, but any > particular reason you aren't using render_to_response instead > of template/context rendering? > > http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to... > > It's much simpler! > > Walt > > -~ -- 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: Using composition in Django
Hi Guevara, Proxy models only inherit python logic, they are what you expect when you subclass a superclass; I dont think thats what you want in this case. I think you actually do want multi-table inheritence, im not too well educated in "design patterns" but i think thats what you mean by composition. However, allthough Python itselfs supports multiple-inheretence, im not sure if that works with more then two Django models. Subclassing a Django model implies a OneToOne relationship which is automaticly generated. An instance of employee should then contain fields from both Person and Adress on the python layer, and contain only the foreign keys on the database layer. Again i'm not sure if this works with 3 models involved (Address, Person and Employee). Take a look at http://docs.djangoproject.com/en/1.3/topics/db/models/#multi-table-inheritance This is what i mean: class Person(models.Model): first_name ... last_name ... class Adress(models.Model): street ... city ... class Employee(Person, Adress): pass Regards, Yuka On Sat, Apr 16, 2011 at 10:35 PM, Guevarawrote: > Hello! > I have two class, Person and employee, i need make a composition for > this (Prefer composition over inheritance): > > class Person(models.Model): > name = models.CharField(max_length=50) > date_inclusion = models.DateField() > # others fields > > class Employee(models.Model): > person = models.OneToOneField(Person, primary_key=True) > address = models.OneToOneField(Address, primary_key=True) > > > The SQL generate is: > > > BEGIN; > CREATE TABLE "person_person" ( > "id" serial NOT NULL PRIMARY KEY, > "name" varchar(50) NOT NULL, > "date_inclusion" date NOT NULL, > ) > ; > CREATE TABLE "employee_employee" ( > "person_id" integer NOT NULL PRIMARY KEY, > "address_id" integer NOT NULL PRIMARY KEY, > ) > ; > > > This is correct? Should generate the id of the employee? > Proxy models could be used for this case? > > 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: Put an "inline" at the top of admin form instead of bottom?
Hi Jeff, I dont knw the details of the top of my head, but you could place inherit a changeform template dedicated for your specific app/model, and simply edit it to have the inline formsets on the top, or use a conditional template tag to display only one of your inline models at the top. I think its all documented in the admin section of the manual. Yuka On Sat, Apr 16, 2011 at 5:30 AM, Jeff Blainewrote: > I'm using the admin functionality for most of my needs (a nice CRUD DB > frontend, not a user-facing website). Is there a best way to get one of my > inline models presented at the top of the form instead of the bottom? I > would greatly prefer not to have to specify all of the fields (via > ModelAdmin.fields), as we really like the automatic introspection > functionality. > > -- > 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: New python, django user... having issues
On 16 April 2011 16:36, Waltwrote: > Windows 64 does make things interesting, but just to summarize > what I do to install on Windows: > > Install mod_python for python 2.5: Do yourself a favour and switch to something else then mod_python. It's a dead project (that's why it probably won't work with newer Python). Use mod_wsgi, uwsgi or gunicorn (or any other WSGI server). > The reason for using 2.5 is that mod_python or windows and > the MySQL Python connector only support that version, at > least as far as I have been able to find. The PyPI page says otherwise[1]. You probably mean that there is no binary packages for newer Python versions. If you trust random blogs, here are some packages [2][3]. [1]: http://pypi.python.org/pypi/MySQL-python/1.2.3 [2]: http://www.codegood.com/archives/4 [3]: http://www.codegood.com/archives/129 -- Łukasz Rekucki -- 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: New python, django user... having issues
I think you're hijacking this thread, yes? Can you submit all the code for the models, please? Perhaps start a new thread... -- 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 models, nested classes, and some weird behavior
Hello. In an app I'm working on I have a package which contains an arbitrary number of modules, each of which is expected to contain several django models. In each module, the models have the same name, but they are nested in an outer class, which I assume shouldn't cause problems. However, it does. In my whittled down example, model PluginLite.Job is somehow assigned PluginPlus.Job. Problem seems to go away when Jobs don't extend models.Model #capabilities/__init__.py: __all__ = ['PluginPlus','PluginLite'] from django.conf import settings if not settings.configured: settings.configure( DATABASE_ENGINE = 'sqlite3', DATABASE_NAME = 'db.sqlite', DATABASE_USER = '', DATABASE_PASSWORD = '', DATABASE_HOST = '', DATABASE_PORT = '', TIME_ZONE = '', ) import capabilities from capabilities import * print 'PluginLite.PluginLite.Job:',capabilities.PluginLite.PluginLite.Job # import capabilities and this prints out #capabilities/PluginLite.py from django.db import models class PluginLite: class Job(models.Model): class Meta: db_table = 'PluginLite_Job' class WorkUnit(models.Model): class Meta: db_table = 'PluginLite_WorkUnit' #capabilities/PluginPlus.py from django.db import models class PluginPlus: class Job(models.Model): class Meta: db_table = 'PluginPlus_Job' class WorkUnit(models.Model): class Meta: db_table = 'PluginPlus_WorkUnit' -- 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: Test fails to run
Hi, In which part of the test are you truncating the db? It could also be that test_ db is still in your database after a previous run of test, and it refuses to flush. Try manually deleting it and running syncdb again. -- Gladys http://blog.bixly.com On Apr 17, 1:20 am, Aleksandr Vladimirskiywrote: > Hello, > > I'm running a test but it fails after syncdb part with the following > message: > > Error: Database test_ couldn't be flushed. Possible > reasons: > * The database isn't running or isn't configured correctly. > * At least one of the expected database tables doesn't exist. > * The SQL was invalid. > Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL > this command wasn't able to run. > The full error: cannot truncate a table referenced in a foreign key > constraint > DETAIL: Table "" references "". > HINT: Truncate table "" at the same time, or use > TRUNCATE ... CASCADE. > > The foreign key is between models in 2 different apps. > > Thanks, > > Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.
Using composition in Django
Hello! I have two class, Person and employee, i need make a composition for this (Prefer composition over inheritance): class Person(models.Model): name = models.CharField(max_length=50) date_inclusion = models.DateField() # others fields class Employee(models.Model): person = models.OneToOneField(Person, primary_key=True) address = models.OneToOneField(Address, primary_key=True) The SQL generate is: BEGIN; CREATE TABLE "person_person" ( "id" serial NOT NULL PRIMARY KEY, "name" varchar(50) NOT NULL, "date_inclusion" date NOT NULL, ) ; CREATE TABLE "employee_employee" ( "person_id" integer NOT NULL PRIMARY KEY, "address_id" integer NOT NULL PRIMARY KEY, ) ; This is correct? Should generate the id of the employee? Proxy models could be used for this case? 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: Using request.GET and having issues
2011/4/16 Karen McNeil> Yep, the encoding was the problem. I just added a line >searchterm = searchterm.encode('utf-8') > Does the nltk code not support unicode? A better solution would be to never do explicit encoding yourself, but rather just pass unicode from the DB and unicode from request.GET into nltk, unless that doesn't work for some reason. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.
Test fails to run
Hello, I'm running a test but it fails after syncdb part with the following message: Error: Database test_ couldn't be flushed. Possible reasons: * The database isn't running or isn't configured correctly. * At least one of the expected database tables doesn't exist. * The SQL was invalid. Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run. The full error: cannot truncate a table referenced in a foreign key constraint DETAIL: Table "" references "". HINT: Truncate table "" at the same time, or use TRUNCATE ... CASCADE. The foreign key is between models in 2 different apps. Thanks, Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 quit unexpectedly
On Sat, Apr 16, 2011 at 6:17 PM, Hudarwrote: > Withouth grappeli, I can go to django admin page. But > after install grappelli, and try to access http://127.0.0.1/admin/ > error appear 'Python quite unexpectedly'. Hello Hudar, It means python crashed, in general this occurs when theres a problem with one of the shared library dependencies. Maybe you can post some information about the os you are running this on, what python packages are installed or availeable on your sys.path and maybe your Django settings.py Also, which grappelli branch are you using? I recall there being atleast 4, all with different dependencies. What happens when you open a shell and do a "from grappelli import *"? Is there any other information being reported besides that error, what does the console report before it crashes? Yuka -- 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: Using request.GET and having issues
Yep, the encoding was the problem. I just added a line searchterm = searchterm.encode('utf-8') and now it works! Thank you! On Apr 16, 9:19 am, Karen Traceywrote: > 2011/4/16 Karen McNeil > > > > > I have the following view set up: > > > def concord(request): > > searchterm = request.GET['q'] > > ... more stuff ... > > return render_to_response('concord.html', locals()) > > > With URL "http://mysite.com/concord/?q=برشه;, and template code > > Your search for {{ searchterm }} returned {{ results }} > > results in {{ texts.count }} texts. > > I get this result on the page: > > Your search for برشه returned 0 results in 8 texts. > > > The search term (برشه) is being passed successfully, but there should > > be 13 results, not zero. When I hard-code "searchterm = 'برشه' " into > > the concord view, instead of "searchterm = request.GET['q']", the page > > displays perfectly. > > With this line of code: > > "searchterm = 'برشه' " > > searchterm will be a bytestring, utf-8 encoded if that is the encoding of > your file. > > With this: > > searchterm = request.GET['q']" > > it will be unicode. Django returns unicode from the DB and request > dictionaries. > > I notice you are explicitly encoding to utf-8 the texts you are searching > before passing them into the nltk code. However you never do this for the > searchterm, and I'd guess that is why the difference in results when you > hard code it vs. pulling it from request.GET. > > Can't you pass unicode to the nltk code? If you can, I'd get rid of the > explicit encoding to utf-8 of the DB content you are searching. If you > really must pass it bytestrings instead of of unicode, then explicitly > encoding the search term to to utf-8 as well will probably fix the problem. > > Karen > --http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.
limit_choices_to (or some other way) to filter ForeignKey choices based on current model field
if i have something like this: === class MyModel(models.Model): name = models.CharField(max_length=255) class OtherModel(models.Model): name = models.CharField(max_length=255) mymodel = models.ForeignKey(MyModel) class MyModelItem(models.Model): mymodel = models.ForeignKey(MyModel) other = models.ForeignKey(OtherModel, null=True, blank=True) === how can i use limit_choices_to (or some other way) to filter ForeignKey choices based on current model field? basically, how can i do: other = models.ForeignKey(OtherModel, null=True, blank=True, limit_choices_to={'mymodel': 'self.mymodel'}) any options works for me (overwriting admin.TabularInline or form for TabularInline). thanks for any info. Aljosa -- 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: New python, django user... having issues
I have two models, model A and model B , model A like this CUSTOMER_NAME = ( (IBM, 'IBM'), (GSMC, 'GSMD'), (CSMC, 'CSMC'), (HJTC, 'HJTC'), customer_name = models.IntegerField(choices = CUSTOMER_NAME, default = IBM,) activity_type = models.IntegerField(choices = ACTIVITY_TYPE, ) I want the constant CUSTOMER_NAME query from model B, how can I do that, when I make a query in model A main body, like this entity_id = ToolDetail.objects.all() it tell me entity_id is not definedhow can I make this query...someone help me. -- 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.
Aw: How to unit test if user has access to page
Also beware! Only do a client.post if you really want to test that a user submits a form. Usually when a not-logged-in-user wants to go to a secured page immediately he will try a get request and just enter the URL. Sometimes your view behaves differently on get and on post (most of the times) so you probably should test both scenarios. Best regards, Martin -- 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: Using request.GET and having issues
No, that's not the issue. In addition to displaying the count, the page also shows the resulting sentences, and the count here is correct because no results were returned. I think Karen, below, might be right that it has something to do with the encoding of the search string... I'll try working that angle and see if I get anywhere with it. Thank you all for your help... On Apr 16, 5:41 am, Shawn Milochikwrote: > This doesn't appear to be a Django question. Your 'results' variable > is being populated by checking the length of an > nltk.text.ConcordanceIndex() instance. I'm not familiar with the nltk > module, but I'm assuming you are at least a little, since you're using > it. It appears that its length isn't useful in determining the count > you want. > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.
Python quit unexpectedly
Hi, Anyone got this problem? I try to run grappelli on django 1.3. and run this command : #python manage.py runserver Server running. Withouth grappeli, I can go to django admin page. But after install grappelli, and try to access http://127.0.0.1/admin/ error appear 'Python quite unexpectedly'. I try both on python 2.5 and python 2.6, got the same error. For additional info, below is my url.py === url.py = from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), (r'^grappelli/', include('grappelli.urls')), ) === -- 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: New python, django user... having issues
Windows 64 does make things interesting, but just to summarize what I do to install on Windows: Install python2.5: http://www.python.org/download/releases/2.5.4/ Install latest apache: http://httpd.apache.org/download.cgi#apache22 Install mod_python for python 2.5: http://archive.apache.org/dist/httpd/modpython/win/3.3.1/mod_python-3.3.1.win32-py2.5-Apache2.2.exe Install your database of choice (postgresql 9.0.1/ mysql): http://www.enterprisedb.com/products-services-training/pgdownload#windows http://www.mysql.com/downloads/mysql/ Install the appropriate python connector: http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.4.win32-py2.5-pg9.0.3-release.exe http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.win32-py2.5.exe/download I also usually install svn: http://www.sliksvn.com/en/download svn co http://code.djangoproject.com/svn/django/trunk/ Add python's bin to your path, add django-admin.py to your path and you should be good to go. The reason for using 2.5 is that mod_python or windows and the MySQL Python connector only support that version, at least as far as I have been able to find. Good luck, Walt -~ -- 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: 'Context' object has no attribute 'render_context'
I'm not sure I know why your code is misbehaving, but any particular reason you aren't using render_to_response instead of template/context rendering? http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response It's much simpler! Walt -~ -- 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: Using request.GET and having issues
> searchterm = request.GET['q'] Shouldn't this be: request.GET.get('q','') Walt -~ -- 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: Unexplainable delay when binding request.POST to form
On Sat, Apr 16, 2011 at 7:10 AM, Toni Milovanwrote: > I'm getting 20-30 seconds delay when trying to bind request.POST data > to form. > > - >CompanyFormset = modelformset_factory(Company, > form=EditCompanyForm, extra=0) > >if request.method == 'POST': >formset = CompanyFormset(request.POST, request.FILES) >if formset.is_valid(): >formset.save() > > --- > > It just happens on one server, and on this line: "formset = > CompanyFormset(request.POST, request.FILES)". I have tried without > request.FILES and without multipart data and always getting the same > delay. I have also tried runing development server and mod_wsgi and > results are the same. > > Delay only happens when binding request data, if I just try to save > formset everything is fast as it should be. Also, on my development > laptop there is no delay whatsoever. On the same server I have other > sites and everything works well so I just have no idea where else I > could look for solution. > > Does anyone have any idea what can cause such behavior? > No clue. How have you determined that that line of code is taking 20 seconds to run? Since you say you can recreate with the dev server on this machine, I would probably tackle this with pdb by putting a breakpoint before that code, stepping into the execution of CompanyFormset(request.POST, request.FILES), and then stepping through the code to narrow down where the big delay is. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: Using request.GET and having issues
2011/4/16 Karen McNeil> I have the following view set up: > > def concord(request): >searchterm = request.GET['q'] >... more stuff ... >return render_to_response('concord.html', locals()) > > With URL "http://mysite.com/concord/?q=برشه;, and template code > Your search for {{ searchterm }} returned {{ results }} > results in {{ texts.count }} texts. > I get this result on the page: >Your search for برشه returned 0 results in 8 texts. > > The search term (برشه) is being passed successfully, but there should > be 13 results, not zero. When I hard-code "searchterm = 'برشه' " into > the concord view, instead of "searchterm = request.GET['q']", the page > displays perfectly. > With this line of code: "searchterm = 'برشه' " searchterm will be a bytestring, utf-8 encoded if that is the encoding of your file. With this: searchterm = request.GET['q']" it will be unicode. Django returns unicode from the DB and request dictionaries. I notice you are explicitly encoding to utf-8 the texts you are searching before passing them into the nltk code. However you never do this for the searchterm, and I'd guess that is why the difference in results when you hard code it vs. pulling it from request.GET. Can't you pass unicode to the nltk code? If you can, I'd get rid of the explicit encoding to utf-8 of the DB content you are searching. If you really must pass it bytestrings instead of of unicode, then explicitly encoding the search term to to utf-8 as well will probably fix the problem. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.
Unexplainable delay when binding request.POST to form
Hi, I'm getting 20-30 seconds delay when trying to bind request.POST data to form. - CompanyFormset = modelformset_factory(Company, form=EditCompanyForm, extra=0) if request.method == 'POST': formset = CompanyFormset(request.POST, request.FILES) if formset.is_valid(): formset.save() --- It just happens on one server, and on this line: "formset = CompanyFormset(request.POST, request.FILES)". I have tried without request.FILES and without multipart data and always getting the same delay. I have also tried runing development server and mod_wsgi and results are the same. Delay only happens when binding request data, if I just try to save formset everything is fast as it should be. Also, on my development laptop there is no delay whatsoever. On the same server I have other sites and everything works well so I just have no idea where else I could look for solution. Does anyone have any idea what can cause such behavior? 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: Using request.GET and having issues
This doesn't appear to be a Django question. Your 'results' variable is being populated by checking the length of an nltk.text.ConcordanceIndex() instance. I'm not familiar with the nltk module, but I'm assuming you are at least a little, since you're using it. It appears that its length isn't useful in determining the count you want. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.