Re: Ajax in Django
On 08-Jul-08, at 10:20 AM, bharathi wrote: > I am creating one Django application with jquery.. > In that Jquery function am using One Ajax script.. Django code cant > taken that ajax code... this code must be put in the HEAD section of the html - so create a block 'head' in the head section of base html and put the code there in the derived template -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/code/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: common problem: set author, update date on save
Hi! > on saving a Post > wish to set created_on and updated_on You can use a date time field with auto_now_add one with and auto_now for that. http://www.djangoproject.com/documentation/model-api/#datetimefield Regards, Daniel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using validators against model fields
On Jul 8, 9:50 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > Django does not do any model field validation by default at the moment. > Admin does it using an old system (essentially, oldforms and Add- and > ChangeManipulators) that is being removed. We are adding more coherent > model field validation prior to 1.0. This is ticket #6845 and it's > actively work in progress (I reviewed it in detail over the weekend and > Honza is going to be working on the patch at the EuroPython sprint this > coming weekend). > > For now, just do the validation manually in your model's save() method. > It's not ideal, but that's the way things are for the time being. Many thanks, Malcolm. -- Ayaz Ahmed Khan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Ajax in Django
On Mon, 2008-07-07 at 21:50 -0700, bharathi wrote: > I am creating one Django application with jquery.. > In that Jquery function am using One Ajax script.. Django code cant > taken that ajax code... > > My code is: > > $(document).ready( > function () { > $("#sortme").Sortable( > { > accept : 'sortitem', > onchange : function (sorted) { > serial = $.SortSerialize('sortme'); > > $.ajax({ > url: "/sortdata", You should probably add a trailing slash here: "/sortdata/" instead of "/sortdata". Django will redirect the browser to /sortdata/ by default (see APPEND_SLASH) and your POST data will be lost. > type: "POST", > data: serial.hash, > // complete: function(){}, >success: function(feedback){ > $('#data').html(feedback); } > // error: function(){} > > }); > > } > } > ) > > > > } > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Non ForeignKey field type as
You can use the choices option in your model. http://www.djangoproject.com/documentation/model-api/#choices class Details(models.Model): ... PROJECT_TYPES = ( ('A', 'Type A'), ('B', 'Type B'), ) project_type = models.CharField(max_length=30,choices=PROJECT_TYPES) ... HTH, Daniel Am Montag, den 07.07.2008, 22:59 -0700 schrieb [EMAIL PROTECTED]: > Hello, > > I'm building my first Django project and was wanting to know how to > add a field type to the admin page. I would like the > Details.project_type field to be displayed as a select box but it's > not a foreign key, how do I go about this? > > Thanks, > > Jason > > from django.db import models > > class Project(models.Model): > client = models.CharField(max_length=30) > add_date = models.DateTimeField('date added') > class Meta: > ordering = ['-add_date'] > def __unicode__(self): > return self.client > class Admin: > fields = ( > ('Client', {'fields': ('client',)}), > ('Date Added', {'fields': ('add_date',)}), > ) > pass > > class Details(models.Model): > project = models.ForeignKey(Project) > project_type = models.CharField(max_length=30)# displayed as > > title = models.CharField(max_length=50) > blurb = models.TextField() > builder = models.CharField(max_length=50) > photography = models.CharField(max_length=100) > interior_designer = models.CharField(max_length=50) > def __unicode__(self): > return self.title > > class Image(models.Model): > name = models.CharField(max_length=30) > def __unicode__(self): > return self.name > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Inserting html into a page dynamically
Thx to both of you, I'll do it with AJAX then. I'll have to find a way to make this work anyway if the user doesn't have Javascript enabled. Bibi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
not allowing me to login to admin site
Hi! I went away for the weekend, when all was working fine, and having come back to work I have found that I cannot login to the admin site. Checked the database users passwords and they had automatically changed themselves to random strings. I changed the user password back in phpmyadmin but still cannot login to admin site. Nothing has been done to other than to turn off the computer for the weekend and turn it back on again! Help! Allison --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to force user login before do anything
Django offers @login_required to redirect user to login method. But, If the site force user to login at first before they can do something, I have to add @login_required to every views. How to solve this problem with a more elegent 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: not allowing me to login to admin site
Hi! When you change the password with phpmyadmin, did you consider that passwords are not stored in plaintext, but as salted hashes? You can try to set it to this value: sha1$3a68b$7fbea95491a9d04e3cf647d5c8e675da69e1d458 This should set your password to 'passwort' (without apostrophes). Alternatively, if you have shell access, you can use the DB API to reset the password. See: http://coderseye.com/2007/howto-reset-the-admin-password-in-django.html HTH, Daniel Am Dienstag, den 08.07.2008, 02:00 -0700 schrieb allisongardner: > Hi! I went away for the weekend, when all was working fine, and having > come back to work I have found that I cannot login to the admin site. > Checked the database users passwords and they had automatically > changed themselves to random strings. I changed the user password back > in phpmyadmin but still cannot login to admin site. Nothing has been > done to other than to turn off the computer for the weekend and turn > it back on again! > Help! > Allison > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: runserver with manage.py works but doesn't work with django-admin.py
> so it's odd that my new project works with "python manage.py > runserver" but gives me an error when i do "django-admin.py > runserver." how is this possible? Is it? Have a look inside manage.py: " try: import settings # Assumed to be in the same directory. except ImportError: import sys " It imports your settings file; django-admin.py does no such thing. Hence manage.py takes care of setting up your environment correctly for the current project such as your PYTHONPATH, and it can find all the modules (apps) in your project directory. That explains why you get an ImportError: the whatever module isn't in your PYTHONPATH. Hope that clarifies things. Evert > btw the error is below: > > Traceback (most recent call last): > File "/Library/Frameworks/Python.framework/Versions/Current/bin/ > django-admin.py", line 5, in > management.execute_from_command_line() > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/core/management/__init__.py", line 263, > in execute_from_command_line > utility.execute() > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/core/management/__init__.py", line 219, > in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/core/management/base.py", line 77, in > run_from_argv > self.execute(*args, **options.__dict__) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/core/management/base.py", line 86, in > execute > translation.activate('en-us') > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/utils/translation/__init__.py", line > 73, in activate > return real_activate(language) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/utils/translation/__init__.py", line > 43, in delayed_loader > return g['real_%s' % caller](*args, **kwargs) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/utils/translation/trans_real.py", line > 220, in activate > _active[currentThread()] = translation(language) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/utils/translation/trans_real.py", line > 209, in translation > default_translation = _fetch(settings.LANGUAGE_CODE) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/utils/translation/trans_real.py", line > 192, in _fetch > app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), > appname[p+1:]) > ImportError: No module named whatever --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to force user login before do anything
Writing a middleware is probably a good solution. You can use this one: http://superjared.com/entry/requiring-login-entire-django-powered-site/ HTH, Daniel Am Dienstag, den 08.07.2008, 02:13 -0700 schrieb [EMAIL PROTECTED]: > Django offers @login_required to redirect user to login method. > But, If the site force user to login at first before they can do > something, I have to add @login_required to every views. > How to solve this problem with a more elegent 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: not allowing me to login to admin site
Sorry just to add I am a newbie. I looked up previous questions and found: "I'm greatly enjoying this excellent project. However, I have a problem with users created through the admin web interface being able to log into the admin site. I get "Please enter a correct username and password." Even though all users have "is_active" and "is_staff" set to True. It's definitely *not* a typo/caps-lock thing. I'm using MySQL. " The answer was: ">>>from django.models.auth import users >>> u = users.create_user('username', '[EMAIL PROTECTED]', 'password') >>> u.is_staff = True >>> u.save() " I tried this from within my project folder and it gave me a traceback folder. I am not very confident with shells etc. I am using ubuntu OS and MYSQL 5.051 On Jul 8, 11:00 am, allisongardner <[EMAIL PROTECTED]> wrote: > Hi! I went away for the weekend, when all was working fine, and having > come back to work I have found that I cannot login to the admin site. > Checked the database users passwords and they had automatically > changed themselves to random strings. I changed the user password back > in phpmyadmin but still cannot login to admin site. Nothing has been > done to other than to turn off the computer for the weekend and turn > it back on again! > Help! > Allison --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: not allowing me to login to admin site
Hi Daniel, No i didn't consider salted hashes (I have never heard of them is the reason lol). I have now reset it to the hash as you suggested and I can now login in. THANK YOU!!! Will look further into problem as it does not accept any of my user logins that have been created by the admin site, even though I know i am using the correct username and password. I do have shell access as I am using my own computer. When I have worked out what to do I will look into your second suggestion. Thanks agin for quick response. MWAH!!! Allison On Jul 8, 11:19 am, Daniel Hepper <[EMAIL PROTECTED]> wrote: > Hi! > > When you change the password with phpmyadmin, did you consider that > passwords are not stored in plaintext, but as salted hashes? > > You can try to set it to this value: > sha1$3a68b$7fbea95491a9d04e3cf647d5c8e675da69e1d458 > > This should set your password to 'passwort' (without apostrophes). > Alternatively, if you have shell access, you can use the DB API to reset > the password. > > See:http://coderseye.com/2007/howto-reset-the-admin-password-in-django.html > > HTH, > Daniel > > Am Dienstag, den 08.07.2008, 02:00 -0700 schrieb allisongardner: > > > Hi! I went away for the weekend, when all was working fine, and having > > come back to work I have found that I cannot login to the admin site. > > Checked the database users passwords and they had automatically > > changed themselves to random strings. I changed the user password back > > in phpmyadmin but still cannot login to admin site. Nothing has been > > done to other than to turn off the computer for the weekend and turn > > it back on again! > > Help! > > Allison --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to create field not stored in database, but visible in admin?
How to create a field that is not stored in database, but is visible in Django newforms-admin? (I'm assuming there is a way) I would like to define a field which acts as a kind of proxy. Setting and getting value of this field actually runs some defined operation (for example executes custom SQL query) and returns it's results. This field has a related form field which is visible in Django newforms-admin among the form fields for other fields of containing model. As I'm using newforms-admin, I could add the form field to the ModelForm of my model in ModelAdmin and define custom save method for this form, which would execute a defined operation. But I want to have this functionality in two my different projects, and this approach would not be DRY. So is there a way to create such model field? Or maybe there is a better way to achieve what I want? Please help. PS. Sorry for my bad English. I'm not a native speaker. If something is not decipherable to you, just ask. Regards, -- Marek Stępniowski http://stepniowski.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: not allowing me to login to admin site
On Tue, Jul 8, 2008 at 4:33 AM, allisongardner <[EMAIL PROTECTED]> wrote: > Will look further into problem as it does not accept any of my user > logins that have been created by the admin site, even though I know i > am using the correct username and password. I do have shell access as > I am using my own computer. When I have worked out what to do I will > look into your second suggestion. Thanks agin for quick response. > MWAH!!! If you're on Django 0.96 or a checkout of the development code, there's special-case handling in the admin for creating users such that the password will be properly set, as well as a special-case editing view for changing passwords through the admin. For manually creating users from Python code, the Django User model has a manager with a special method -- create_user() -- which will handle this for you, so doing: from django.contrib.auth.models import User u = User.objects.create_user('bob', '[EMAIL PROTECTED]', 'some_password') will work. For manually editing users from Python code, the User model defines a method called 'set_password()' which also handles this for you: from django.contrib.auth.models import User u = User.objects.get(username='bob') u.set_password('some_new_password') u.save() For bulk imports, you can currently rely on some backwards-compatible hackery we do to support storing passwords as plain old MD5 hashes, by which Django will transparently "upgrade" the stored password to a (more secure) salted SHA1 hash the next time the user successfully logs in. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to create field not stored in database, but visible in admin?
On Tue, 2008-07-08 at 11:49 +0200, Marek Stępniowski wrote: > How to create a field that is not stored in database, but is visible > in Django newforms-admin? (I'm assuming there is a way) A model "field" is something that is stored in the database, by definition. If it's not stored in the database, it isn't a "field". It is just a normal Python attribute or property method. I don't know how easy it is to include those types of things in newforms-admin Admin, but that's the area you have to look in. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to force user login before do anything
If your REQUIRE_LOGIN_PATH is different in settings you can use this middleware http://www.djangosnippets.org/snippets/136/ Satheesh On Jul 8, 2:25 pm, Daniel Hepper <[EMAIL PROTECTED]> wrote: > Writing a middleware is probably a good solution. > > You can use this > one:http://superjared.com/entry/requiring-login-entire-django-powered-site/ > > HTH, > Daniel > > Am Dienstag, den 08.07.2008, 02:13 -0700 schrieb [EMAIL PROTECTED]: > > > Django offers @login_required to redirect user to login method. > > But, If the site force user to login at first before they can do > > something, I have to add @login_required to every views. > > How to solve this problem with a more elegent 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to change ordering of m2m-fields in newforms-admin?
Hello all, maybe there are some newforms-admin experts out there: What's the right way to change the ordering of ManyToMany-fields (displayed as select widgets) in newforms-admin? I need to change the ordering *without* changing the respective model class. Background: The default ordering of the contrib.auth User class was removed from trunk (see ticket #6089). But I need an ordererd user selection widget for my ManyToMany-fields relating to the User class. BTW, how can I replace the default widget for a specific field to be used in the newforms-admin form? I didnt't find any docs on this. Regards -Stephan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: determining model subclass
André, I'm assuming that you are using the Trunk version of Django because subclassing isn't supported in previous versions. Assuming that. You can either have Item be an Abstract class which does not act like a table but just a parent class containing common items. (this is not what you are trying...) Or Each sub class is a seperate model from Item (assuming this is what you want). From the documentation you should be able to do the following: items = Item.objects.all() for item in items: try: x = Item.task type = "Task" except: try: x = Item.event type = "Event" except: type = "Item" Do something pertaining to the item type I haven't tried this but according to the docs it should work You should also fill in the correct exception. I just don't know what it is. Hope it helps. Dave. On Jul 8, 2:12 am, "Andre Meyer" <[EMAIL PROTECTED]> wrote: > hi all > > is it possible to determine the subclass of a model instance? > > what i mean is this: > if you have a (n abstract) model class and two subclasses, like > > class Item(models.Model): > pass > > class Task(Item): > pass > > class Event(Item): > pass > > and you retrieve > > items = Item.objects.all() > > how can you know whether the items are either tasks or events? > > items[0].__class__ returns just . > > thanks for sharing your insights > regards > André --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Calendar of Events
I looked at the 3captus.com/download/django_calendar, but found it to be somewhat cumbersome in terms of functionality. I don't want anonymous users to create or delete calendar of events. Any more suggestions or ideas? -Mario On Jul 7, 11:29 pm, bedros <[EMAIL PROTECTED]> wrote: > I was looking for the same thing and found the following > > http://www.3captus.com/download/django_calendar > > have not tried it yet, but there's a demo on the same website. > > On Jul 7, 6:34 pm, Mario <[EMAIL PROTECTED]> wrote: > > > Thank you. I managed to install the eventcalendarmodel in Django. I > > can add the events and event categories and display using the default > > templates. > > > My next question is ~ how do I display thecalendarassuming I'm using > > the default templatetag that came with the application? I added {% > > load load event_tags %} in my base.html. What am I missing? I want to > > display thecalendari.e. July 2008 > > > Thank you for your patience. > > > Respectfully yours, > > > Goober > > > On Jul 7, 8:15 pm, Rob Hudson <[EMAIL PROTECTED]> wrote: > > > > Google is your friend:http://code.google.com/p/django-event-calendar/ > > > > On Jul 7, 2:13 pm, Mario <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > > > I’m a NOOB and I was wondering if there are any calendars of event > > > > model that will allow a user to click on a specific date with the > > > > associated listing of events. Any suggestions or recommendations are > > > > appreciated. > > > > > Thank you. > > > > Goober --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin interface using my views
I'm getting this error when trying to view my admin interface ... In template /usr/lib/python2.5/site-packages/django/contrib/admin/ templates/admin/base.html, error at line 28 Caught an exception while rendering: Tried showSides in module teamsheet.sheets.views. Error was: 'module' object has no attribute 'showSides' "teamsheet.sheets.views" being my own views. from settings.py: TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/ django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. '/Users/stuartgrimshaw/Project/teamsheet/templates' ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'teamsheet.sheets', ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin interface using my views
On Tue, 2008-07-08 at 06:22 -0700, Stuart Grimshaw wrote: > I'm getting this error when trying to view my admin interface ... > > In template /usr/lib/python2.5/site-packages/django/contrib/admin/ > templates/admin/base.html, error at line 28 > Caught an exception while rendering: Tried showSides in module > teamsheet.sheets.views. Error was: 'module' object has no attribute > 'showSides' As the error says, you are trying to use the "showSides" variable or function from some module, but it doesn't exist in that module. So search through your code for where you are calling showSides and find the case where it is being called incorrectly. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Sort a list of objects by an attribute of the objects
Ok i have a list of form fields, i want to sort the list by the ".label" of the fields. I have tried a many different ways but i cant seem to make this work. I know this is more of a python question but this is the best resource I've found for these questions. Can anybody throw an example up for 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: string indices must be integers error in admin - don't know where to start debugging
Problem solved. Just need to copy in my local version of Django On Jul 7, 6:29 pm, Jon Loyens <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I've got a problem and I don't even know where to start debugging > it... there seems to be a difference between the way my app is > behaving between my local environment and my deployment environment. > Hopefully you guys can give me some idea where to start. > > I've written a small PR application that along with a story, publishes > pictures and other files. I've written models that look like this > (this is all written on the trunk): > > class Story(models.Model): > title = models.CharField(max_length=100) > date = models.DateField() > slug = models.SlugField() > published = models.BooleanField() > body = models.TextField() > > class Meta: > verbose_name_plural = "stories" > ordering = ['-date'] > pass > > def __str__(self): > return self.title.encode("utf-8") > > class Admin: > list_display = ('title','date','slug',) > pass > > class Picture(models.Model): > image = models.ImageField(upload_to="photos") > date = models.DateField() > title = models.CharField(max_length=100, core=True) > caption = models.CharField(max_length=100, blank=True) > story = models.ForeignKey(Story, edit_inline=models.STACKED) > > def __str__(self): > return self.title.encode("utf-8") > > class Meta: > ordering = ['-date'] > pass > > class Downloads(models.Model): > media = models.FileField(upload_to="downloads") > date = models.DateField() > title = models.CharField(max_length=100, core=True) > story = models.ForeignKey(Story, edit_inline=models.STACKED) > > def __str__(self): > return self.title.encode("utf-8") > > class Meta: > verbose_name_plural = "downloads" > ordering = ['-date'] > pass > > This works great locally on my machine. However, when I deploy on > WebFaction (again using a django instance built from the trunk), > everything appears to be fine until I edit a Story object in the Admin > UI. When I try and save any edits (no matter what field I edit), I > get this error: > > Traceback: > File "/home/myaccount/webapps/mysite_site/lib/python2.5/django/core/ > handlers/base.py" in get_response > 82. response = callback(request, *callback_args, > **callback_kwargs) > File "/home/myaccount/webapps/mysite_site/lib/python2.5/django/contrib/ > admin/views/decorators.py" in _checklogin > 62. return view_func(request, *args, **kwargs) > File "/home/myaccount/webapps/mysite_site/lib/python2.5/django/views/ > decorators/cache.py" in _wrapped_view_func > 44. response = view_func(request, *args, **kwargs) > File "/home/myaccount/webapps/mysite_site/lib/python2.5/django/contrib/ > admin/views/main.py" in change_stage > 338. new_object = manipulator.save(new_data) > File "/home/myaccount/webapps/mysite_site/lib/python2.5/django/db/ > models/manipulators.py" in save > 207. f.save_file(rel_new_data, > new_rel_obj, self.change and old_rel_obj or None, old_rel_obj is not > None, rel=True) > File "/home/myaccount/webapps/mysite_site/lib/python2.5/django/db/ > models/fields/__init__.py" in save_file > 933. FileField.save_file(self, new_data, new_object, > original_object, change, rel, save) > File "/home/myaccount/webapps/mysite_site/lib/python2.5/django/db/ > models/fields/__init__.py" in save_file > 847. file_name = file['filename'] > > Exception Type: TypeError at /admin/pr/story/1/ > Exception Value:stringindicesmust be integers --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Sort a list of objects by an attribute of the objects
Resolved. Answer for those interested: def sort_by_attr(seq, attr): import operator intermed = map(None, map(getattr, seq, (attr,)*len(seq)), xrange(len(seq)), seq) intermed.sort() return map(operator.getitem, intermed, (-1,) * len(intermed)) def sort_by_attr_inplace(lst, attr): lst[:] = sort_by_attr(lst, attr) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin interface using my views
On Jul 8, 2:40 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-07-08 at 06:22 -0700, Stuart Grimshaw wrote: > > I'm getting this error when trying to view my admin interface ... > > > In template /usr/lib/python2.5/site-packages/django/contrib/admin/ > > templates/admin/base.html, error at line 28 > > Caught an exception while rendering: Tried showSides in module > > teamsheet.sheets.views. Error was: 'module' object has no attribute > > 'showSides' > > As the error says, you are trying to use the "showSides" variable or > function from some module, but it doesn't exist in that module. So > search through your code for where you are calling showSides and find > the case where it is being called incorrectly. aha! It was being called in one of my URL files, but the view is no longer valid, or linked to so normal use of the site didn't trigger that error. Thanks Malcom. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "ColorField"?
You'll want to check out django.db.models.fields, django.db.models.fields.subclassing, and django.core.validators as starting points for creating a new Field type with a custom validator. In addition, there's a js attribute for class Admin you can use to bring in the necessary JavaScript into admin (http://www.djangoproject.com/documentation/model-api/#js), or you can look into newforms-admin branch (soon to be trunk) for more options on custom admin pages. On Mon, Jul 7, 2008 at 11:28 PM, Leaf <[EMAIL PROTECTED]> wrote: > > Also note - when I say this, I'm talking about something that can plug > in to the admin interface. Just clearing that up. > > Regards, > Leaf > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms-admin, forms.ModelForm, formtools.preview
On Mon, Jul 7, 2008 at 6:22 AM, d-rave <[EMAIL PROTECTED]> wrote: > > Has anyone successfully got formtools.preview working with > forms.ModelForm so that the form fields are populated from the model. > > If so, do you have an example?? Dave, I'm not familiar with formtools but if all you want to do is prepopulate a form then you can use the initial={} keyword arg. This probably doesn't help but ... you could do this in your view if you want: form = Form(initial={'user':u, ...}) http://www.djangoproject.com/documentation/newforms/#dynamic-initial-values -- Milan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
AutoImageField From Custom upload and filters
does any know why the auto_rename loses the file name but not the extension? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms-admin, forms.ModelForm, formtools.preview
On Tue, Jul 8, 2008 at 10:00 AM, Milan Andric <[EMAIL PROTECTED]> wrote: > On Mon, Jul 7, 2008 at 6:22 AM, d-rave <[EMAIL PROTECTED]> wrote: >> >> Has anyone successfully got formtools.preview working with >> forms.ModelForm so that the form fields are populated from the model. >> >> If so, do you have an example?? > > Dave, I'm not familiar with formtools but if all you want to do is > prepopulate a form then you can use the initial={} keyword arg. This > probably doesn't help but ... you could do this in your view if you > want: > > form = Form(initial={'user':u, ...}) > > http://www.djangoproject.com/documentation/newforms/#dynamic-initial-values > Another trick is to use model_to_dict to pass in initial values : from django.newforms.models import model_to_dict ... f = Form( initial=model_to_dict(obj) ) -- Milan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to use combined indices (esp. in fulltext queries)?
Hi, I would need to do a query like SELECT * FROM mytable WHERE match (a) against("+AAA" in boolean mode) and match (b against("+BBB" in boolean mode) and match (a,b) against("+AAA +BBB" in boolean mode) If I would omit the last line (which seems to be redundant) I could do this easily with the Django framework by s.filter(a__search='AAA', b__search='BBB') However it turned out that doing the query with the last line is far more efficient for MySQL. By querying (a,b) it can query a combined index which returns only very few rows which then are combined with the other two AND statements. If I omit the combined index, the temp table (for doing the AND statement) is far bigger. The speed gain is about factor 100 - sometimes even more (yes: my tables are quiet large and it is noticeable) How would I do this in Django? Thanks for your help. Tobias. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: AutoImageField From Custom upload and filters
On Tue, Jul 8, 2008 at 10:02 AM, moos3 <[EMAIL PROTECTED]> wrote: > > does any know why the auto_rename loses the file name but not the > extension? Not familiar with auto_rename but maybe if you show a little code and explain what you are trying to do then someone can help. -- Milan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
User is in models.py
Hello all! Is it possible to find out current user id form "myapp/models.py" file so i can customize the way it is saved from the admin interface? I'd like to do something like class Myapp(models.Model): ... ... def save(self): if user.is_superuser: dosomethinghere() super(Myapp, self).save() I've noticed that django saves an history of the changes occurred to a any row in myapp table, so i think it should be easy to find out current user. Thanks in advance! Haku! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
integer form fields
I need to limit an integerfield form type to 6 digits. I've tried max_length and max_digits but those don't work. Is there anything that does that or will I need to do a custom validation? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: AutoImageField From Custom upload and filters
http://dpaste.com/61358/ here is the code. here is also the wiki page http://code.djangoproject.com/wiki/CustomUploadAndFilters some reason instance isn't getting set for some reason. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: integer form fields
On Tue, Jul 8, 2008 at 4:28 PM, Bobby Roberts <[EMAIL PROTECTED]> wrote: > > I need to limit an integerfield form type to 6 digits. I've tried > max_length and max_digits but those don't work. Is there anything > that does that or will I need to do a custom validation? How about max_value=99? Regards, Jonathan. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Sort a list of objects by an attribute of the objects
This is a bit more complicated than you need. This will work: def sort_by_attr_inplace(seq, attr): import operator seq.sort(key=operator.attrgetter(attr)) --Ned. http://nedbatchelder.com joshuajonah wrote: > Resolved. > > Answer for those interested: > > def sort_by_attr(seq, attr): > import operator > intermed = map(None, map(getattr, seq, (attr,)*len(seq)), > xrange(len(seq)), seq) > intermed.sort() > return map(operator.getitem, intermed, (-1,) * > len(intermed)) > > def sort_by_attr_inplace(lst, attr): > lst[:] = sort_by_attr(lst, attr) > > > > -- Ned Batchelder, http://nedbatchelder.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
elusive Post error
I was wondering if anyone else has ever run into this problem... When filling out a form, I click submit and get a POST error claiming that the page does not support POST. However, if I refresh the error page, the request goes through, and all is happy. I don't have much experience with web applications, so I'm not sure where to start here. We're running on Apache and using SSL for authentication, but I disabled SSL and the problem persists. Here's my settings file anyway... any ideas? -Adam # Django settings for ProjectProfiler project. import posix # for getuid import pwd# for getpwuid DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', '[EMAIL PROTECTED]'), ) MANAGERS = ADMINS DATABASE_ENGINE = 'mysql'# 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. # Check whether to use the test or production version of the DB if (pwd.getpwuid(posix.getuid())[0] == "imageweb") : DATABASE_NAME = 'projectprofiler'# Or path to database file if using sqlite3. else : DATABASE_NAME = 'projectprofilertest'# Or path to database file if using sqlite3. DATABASE_USER = 'cpuser' # Not used with sqlite3. DATABASE_PASSWORD = 'cPus3r' # Not used with sqlite3. DATABASE_HOST = 'imgdb01.broad.mit.edu' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. TIME_ZONE = 'America/New_York' LANGUAGE_CODE = 'en-us' SITE_ID = 1 USE_I18N = True MEDIA_ROOT = '/home/radon01/afraser/projectprofiler/trunk/ projectprofiler/media/' MEDIA_URL = 'http://127.0.0.1:8000/projectprofiler/media/' ADMIN_MEDIA_PREFIX = '/projectprofiler/media/admin/' SECRET_KEY = '&[EMAIL PROTECTED]&a886+2(2w9fu$6=-' TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', # 'django.template.loaders.eggs.load_template_source', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', #'django.contrib.auth.middleware.AuthenticationMiddleware', 'projectprofiler.sslauth.middleware.SSLAuthMiddleware', 'django.middleware.doc.XViewMiddleware', 'projectprofiler.middleware.threadlocals.ThreadLocals', ) ROOT_URLCONF = 'projectprofiler.urls' TEMPLATE_DIRS = ( '/home/radon01/afraser/projectprofiler/trunk/projectprofiler/ templates', '/imaging/analysis/People/imageweb/projectprofiler/trunk/ projectprofiler/templates', '/Users/ljosa/research/projectprofiler/projectprofiler/trunk/ projectprofiler/templates', ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', #'django.contrib.sites', 'projectprofiler.sslauth', 'projectprofiler.projects', 'django.contrib.admin', ) AUTHENTICATION_BACKENDS = ( 'projectprofiler.sslauth.backends.SSLAuthBackend', #'django.contrib.auth.backends.ModelBackend', ) def myusernamegen(ssl_info): import re return re.sub('@mit.edu', '', ssl_info.subject_email) SSLAUTH_CREATE_USER_CALLBACK = myusernamegen SSLAUTH_CREATE_USER = True --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Markup languages vs HTML
Hi, I'm working on some project, a part of which is a small blog app. All the blog posts are saved as HTML (using TinyMCE in admin). I was wondering, after reading some stuff about Markdown, what are pros and cons of each method, ie. saving posts with some markup language vs. html. I must admit, that I feel a bit uncomfortable saving html to the database - it just doesn't seem right to me. So, what is your opinion on this matter? Thanks, Matic Žgur --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Calculating on generic view
Hi there, im very new at Django, and i have a little problem. Is there a way to do some calculation on generic views? Example: Ich have a table in the db with the columns "distance" and "time", and i want to display an html-table with "distance", "time" and "km/h" for each row. How can i calculate this "km/h"? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Grouping Items In Multiple Categories
Does anyone know of an elegant way in Django to group database items under 2 categories. For example I have a database model that contains the following information: State Committee_Type Committee When I send it out to the template, I need to be able to group each committee under its type and state so that it looks something like this: State 1: Committee_Type1: Committee1 Committee2 Committee_Type2: Committee1 Committee2 State 2: Committee_Type1: Committee1 Committee2 Committee_Type2: Committee1 Committee2 etc... I looked at the regroup tag but I can only get it to group the items by a single category, any help would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
one to one symmetric relationship
Hello, Thanks for your answer Malcom. My mistake was to suppose that one to one relationships were symmetric. Do you have an idea on how to design a symmetric one to one relationship ? I tried with ForeignKey(unique=True) but it is not symmetric. I even tried ManyToManyField(unique=True), which is symmetric but not really unique in an object point of view. It is unique in a DB point of view. We can add (A,B) and (C,A) tuples in the m2m table, which creates multiple relationships A-B and A-C. Is it possible with existing fields ? Regards, Aldo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Calculating on generic view
El Tue, 8 Jul 2008 09:15:36 -0700 (PDT) rocco_s <[EMAIL PROTECTED]> escribió: > > Hi there, > > im very new at Django, and i have a little problem. > > Is there a way to do some calculation on generic views? > > Example: Ich have a table in the db with the columns "distance" and > "time", and i want to display an html-table with "distance", "time" > and "km/h" for each row. > How can i calculate this "km/h"? > > > r. > read this: http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-generic-views/ especially the "Getting more out of a generic view" part. Hope it helps. Hope it helps. -- P.U. Gonzalo Delgado <[EMAIL PROTECTED]> http://djangopeople.net/gonzalo/ pgpot6SShJfO3.pgp Description: PGP signature
Re: Grouping Items In Multiple Categories
Hi Josh, Have you tried passing a tuple with the two columns to the group_by method ? Cheers. -- Rui On Tue, Jul 8, 2008 at 1:25 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Does anyone know of an elegant way in Django to group database items > under 2 categories. > > For example I have a database model that contains the following > information: > > State > Committee_Type > Committee > > When I send it out to the template, I need to be able to group each > committee under its type and state so that it looks something like > this: > > State 1: > Committee_Type1: > Committee1 > Committee2 > Committee_Type2: > Committee1 > Committee2 > > State 2: > Committee_Type1: > Committee1 > Committee2 > Committee_Type2: > Committee1 > Committee2 > > etc... > > I looked at the regroup tag but I can only get it to group the items > by a single category, any help would be appreciated. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: What's the best way to simulate a request?
Andrew wrote: > Here's the situation: > > I'm creating an RESTful internal API as an app in our project. Our > 'main' app (we'll call it main) is a client of the API app. Since > we're building the API piece by piece as we use it, the emphasis on > all of this is simple simple simple -- with our eye on eventually > opening up pieces of the API to the public. > > The general flow looks like: > request => main app handling => API client => API logic. > > Because right now both of the apps live in the same project and are > being served from the same boxes (and the API won't be running on a > separate machine for a while), I figured, hey, why not just fake an > HttpRequest from the main app logic and pass it over to API? That way, > we don't need to worry about exposing the internal URLs, we don't need > to worry about authentication right now, it'll be simple. > > Right now the API client I've written takes an HTTP method, path, and > params, uses resolve(path, api.urls) to get the view, and then calls > the view using a fake HttpRequest that I populate myself. > > The one problem is that I'm finding it much harder to fake the > HttpRequests than I thought -- namely because the RESTful handlers on > the API side are expecting things like request._get_post_and_files() > to be present. > > So, my thoughts: > a) Continue using the lightweight API "client" I've written, but > instead of building a HttpRequest, fake a WSGIRequest instead (with > the _minimum_ data needed) > b) Patch the django test client to deal with PUT and DELETE and use > that as our API client > c) Import the API urls.py into the main urls.py and call the API > methods by generating actual HTTP requests > > I'm not crazy about c) since it requires more infrastructure work now. > > Any thoughts? Yeah, give more than lip service to "simple simple simple". You say that then outline how you are reimplementing HTTP because you don't want to be "exposing the internal URLs" yet. I suggest spending an hour, a day learning about how your webserver(s) handle auth and start using it. My $.02US (only about .01 at today's rates) Baring that, option B is best since the code will at least be useful for tests. Where as the other options' code become mostly worthless once you start using real requests. -- Norman J. Harman Jr. Senior Web Specialist, Austin American-Statesman ___ You've got fun! Check out Austin360.com for all the entertainment info you need to live it up in the big city! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Markup languages vs HTML
Hi Matic, I really think that html should not be saved on your database. Markup languages are more "human readable" and can be easily converted to HTML, if needed. And really, it just don´t look right :) Cheers and good luck. -- Rui --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Grouping Items In Multiple Categories
On Tue, Jul 8, 2008 at 11:25 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Does anyone know of an elegant way in Django to group database items > under 2 categories. Don't know about elegant, but something like this would work: {% regroup committees by state as committee_state_list %} {% for committee_state in committee_state_list %} {{ committee_state.grouper }} {% regroup committee_state.list by committee_type as committee_type_list %} {% for committee_type in committee_type_list %} {{ committee_type.grouper }} {% for committee in committee_type.list %} {{ committee.name }} {% endfor %} {% endfor %} {% endfor %} Arien --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ProgrammingError: (2014, "Commands out of sync; you can't run this command now")
In a production site, all of a sudden while trying to edit the site via the admin interface I get: ProgrammingError: (2014, "Commands out of sync; you can't run this command now") This is when trying to access the record list: "/admin/core/pagina/" This is only while trying to edit this one specific model ('pagina'), I can edit the others without errors. I dumped the database to my development server, and I get the same error. It was working fine right before importing the DB from the production server, so I'm thinking there's a problem in the actual DB. I ran Optimize, Check and Repair on the DB in MySQL Administrator. No dice. I haven't updated or changed anything on either server. Development's running XP, production Linux. Full traceback: Traceback (most recent call last): File "C:\django\djtrunk\django\core\servers\basehttp.py", line 277, in run self.result = application(self.environ, self.start_response) File "C:\django\djtrunk\django\core\servers\basehttp.py", line 631, in __call__ return self.application(environ, start_response) File "C:\django\djtrunk\django\core\handlers\wsgi.py", line 205, in __call__ response = self.get_response(request) File "C:\django\djtrunk\django\core\handlers\base.py", line 117, in get_response receivers = dispatcher.send(signal=signals.got_request_exception, request=request) File "C:\django\djtrunk\django\dispatch\dispatcher.py", line 360, in send **named File "C:\django\djtrunk\django\dispatch\robustapply.py", line 47, in robustApply return receiver(*arguments, **named) File "C:\django\djtrunk\django\db\__init__.py", line 73, in _rollback_on_exception transaction.rollback_unless_managed() File "C:\django\djtrunk\django\db\transaction.py", line 149, in rollback_unless_managed connection._rollback() File "C:\django\djtrunk\django\db\backends\mysql\base.py", line 195, in _rollback BaseDatabaseWrapper._rollback(self) File "C:\django\djtrunk\django\db\backends\__init__.py", line 24, in _rollback return self.connection.rollback() ProgrammingError: (2014, "Commands out of sync; you can't run this command now") --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to create field not stored in database, but visible in admin?
Marek Stępniowski wrote: > How to create a field that is not stored in database, but is visible > in Django newforms-admin? (I'm assuming there is a way) > > I would like to define a field which acts as a kind of proxy. Setting > and getting value of this field actually runs some defined operation > (for example executes custom SQL query) and returns it's results. This > field has a related form field which is visible in Django > newforms-admin among the form fields for other fields of containing > model. Nothing requires there to be a 1-to-1 mapping of form to model. In fact I've made a forms that have no model at all. > As I'm using newforms-admin, I could add the form field to the > ModelForm of my model in ModelAdmin and define custom save method for > this form, which would execute a defined operation. But I want to have > this functionality in two my different projects, and this approach > would not be DRY. Put functionality in base class(es) and or library that both projects inherit/use. I would be wary of putting functionality other than data collection/validation/munging into a form. "save" sounds like it needs to be in a Model or Manager. > So is there a way to create such model field? Or maybe there is a > better way to achieve what I want? Please help. Know about Python properties? http://www.python.org/download/releases/2.2.3/descrintro/#property They are exactly what I'd use to implement "Setting and getting value of this field actually runs some defined operation" -- Norman J. Harman Jr. Senior Web Specialist, Austin American-Statesman ___ You've got fun! Check out Austin360.com for all the entertainment info you need to live it up in the big city! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Markup languages vs HTML
Matic Žgur wrote: > Hi, > > I'm working on some project, a part of which is a small blog app. All > the blog posts are saved as HTML (using TinyMCE in admin). I was > wondering, after reading some stuff about Markdown, what are pros and > cons of each method, ie. saving posts with some markup language vs. > html. I must admit, that I feel a bit uncomfortable saving html to the > database - it just doesn't seem right to me. So, what is your opinion > on this matter? I often will create two(three) fields. body_markup -> "source" text in markup body_rendered -> body_markup rendered to html [markup_style] -> optional choice field that defines what markup body_markup is in Edit body_markup. Display body_rendered. Render body_markup to body_rendered on save(). body_rendered is probably a pre-optimization. But, I use it anyway. Could use the cache system for something similar, your needs probably vary. markup is good for sophisticated / power users / niches where markup is expected (e.g. wikis) TinyMCE / js editor is good for the masses. -- Norman J. Harman Jr. Senior Web Specialist, Austin American-Statesman ___ You've got fun! Check out Austin360.com for all the entertainment info you need to live it up in the big city! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Grouping Items In Multiple Categories
Thanks Arien, this was what I was looking for, I just couldn't figure out what the syntax needed to be, they really should add this example to the Django documentation. On Jul 8, 1:30 pm, Arien <[EMAIL PROTECTED]> wrote: > On Tue, Jul 8, 2008 at 11:25 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Does anyone know of an elegant way in Django to group database items > > under 2 categories. > > Don't know about elegant, but something like this would work: > > {% regroup committees by state as committee_state_list %} > {% for committee_state in committee_state_list %} > {{ committee_state.grouper }} > {% regroup committee_state.list by committee_type as committee_type_list %} > {% for committee_type in committee_type_list %} > {{ committee_type.grouper }} > {% for committee in committee_type.list %} > {{ committee.name }} > {% endfor %} > {% endfor %} > {% endfor %} > > Arien --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: User is in models.py
You have to pass request.user from some view to the apropiate save method. views.py: def save_human(reqiest): # do some stuff human.save(request.user) models.py: class Human(Model): # ... def save(self, user): # do something with user # may be # self.user = user super(Human, self).save() Greets! Juanjo -- mi blog: http://www.juanjoconti.com.ar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
connection.queries - show improper SQL?
When I look at generated sql from connection.queries, it doesn't show any quotes around strings. For example: >>> from django.db import connection >>> from django.contrib.auth.models import User >>> User.objects.filter(username="bob") [] >>> connection.queries[-1] {'time': '0.000', 'sql': u'SELECT `auth_user`.`id`, `auth_user`.`username`, `auth_user`.`first_name`, `auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`, `auth_user`.`is_active`, `auth_user`.`is_superuser`, `auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user` WHERE `auth_user`.`username` = bob ORDER BY `auth_user`.`username` ASC'} >>> As one would imagine, when I execute: mysql> SELECT `auth_user`.`id`, `auth_user`.`username`, `auth_user`.`first_name`, `auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`, `auth_user`.`is_active`, `auth_user`.`is_superuser`, `auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user` WHERE `auth_user`.`username` = bob ORDER BY `auth_user`.`username` ASC; It complains with "Unknown column 'bob' in 'where clause'". It's obvious how I would change that code to execute properly, but I'd like to know exactly what query django is building. (for example you can get away with passing a number into a query against a varchar, and that can affect the efficiency of complex queries) Is this Django-MySQL 5.x specific? Is this a full-on django bug? Regards. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
running development server
hey all, i'm trying to open up my development server to a couple of our other staff members to help me start testing next week. to open up the development server to others on our network, do i set runserver to my IP or the network's IP? chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: running development server
python manage.py runserver IP:PORT I hope that helps. On Jul 8, 2:30 pm, [EMAIL PROTECTED] wrote: > hey all, > > i'm trying to open up my development server to a couple of our other > staff members to help me start testing next week. to open up the > development server to others on our network, do i set runserver to my > IP or the network's IP? > > chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: running development server
Also you could use mod_python or fastcgi so you can see how its going to act when deployed. On Jul 8, 2:30 pm, [EMAIL PROTECTED] wrote: > hey all, > > i'm trying to open up my development server to a couple of our other > staff members to help me start testing next week. to open up the > development server to others on our network, do i set runserver to my > IP or the network's IP? > > chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: running development server
thnx, i got that, but the IP is that my machine's IP on the network, or the network's IP? i tried it with mine, made sure the port 8000 was open and did python manage.py runserver IP:8000 and got the server to initially start, but immediately after it displays the "Quit the server with CTRL-BREAK" line I get "Error: (10049, "Can't assign requested address")" error. if anyone has had this error, please let me know and i can work with our network admin to fix it. the server runs fine when it's just on my machine at 127.0.0.1:8000. chris On Jul 8, 2:33 pm, moos3 <[EMAIL PROTECTED]> wrote: > Also you could use mod_python or fastcgi so you can see how its going > to act when deployed. > > On Jul 8, 2:30 pm, [EMAIL PROTECTED] wrote: > > > hey all, > > > i'm trying to open up my development server to a couple of our other > > staff members to help me start testing next week. to open up the > > development server to others on our network, do i set runserver to my > > IP or the network's IP? > > > chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Markup languages vs HTML
The important consideration is what is the best representation for your data? Since you are talking about user-edited content, you need to think about the user experience, and what data format is best for your users. The database concerns don't really matter after that. If you users need or expect to edit HTML, then you should offer that and store the HTML in the database. Don't be distracted by the fact that HTML is often generated from structured data: it can also be a perfectly reasonable data storage format itself. On the other hand, if your users would be more comfortable editing Markdown, then use that. The user experience concerns are far more important, and will dictate the data storage. --Ned. Matic Žgur wrote: > Hi, > > I'm working on some project, a part of which is a small blog app. All > the blog posts are saved as HTML (using TinyMCE in admin). I was > wondering, after reading some stuff about Markdown, what are pros and > cons of each method, ie. saving posts with some markup language vs. > html. I must admit, that I feel a bit uncomfortable saving html to the > database - it just doesn't seem right to me. So, what is your opinion > on this matter? > > Thanks, > Matic Žgur > > > > > -- Ned Batchelder, http://nedbatchelder.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Markup languages vs HTML
The important consideration is what is the best representation for your data? Since you are talking about user-edited content, you need to think about the user experience, and what data format is best for your users. The database concerns don't really matter after that. If you users need or expect to edit HTML, then you should offer that and store the HTML in the database. Don't be distracted by the fact that HTML is often generated from structured data: it can also be a perfectly reasonable data storage format itself. On the other hand, if your users would be more comfortable editing Markdown, then use that. The user experience concerns are far more important, and will dictate the data storage. --Ned. http://nedbatchelder.com Matic Žgur wrote: > Hi, > > I'm working on some project, a part of which is a small blog app. All > the blog posts are saved as HTML (using TinyMCE in admin). I was > wondering, after reading some stuff about Markdown, what are pros and > cons of each method, ie. saving posts with some markup language vs. > html. I must admit, that I feel a bit uncomfortable saving html to the > database - it just doesn't seem right to me. So, what is your opinion > on this matter? > > Thanks, > Matic Žgur > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: connection.queries - show improper SQL?
While you don't have an exception if using ORM so it isn't bug it is feature. On Jul 8, 10:07 pm, Peter <[EMAIL PROTECTED]> wrote: > When I look at generated sql from connection.queries, it doesn't show > any quotes around strings. > > For example:>>> from django.db import connection > >>> from django.contrib.auth.models import User > >>> User.objects.filter(username="bob") > [] > >>> connection.queries[-1] > > {'time': '0.000', 'sql': u'SELECT `auth_user`.`id`, > `auth_user`.`username`, `auth_user`.`first_name`, > `auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`, > `auth_user`.`is_staff`, `auth_user`.`is_active`, > `auth_user`.`is_superuser`, `auth_user`.`last_login`, > `auth_user`.`date_joined` FROM `auth_user` WHERE > `auth_user`.`username` = bob ORDER BY `auth_user`.`username` ASC'} > > > > As one would imagine, when I execute: > > mysql> SELECT `auth_user`.`id`, `auth_user`.`username`, > `auth_user`.`first_name`, `auth_user`.`last_name`, > `auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`, > `auth_user`.`is_active`, `auth_user`.`is_superuser`, > `auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user` > WHERE `auth_user`.`username` = bob ORDER BY `auth_user`.`username` > ASC; > > It complains with "Unknown column 'bob' in 'where clause'". > > It's obvious how I would change that code to execute properly, but I'd > like to know exactly what query django is building. > (for example you can get away with passing a number into a query > against a varchar, and that can affect the efficiency of complex > queries) > > Is this Django-MySQL 5.x specific? Is this a full-on django bug? > > Regards. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
newforms: how to make input widgets smaller
Hallöchen! I use newforms.ModelForm to get a form from one of my models. However, the HTML fields are all too wide. Okay, I could re-define all fields that need narrower s like class SixChamberChannelForm(ModelForm): gas = forms.CharField(widget=forms.TextInput(attrs={"size": "10"})) diluted_in = forms.CharField(widget=forms.TextInput(attrs={"size": "10"})) class Meta: model = models.SixChamberChannel however, then I lose the information contained in max_length and help_text in the model. How can I just put a "size" attribute to the fields? Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Transitioning old webapp to Django
Hi, I'm moving an old PHP & MySQL3 application to Django SVN with mysql5, and I've run into a problem. The passwords for the old user accounts were stored in the database and used the mysql PASSWORD() function for hashing. MySql 5 changed the hashing function, but kept the old hashing function under OLD_PASSWORD() for compatibility. I would like to have django use the OLD_PASSWORD() function for the user's first login, and then recreate the hash using the current PASSWORD() function. Does anyone know of a good way to have Django use the OLD_PASSWORD() function? It would be nice to use a modified version of contrib.auth, but I'm not sure if its possible. Thanks, William --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Issue with django-tagging 0.3 (svn) with models definition
Nicolas Steinmetz wrote: > > Hello, > > Despite I read a lot of time the overview.txt on the django tagging svn > repository, I still can't stand how to use it at my model's level. I'm > quite new to python and may miss some elements. > > When diving into the register part, it says it requiers a field for tag > which is supposed to be "tags". But what kind of type is this tag supposed > to be ? a TagField() ? > > I came down to this kind of things which looks not the optimum for me (at > least at validate & runserver step, it stops shouting...): > > from django.db import models > import tagging > from tagging.models import Tag > from tagging.fields import TagField > > # Create your models here. > class Links(models.Model): > title = models.CharField(max_length=80) > description = models.TextField() > url = models.URLField() > tags = TagField() > > class Admin: > list_display = ('title', 'description', 'url', 'tags',) > list_filter = ['title', 'tags'] > search_fields = ['title','tags',] > > class Meta: > verbose_name = "Lien" > verbose_name_plural = "Liens" > > tagging.register(Links) > > But when I try to save a link, I got : > > IntegrityError at /admin/links/links/add/ > tagging_taggeditem.object_id may not be NULL > > What did I miss ? > > Regards, > Nicolas > Nobody is in a similar case than mine ? -- Nicolas Steinmetz http://www.steinmetz.fr/ http://www.unelectronlibre.info/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: determining model subclass
Dave's method is what I also use. I was hoping someone would come up with an easier way, but I think it is a limitation of the way the database tables are created in multitable inheritance. David On Jul 8, 6:13 am, Chester <[EMAIL PROTECTED]> wrote: > André, > I'm assuming that you are using the Trunk version of Django because > subclassing isn't supported in previous versions. > > Assuming that. > > You can either have Item be an Abstract class which does not act like > a table but just a parent class containing common items. (this is not > what you are trying...) > > Or > > Each sub class is a seperate model from Item (assuming this is what > you want). From the documentation you should be able to do the > following: > > items = Item.objects.all() > for item in items: > try: > x = Item.task > type = "Task" > except: > try: >x = Item.event >type = "Event" > except: >type = "Item" > Do something pertaining to the item type > > I haven't tried this but according to the docs it should work You > should also fill in the correct exception. I just don't know what it > is. > > Hope it helps. > > Dave. > > On Jul 8, 2:12 am, "Andre Meyer" <[EMAIL PROTECTED]> wrote: > > > hi all > > > is it possible to determine the subclass of a model instance? > > > what i mean is this: > > if you have a (n abstract) model class and two subclasses, like > > > class Item(models.Model): > > pass > > > class Task(Item): > > pass > > > class Event(Item): > > pass > > > and you retrieve > > > items = Item.objects.all() > > > how can you know whether the items are either tasks or events? > > > items[0].__class__ returns just . > > > thanks for sharing your insights > > regards > > André --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: connection.queries - show improper SQL?
2008/7/8 Peter <[EMAIL PROTECTED]>: > > When I look at generated sql from connection.queries, it doesn't show > any quotes around strings. > > For example: from django.db import connection from django.contrib.auth.models import User User.objects.filter(username="bob") > [] connection.queries[-1] > {'time': '0.000', 'sql': u'SELECT `auth_user`.`id`, > `auth_user`.`username`, `auth_user`.`first_name`, > `auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`, > `auth_user`.`is_staff`, `auth_user`.`is_active`, > `auth_user`.`is_superuser`, `auth_user`.`last_login`, > `auth_user`.`date_joined` FROM `auth_user` WHERE > `auth_user`.`username` = bob ORDER BY `auth_user`.`username` ASC'} > > As one would imagine, when I execute: > > mysql> SELECT `auth_user`.`id`, `auth_user`.`username`, > `auth_user`.`first_name`, `auth_user`.`last_name`, > `auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`, > `auth_user`.`is_active`, `auth_user`.`is_superuser`, > `auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user` > WHERE `auth_user`.`username` = bob ORDER BY `auth_user`.`username` > ASC; > > It complains with "Unknown column 'bob' in 'where clause'". > > It's obvious how I would change that code to execute properly, but I'd > like to know exactly what query django is building. > (for example you can get away with passing a number into a query > against a varchar, and that can affect the efficiency of complex > queries) > > Is this Django-MySQL 5.x specific? Is this a full-on django bug? > The behavior you see stems from the fact, that different database backends need different quoting and escaping of values. The SQL queries from connection.queries are not literally executed; the statements and the parameters get passed separately to the backend as as good practice recommends. What you see is not a Django bug then, but maybe not Django-MySQL specific either. If you need to know more you'd have to dig into the django db or the python-mysql source code. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: running development server
Chris, Are you using the IP address of your network interface? Jorge Hugo Murillo - Original Message From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> To: Django users Sent: Tuesday, July 8, 2008 2:37:02 PM Subject: Re: running development server thnx, i got that, but the IP is that my machine's IP on the network, or the network's IP? i tried it with mine, made sure the port 8000 was open and did python manage.py runserver IP:8000 and got the server to initially start, but immediately after it displays the "Quit the server with CTRL-BREAK" line I get "Error: (10049, "Can't assign requested address")" error. if anyone has had this error, please let me know and i can work with our network admin to fix it. the server runs fine when it's just on my machine at 127.0.0.1:8000. chris On Jul 8, 2:33 pm, moos3 <[EMAIL PROTECTED]> wrote: > Also you could use mod_python or fastcgi so you can see how its going > to act when deployed. > > On Jul 8, 2:30 pm, [EMAIL PROTECTED] wrote: > > > hey all, > > > i'm trying to open up my development server to a couple of our other > > staff members to help me start testing next week. to open up the > > development server to others on our network, do i set runserver to my > > IP or the network's IP? > > > chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: running development server
Chris, Are you using the IP address of your network interface? Jorge Hugo Murillo - Original Message From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> To: Django users Sent: Tuesday, July 8, 2008 2:37:02 PM Subject: Re: running development server thnx, i got that, but the IP is that my machine's IP on the network, or the network's IP? i tried it with mine, made sure the port 8000 was open and did python manage.py runserver IP:8000 and got the server to initially start, but immediately after it displays the "Quit the server with CTRL-BREAK" line I get "Error: (10049, "Can't assign requested address")" error. if anyone has had this error, please let me know and i can work with our network admin to fix it. the server runs fine when it's just on my machine at 127.0.0.1:8000. chris On Jul 8, 2:33 pm, moos3 <[EMAIL PROTECTED]> wrote: > Also you could use mod_python or fastcgi so you can see how its going > to act when deployed. > > On Jul 8, 2:30 pm, [EMAIL PROTECTED] wrote: > > > hey all, > > > i'm trying to open up my development server to a couple of our other > > staff members to help me start testing next week. to open up the > > development server to others on our network, do i set runserver to my > > IP or the network's IP? > > > chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Markup languages vs HTML
On 8 juil, 18:02, "Matic Žgur" <[EMAIL PROTECTED]> wrote: > Hi, > > I'm working on some project, a part of which is a small blog app. All > the blog posts are saved as HTML (using TinyMCE in admin). I was > wondering, after reading some stuff about Markdown, what are pros and > cons of each method, ie. saving posts with some markup language vs. > html. Err... HTML actually *is* a markup language, you know ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django + tiny_mce
Thanks Chatchai. Unfortunately, integration of tiny_mce still eludes me. It seems that django is not looking in the proper directory for tiny_mce.js. But I can't see why, despite generous off-list help from kind-soul Peter. 1) I've reviewed and documented my configuration below and would be truly grateful if someone could point out the error or my way. 2) Also, at one point I though the problem might be due to improper file permissions. So I've opened tiny_mce.js and change_form.html wide open. Didn't help, but I suspect it may have created a security problem. Can anyone tell me how to set the permissions correctly? Lloyd Review of tiny_mce configuration: 1) Bennett:p23 "In urls.py, add a new line..." my urls.py * from django.conf.urls.defaults import * urlpatterns = patterns('', # Example: # (r'^cms/', include('cms.foo.urls')), # Uncomment this for admin: (r'^admin/', include('django.contrib.admin.urls')), (r'^tiny_mce/(?P.*)$','django.views.static.serve', { 'document_root': '/home/lloyd/ django/media/jscripts/tiny_mce' }), (r'', include('django.contrib.flatpages.urls')), ) ** 2) Bennett:p24 "Replace the /path-to-tiny_mce/..." See above. 2a) Confirm path to tiny_mce Entered in browser: http://192.168.1.4:8000/tiny_mce/tiny_mce.js Browser returned: var tinymce={majorVersion:'3',minorVersion:'0.8',... 3) Bennett:p25 "So inside your templates directory, create an admin directory. Then create a flatpages directory inside of admin and a flatpage subdirectory inside of flatpages. Finally copy the change_form template..." [EMAIL PROTECTED]:~/django/templates/admin/flatpages/flatpage$ ls -l total 4 -rwxrwxrwx 1 lloyd lloyd 3493 2008-07-08 02:16 change_form.html 4) Bennett:p25 "Now you can open up the change_form.html template in your template directory and edit it..." {% extends "admin/base_site.html" %} {% load i18n admin_modify adminmedia %} {% block extrahead %}{{ block.super }} tinyMCE.init({ mode: "textareas", theme: "simple" }); 5) Test Enter in browser: 192.168.1.4:8000/admin/ and advance to change form. Output of runserver: [08/Jul/2008 15:37:57] "GET /admin/ HTTP/1.1" 200 4851 [08/Jul/2008 15:38:00] "GET /admin/flatpages/flatpage/ HTTP/1.1" 200 2817 [08/Jul/2008 15:38:06] "GET /admin/flatpages/flatpage/2/ HTTP/1.1" 200 5186 [08/Jul/2008 15:38:07] "GET /admin/jsi18n/ HTTP/1.1" 200 803 [08/Jul/2008 15:38:07] "GET /admin/flatpages/flatpage/2/tiny_mce/ tiny_mce.js HTTP/1.1" 404 1780 Clearly django is looking for tiny_mce.js in wrong place. 6) Confirm location of tiny_mce: [EMAIL PROTECTED]:~/django/media/jscripts/tiny_mce$ ls -l total 424 -rw-r--r-- 1 lloyd lloyd453 2008-07-07 16:12 example.html -rw-r--r-- 1 lloyd lloyd 1617 2008-07-07 16:12 textareas.js -rwxrwxrwx 1 lloyd lloyd 153025 2008-07-07 16:12 tiny_mce.js -rw-r--r-- 1 lloyd lloyd 7145 2008-07-07 16:12 tiny_mce_popup.js -rw-r--r-- 1 lloyd lloyd 251714 2008-07-07 16:12 tiny_mce_src.js 7) Let's look at settings.py: TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/ django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. '/home/lloyd/django/templates', 8) QUESTION? Why is django looking for tiny_mce in .../admin/flatpages/flatpage ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: running development server
On 8 juil, 20:37, [EMAIL PROTECTED] wrote: > thnx, i got that, but the IP is that my machine's IP on the network, > or the network's IP? Should be your machine's IP address, of course. > i tried it with mine, made sure the port 8000 was open and did python > manage.py runserver IP:8000 and got the server to initially start, but > immediately after it displays the "Quit the server with CTRL-BREAK" > line I get "Error: (10049, "Can't assign requested address")" error. Chances are another service is already listening on that ip+port on your machine. Try with a couple other ports and see 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms: how to make input widgets smaller
On 8 juil, 21:06, Torsten Bronger <[EMAIL PROTECTED]> wrote: > Hallöchen! > > I use newforms.ModelForm to get a form from one of my models. > However, the HTML fields are all too wide. Okay, I could > re-define all fields that need narrower s like > > class SixChamberChannelForm(ModelForm): > gas = forms.CharField(widget=forms.TextInput(attrs={"size": "10"})) > diluted_in = forms.CharField(widget=forms.TextInput(attrs={"size": "10"})) > class Meta: > model = models.SixChamberChannel > > however, then I lose the information contained in max_length and > help_text in the model. How can I just put a "size" attribute to > the fields? What about using css ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django + tiny_mce
2008/7/8 LRP <[EMAIL PROTECTED]>: > > > Add a slash here: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms: how to make input widgets smaller
Hallöchen! bruno desthuilliers writes: > On 8 juil, 21:06, Torsten Bronger <[EMAIL PROTECTED]> > wrote: > >> I use newforms.ModelForm to get a form from one of my models. >> However, the HTML fields are all too wide. Okay, I could >> re-define all fields that need narrower s like >> >> class SixChamberChannelForm(ModelForm): >> gas = forms.CharField(widget=forms.TextInput(attrs={"size": "10"})) >> diluted_in = forms.CharField(widget=forms.TextInput(attrs={"size": "10"})) >> class Meta: >> model = models.SixChamberChannel >> >> however, then I lose the information contained in max_length and >> help_text in the model. How can I just put a "size" attribute to >> the fields? > > What about using css ? I had tried and failed. At least Firefox ignores style="width: 3em" attributes. Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: connection.queries - show improper SQL?
>From the source for QuerySet.__str__: Returns the query as a string of SQL with the parameter values substituted in. Parameter values won't necessarily be quoted correctly, since that is done by the database interface at execution time. The __str__ method just does a naive Python % operation, and doesn't try to quote the results. (And in fact, the different ORM backends take the query and parameters as separate arguments and do their own thing, such as substituting literal 'NULL' for None paramters and things like that.) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Trying to understand project structure w/apps
Hi guys+gals, I'm new to django, and I'm trying to wrap my head around a project structure. I have a simple case that I'm thinking about, but can't put together a reasonable mental model for it. I've got a site that has a schedule component (events), and a news component (news items). So I can easily create two apps, one for events, and the other for news, and I can create varying ways to display these components. My problem is that when I start thinking about the homepage... where I'd like to display both some events, and some news items. I can't figure out how I would use templates to do such a thing... place both on the same page. Ideally, I would like to have a template that displays an event, and one that displays a news item. But I'm not sure how that would work, with both of them extending the same base template. I could, of course, create one app which has all of these models internal, which would let me easily pull them into a single template, but I would really rather not couple the two distinct models together in both the view and the templates. If someone could give me a few pointers in a direction they'd approach this problem, it would be greatly appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: AutoImageField From Custom upload and filters
any takers on this ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Calculating on generic view
Hey, it helps :-) but i have a little problem now. I try to add an attribute to each element. In the CLI ist works: >>> from mysite.myapp.models import Mymodel >>> list = Mymodel.objects.all() >>> for elem in list: ... elem.kmph = elem.distance/elem.time >>> list[0].kmph 45 But when i put this in a view, it don't work: def myview(request): list = Mymodel.objects.all() for elem in list: elem.kmph = elem.distance/elem.time return object_list(request, queryset=list) In the template i have a part something like this: [...] {% for elem in object_list %} {{elem.distance}} {{elem.time}} {{elem.kmph}} {% endfor %} [...] but the "kmph" is allways empty. Any idea? thanks so far... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
streaming output
Hi, Is there an easy way to get a handle to the output file stream in a Django application? Instead of building an entire response in memory then sending it out, I'd like to send the response in pieces. thanks, Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Calculating on generic view
Hey, it helps :-) but i have a little problem now. I try to add an attribute to each element. In the CLI ist works: >>> from mysite.myapp.models import Mymodel >>> list = Mymodel.objects.all() >>> for elem in list: ... elem.kmph = elem.distance/elem.time >>> list[0].kmph 45 But when i put this in a view, it don't work: def myview(request): list = Mymodel.objects.all() for elem in list: elem.kmph = elem.distance/elem.time return object_list(request, queryset=list) In the template i have a part something like this: [...] {% for elem in object_list %} {{elem.distance}} {{elem.time}} {{elem.kmph}} {% endfor %} [...] but the "kmph" is allways empty. Any idea? thanks so far... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Calculating on generic view
Hey, it helps :-) but i have a little problem now. I try to add an attribute to each element. In the CLI ist works: >>> from mysite.myapp.models import Mymodel >>> list = Mymodel.objects.all() >>> for elem in list: ... elem.kmph = elem.distance/elem.time >>> list[0].kmph 45 But when i put this in a view, it don't work: def myview(request): list = Mymodel.objects.all() for elem in list: elem.kmph = elem.distance/elem.time return object_list(request, queryset=list) In the template i have a part something like this: [...] {% for elem in object_list %} {{elem.distance}} {{elem.time}} {{elem.kmph}} {% endfor %} [...] but the "kmph" is allways empty. Any idea? thanks so far... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Trying to understand project structure w/apps
eddie wrote: > Hi guys+gals, > > I'm new to django, and I'm trying to wrap my head around a project > structure. I have a simple case that I'm thinking about, but can't > put together a reasonable mental model for it. > > I've got a site that has a schedule component (events), and a news > component (news items). So I can easily create two apps, one for > events, and the other for news, and I can create varying ways to > display these components. My problem is that when I start thinking > about the homepage... where I'd like to display both some events, and > some news items. I can't figure out how I would use templates to do > such a thing... place both on the same page. Ideally, I would like to > have a template that displays an event, and one that displays a news > item. But I'm not sure how that would work, with both of them > extending the same base template. Typically templates are so site specific that is doesn't make sense to have templates in "apps". Templatetags can be handy. > I could, of course, create one app which has all of these models > internal, which would let me easily pull them into a single template, > but I would really rather not couple the two distinct models together > in both the view and the templates. I think you have a false idea that templates are tied to models somehow. This is not the case. I often create an app called "main" that includes stuff like index about other "site" pages. The main index page often includes data from many models. in main/views.py from app import ModelOne from app import ModelTwo def index(request): context = dict() context["ones"] = ModelOne.objects.all() context["twos"] = ModelTwo.objects.filter(somekey=somevalue) render_to_response("main/index.html", context) > If someone could give me a few pointers in a direction they'd approach > this problem, it would be greatly appreciated. http://www.pointy-stick.com/blog/2007/11/09/django-tip-developing-without-projects/ -- Norman J. Harman Jr. Senior Web Specialist, Austin American-Statesman ___ You've got fun! Check out Austin360.com for all the entertainment info you need to live it up in the big city! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: dreaded FieldError (used to be KeyError) can only replicate on production, ugh!
On Jun 30, 3:01 pm, Milan Andric <[EMAIL PROTECTED]> wrote: > I've been wresting with this one for a couple hours now trying to > track it down, but no luck. I'm recently updated to django trunk and > getting very odd reponses. I could take the same page and refresh it > several times in succession and eventually get the page, but usually > get 500 errors. What would cause that? > > http://multimedia.journalism.berkeley.edu/training/projects/ > > I also restarted/stop/started and removed all .pyc files from my > project, installed apps and django just for good measure. > > I managed to get the traceback while in debug mode that raises a > FieldError:http://dpaste.com/5/ > > Here's the wrapped generic view that is being called:http://dpaste.com/60002/ > > Here's the model:http://dpaste.com/60005/ > Does anyone have comments on the above model? I'm wresting with a FieldError during a loop in the template and having a hell of a time tracking down the problem. The relevant part of the template is: {% for m in p.members.all %} {{m.get_profile.get_display_name}}{% if not forloop.last %}, {% endif %} {% endfor %} When I do the same loop in the shell I don't get any exceptions. Any help is greatly appreciated, this is on trunk. The code seems to choke on specifically one project (id 51) but I've traced all the relations in the db that I could think of and don't see any inconsistencies. But the template error is not consistent meaning sometimes i get the exception and sometimes I don't so just trying to clean things up where I can, starting with the model. -- Milan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: running development server
Just use 0.0.0.0 and the dev server will listen on all interfaces. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Trying to understand project structure w/apps
On Tue, Jul 8, 2008 at 3:53 PM, eddie <[EMAIL PROTECTED]> wrote: > > Hi guys+gals, > > I'm new to django, and I'm trying to wrap my head around a project > structure. I have a simple case that I'm thinking about, but can't > put together a reasonable mental model for it. > > I've got a site that has a schedule component (events), and a news > component (news items). So I can easily create two apps, one for > events, and the other for news, and I can create varying ways to > display these components. My problem is that when I start thinking > about the homepage... where I'd like to display both some events, and > some news items. I can't figure out how I would use templates to do > such a thing... place both on the same page. Ideally, I would like to > have a template that displays an event, and one that displays a news > item. But I'm not sure how that would work, with both of them > extending the same base template. > > I could, of course, create one app which has all of these models > internal, which would let me easily pull them into a single template, > but I would really rather not couple the two distinct models together > in both the view and the templates. > Another option is to skip writing a view and just use a generic view which you can do with a urls.py file and a template. We just had a couple people asking similar question: http://groups.google.com/group/django-users/browse_thread/thread/d2524403e13fcd22/4fe607f6d9487ee9#4fe607f6d9487ee9 But there is nothing wrong and it's quite easy to just create a frontpage app with just a view that returns the correct objects to a template. -- Milan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms: how to make input widgets smaller
Hallöchen! Torsten Bronger writes: > I use newforms.ModelForm to get a form from one of my models. > However, the HTML fields are all too wide. Okay, I could > re-define all fields that need narrower s like > > class SixChamberChannelForm(ModelForm): > gas = forms.CharField(widget=forms.TextInput(attrs={"size": "10"})) > diluted_in = forms.CharField(widget=forms.TextInput(attrs={"size": "10"})) > class Meta: > model = models.SixChamberChannel > > however, then I lose the information contained in max_length and > help_text in the model. How can I just put a "size" attribute to > the fields? Okay, after some introspection (__dict__ rules) I found this solution: class SixChamberChannelForm(ModelForm): def __init__(self, **keyw): super(SixChamberLayerForm, self).__init__(**keyw) self.fields["gas"].widget = forms.TextInput(attrs={"size": "10"}) self.fields["diluted_in"].widget = forms.TextInput(attrs={"size": "10"}) class Meta: model = models.SixChamberChannel I nobody sees possible unfortunate side effects here, I think that's it. Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
does django cache models.py?
i'm trying it figure out why django is not recognizing a new models.py file for my app. even when i completely butcher the code in models.py or change the filename and run "manage.py sqlreset" or "manage.py syndb," it still generates the old model. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Import issues since newforms-admin
Hi, There's an issue that arose as I upgraded an external app of mine to newforms-admin. I created the conventional admin.py, which does all the registration business, and did "import admin" in the module's __init__.py After I did that, I got some import errors at compilation time (or say, project's launching time): "ImportError: cannot import name MenuItem" "MenuItem" is in the external app (freshly upgraded to nfa), and the import that raises the error is made in the project's app. The external app was included at the top of the INSTALLED_APPS setting. Putting it at the end of INSTALLED_APPS solved the issue. I thought that the order didn't matter in INSTALLED_APPS. Have I missed something or have I possibly misconfigured my external app or my project's apps? Is that a known issue (and if so, what's the proper way around it?), or is that worth filing a ticket? Thanks! Julien --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django + tiny_mce
Easy fix. Open your models.py and in the Class Admin section of the model insert js = ['tiny_mce/tiny_mce.js', 'js/textareas.js']. For example: class Admin: list_display = ('headline', 'author', 'pub_date', 'publish') list_filter = ['pub_date'] save_as = True js = ['tiny_mce/tiny_mce.js', 'js/textareas.js'] Save the model. Stop and restart you apache server. Login the Admin and verify the changes. -Mario On Jul 6, 11:56 am, [EMAIL PROTECTED] wrote: > Hello, > > I'm working through James Bennett's Practical Django Projects. Have brought > up the cms; would like to add Rich Text Editing, but the instructions in > Bennet's book don't seem to work for me. > > Googling around, I find a number of recipes for adding RTE. Thought I try the > approach suggested by the Django > project:http://code.djangoproject.com/wiki/AddWYSIWYGEditor. > > But this doesn't work for me either. > > Here's my config: > > 1) tiny_mce.js is in: /usr/share/tinymce/www > 2) TEMPLATE_DIRS in settings.py is set to: > > TEMPLATE_DIRS = ( > '/home/lloyd/django/templates/cms/', > ) > > 3) my template is in: ~/django/templates/cms/flatpages > 4) I've copied change_form.html, the admin template, into: > ~/django/templates/admin_copies > > 5) the admin template extension, change_forms.html, is in: > ~/django/templates/admin/flatpages/flatpage > > ...and reads: > > {% extends "admin_copies/change_form.html" %} > {% block extrahead %}{{ block.super }} > src="/usr/share/tinymce/www/tiny_mce.js"> > src="/usr/share/tinymce/www/textareas.js" > {% endblock %} > > With this configuration, everything works fine, except the tiny_mce editor > fails to show on the admin page. > > Questions: > > 1) Am I missing or misunderstanding a step? > 2) Is there an effective debugging method that I can use in a case like this? > > Many thanks, > > Lloyd R. Prentice --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
"ImportError No module named django"
I installed Django on my iMac running Lepoard. I installed the official release and followed the instructions, but when I try to import Django to Python I get the following message: "ImportError No module named django" on top of this, I now have 2 Python folders version 2.5. Has anyone come up with a fix for this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to use combined indices (esp. in fulltext queries)?
On Tue, 2008-07-08 at 08:13 -0700, ToSH wrote: > Hi, > > I would need to do a query like > SELECT * FROM mytable WHERE match (a) against("+AAA" in boolean mode) > and match (b against("+BBB" in boolean mode) > and match (a,b) against("+AAA +BBB" in boolean mode) > > If I would omit the last line (which seems to be redundant) I could do > this easily with the Django framework by > s.filter(a__search='AAA', b__search='BBB') > > However it turned out that doing the query with the last line is far > more efficient for MySQL. By querying (a,b) it can query a combined > index which returns only very few rows which then are combined with > the other two AND statements. If I omit the combined index, the temp > table (for doing the AND statement) is far bigger. The speed gain is > about factor 100 - sometimes even more (yes: my tables are quiet large > and it is noticeable) > > How would I do this in Django? cursor.execute(my_custom_sql) Seriously! Django is designed to cover maybe 80% of what SQL does. The common stuff. And it provides you with access the the database cursor so that you can do raw queries when you need to. Django isn't a replacement for SQL, it's an adjunct. Particularly if you want to take advantages of things that are very specific to one or other backend (esp. MySQL with all the myriad of storage engine options), talking to the database is the right idea. You might be able to pull of something with the extra(where=) method on a queryset, too, although that can become a bit fragile in complex situations. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "ImportError No module named django"
How did you exactly install it? Which folders are in your PYTHONPATH? Juanjo -- mi blog: http://www.juanjoconti.com.ar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "ImportError No module named django"
Hi, This means that Django is not in the PYTHONPATH. To check what's in that path, run the following in Python: >>> import sys >>> print sys.path On Jul 9, 9:35 am, Juanjo Conti <[EMAIL PROTECTED]> wrote: > How did you exactly install it? > Which folders are in your PYTHONPATH? > > Juanjo > -- > mi blog:http://www.juanjoconti.com.ar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: streaming output
On Tue, 2008-07-08 at 13:31 -0700, Brogli wrote: > Hi, > Is there an easy way to get a handle to the output file stream in a > Django application? Instead of building an entire response in memory > then sending it out, I'd like to send the response in pieces. Not really (in a reliable way). One constraint is that Django is designed to operate seamlessly as a WSGI application and the WSGI specification does not permit responses to be streamed in pieces ("chunked transfer encoding" in the HTTP 1.1 parlance) from an application. Yes, it's theoretically possible to pass a generator to the HttpResponse, but there are lots of technical problems that can arise. Some of which are being worked out on the dev list at the moment, some of which are just technically impossible (like the WSGI constraint). Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: streaming output
Not that i know of, but you'd be surprised how easy it is to write a socket server in Python: http://www.amk.ca/python/howto/sockets/ Brogli wrote: > Hi, > Is there an easy way to get a handle to the output file stream in a > Django application? Instead of building an entire response in memory > then sending it out, I'd like to send the response in pieces. > > thanks, > Dave > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Import issues since newforms-admin
On Tue, 2008-07-08 at 16:20 -0700, Julien Phalip wrote: > Hi, > > There's an issue that arose as I upgraded an external app of mine to > newforms-admin. > > I created the conventional admin.py, which does all the registration > business, and did "import admin" in the module's __init__.py > > After I did that, I got some import errors at compilation time (or > say, project's launching time): > > "ImportError: cannot import name MenuItem" > > "MenuItem" is in the external app (freshly upgraded to nfa), and the > import that raises the error is made in the project's app. It's a bit (for me, at least) to keep track of what structure you're describing here. You are using the word "project" to mean something that isn't clear. Could you give a small layout of the directory structure please. It's not impossible to imagine something like the problem you're describing happening depending upon import paths. Remember that when you do "from foo import models", Python first has to parse and execute the code in "foo/__init__.py", so things might not be fully constructed. But, again, it's hard to tell without concrete code. If you can construct a very small example that demonstrates the problem (like, literally, as few lines as possible. To the point that if you remove any more lines, the problem goes away) then you've got something you can put in a bug report because then other people can try to repeat the problem and diagnose it. I'm not intimately familiar with how newforms is doing imports or recommended practices over there, but if this type of problem is cropping up, it's worth knowing about it so that we can either document "don't do that" or get things fixed if possible. Again, I'm not saying that what you're seeing is a bug or necessarily a problem in Django. I don't understand the problem you're describing from the English-language version. Code speaks more clearly here, I think. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problems using custom sql in manager
I've run into an issue using a manager for a model to run some custom sql. A dumbed down version of the code looks something like this: cursor = connection.cursor() # Get list of zipcodes zips = [zip.zipcode for zip in Zip_Code.objects.filter(lat__range=(min_lat, max_lat), lon__range=(min_lon, max_lon))] sql = """ SELECT id FROM Event WHERE zip_code IN %s""" cursor.execute(sql, (zips,)) The Zipcode field is a VARCHAR(10) in the database, so the zipcodes in the list are unicode strings. If I run the query this way, I get 0 results. Although If I copy the sql it generates and run it I get several results. The interesting this is if I cast the zipcode to an integer then the query works. I also tried casting each zipcode to a regular string but it also returns 0 results. So it looks like in order for the IN function to work for the MySQLdb backend it must be a list of integers. This doesn't work so well for zipcodes that begin with 0's like Burlington VT which is "05401". Is there some trick I am missing, or is this a genuine bug in the python MySQLdb module? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using custom sql in manager
On Tue, 2008-07-08 at 16:56 -0700, AJ wrote: > I've run into an issue using a manager for a model to run some custom > sql. > A dumbed down version of the code looks something like this: > > cursor = connection.cursor() > # Get list of zipcodes > zips = [zip.zipcode for zip in > Zip_Code.objects.filter(lat__range=(min_lat, max_lat), > lon__range=(min_lon, max_lon))] > > sql = """ > SELECT id > FROM Event > WHERE zip_code IN %s""" > cursor.execute(sql, (zips,)) > > > The Zipcode field is a VARCHAR(10) in the database, so the zipcodes in > the list are unicode strings. If I run the query this way, I get 0 > results. Although If I copy the sql it generates and run it I get > several results. > > The interesting this is if I cast the zipcode to an integer then the > query works. I also tried casting each zipcode to a regular string > but it also returns 0 results. So it looks like in order for the IN > function to work for the MySQLdb backend it must be a list of > integers. This doesn't work so well for zipcodes that begin with 0's > like Burlington VT which is "05401". > > Is there some trick I am missing, or is this a genuine bug in the > python MySQLdb module? You're making the assumption that you can pass a list or a tuple as a parameter to the query and that the DB wrapper will magically turn it into the right thing. This isn't correct (it happens to work by accident in some cases, like integers where str(some_list) is valid SQL). You need to be passing in N parameters with something like ', '.join(["%s"] * len(params)) used to construct the placeholders. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django + tiny_mce
Hi, Thanks to all for responses, but puzzle persists... Mathias, I added the slash. Still can't see the tiny_mce edit bar. But it does provide a clue: Output of runserver now looks like: [08/Jul/2008 19:37:17] "GET /admin/ HTTP/1.1" 200 4851 [08/Jul/2008 19:37:20] "GET /admin/flatpages/flatpage/ HTTP/1.1" 200 2817 [08/Jul/2008 19:37:23] "GET /admin/flatpages/flatpage/2/ HTTP/1.1" 200 5187 [08/Jul/2008 19:37:23] "GET /admin/jsi18n/ HTTP/1.1" 200 803 [08/Jul/2008 19:37:23] "GET /tiny_mce/langs/en.js HTTP/1.1" 404 1771 [08/Jul/2008 19:37:24] "GET /tiny_mce/themes/simple/editor_template.js HTTP/1.1" 404 1834 If I enter http://192.168.1.4:8000/tiny_mce/tiny_mce.js, I still see: var tinymce={majorVersion:'3',minorVersion:'0.8'... Mario, I'm serving through the development server , runserver, not Apache. Also, the model is buried in django.contrib.flatpages somewhere. I would think that James Bennett would have mentioned something about adding to the model if it were required. I'll keep you idea in mind, however. Thanks again to all, Lloyd --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using custom sql in manager
Thanks for your quick reply. I have been searching for a long time for good documentation on using IN and paramaters with no luck. When it worked with a list I assumed that was correct. Could you clarify an example of transforming a list of items into something mysqldb would accept then executing it? I think you are saying that if I have 2 items in the list I need to manually specify: zips = ['7', '55544'] sql = """ SELECT id FROM Event WHERE zip_code IN %s, %s""" cursor.execute(sql, (zips[0], zips[1])) and do you need to specify the parens around the params? I tried passing in a string like '("3", "33344")' and it didn't error, but it didn't return any results either. On Jul 8, 8:00 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-07-08 at 16:56 -0700, AJ wrote: > > I've run into an issue using a manager for a model to run some custom > > sql. > > A dumbed down version of the code looks something like this: > > > > cursor = connection.cursor() > > # Get list of zipcodes > > zips = [zip.zipcode for zip in > > Zip_Code.objects.filter(lat__range=(min_lat, max_lat), > > lon__range=(min_lon, max_lon))] > > > sql = """ > > SELECT id > > FROM Event > > WHERE zip_code IN %s""" > > cursor.execute(sql, (zips,)) > > > > > The Zipcode field is a VARCHAR(10) in the database, so the zipcodes in > > the list are unicode strings. If I run the query this way, I get 0 > > results. Although If I copy the sql it generates and run it I get > > several results. > > > The interesting this is if I cast the zipcode to an integer then the > > query works. I also tried casting each zipcode to a regular string > > but it also returns 0 results. So it looks like in order for the IN > > function to work for the MySQLdb backend it must be a list of > > integers. This doesn't work so well for zipcodes that begin with 0's > > like Burlington VT which is "05401". > > > Is there some trick I am missing, or is this a genuine bug in the > > python MySQLdb module? > > You're making the assumption that you can pass a list or a tuple as a > parameter to the query and that the DB wrapper will magically turn it > into the right thing. This isn't correct (it happens to work by accident > in some cases, like integers where str(some_list) is valid SQL). > > You need to be passing in N parameters with something like > > ', '.join(["%s"] * len(params)) > > used to construct the placeholders. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django + tiny_mce
http://192.168.1.4:8000/tiny_mce/tiny_mce.js vs [08/Jul/2008 19:37:23] "GET /tiny_mce/langs/en.js HTTP/1.1" 404 1771 What is "lang" at the right side? Chatchai 2008/7/9 LRP <[EMAIL PROTECTED]>: > > Hi, > > Thanks to all for responses, but puzzle persists... > > Mathias, I added the slash. Still can't see the tiny_mce edit bar. > But it does provide a clue: Output of runserver now looks like: > > [08/Jul/2008 19:37:17] "GET /admin/ HTTP/1.1" 200 4851 > [08/Jul/2008 19:37:20] "GET /admin/flatpages/flatpage/ HTTP/1.1" 200 > 2817 > [08/Jul/2008 19:37:23] "GET /admin/flatpages/flatpage/2/ HTTP/1.1" 200 > 5187 > [08/Jul/2008 19:37:23] "GET /admin/jsi18n/ HTTP/1.1" 200 803 > [08/Jul/2008 19:37:23] "GET /tiny_mce/langs/en.js HTTP/1.1" 404 1771 > [08/Jul/2008 19:37:24] "GET /tiny_mce/themes/simple/editor_template.js > HTTP/1.1" 404 1834 > > If I enter http://192.168.1.4:8000/tiny_mce/tiny_mce.js, I still see: > var tinymce={majorVersion:'3',minorVersion:'0.8'... > > Mario, > > I'm serving through the development server , runserver, not Apache. > Also, the model is buried in django.contrib.flatpages somewhere. I > would think that James Bennett would have mentioned something about > adding to the model if it were required. I'll keep you idea in mind, > however. > > Thanks again to all, > > Lloyd > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---