Re: Mod_Python and everything loaded, Apache serving HTML files without using Django first
On Nov 1, 9:15 pm, The End wrote: > I've finally got mod_python and mysqldb working with apache (long > story short, can't install wsgi for various reasons and i'm using > python 2.4.3... for various reasons...). > > However > > Now when i load up the home page (just typing 'localhost' into > firefox) i get the literal HTML representation of index.html, without > the dynamics filling in. I can only assume that apache is not using > Django to return these requests. > > I only have 1 Virtual Host and Location tag in my entire Apache > Configuration File (with all the standard stuff, i didn't turn > anything off): > > LoadModule python_module /usr/lib64/httpd/modules/mod_python.so > > > ServerName Sweetman > ServerAdmin sweet...@sweetman.com > DocumentRoot /srv/www/sweetman/ > > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE sweetman.settings > PythonDebug On > PythonPath "[ '/sweetman_live/sweetman' , '/usr/lib/ > python2.4/site-packages/django/' , '/srv/www/'] + sys.path" > > > > SetHandler none > > > ErrorLog /srv/www/sweetman/logs/error.log > CustomLog /srv/www/sweetman/logs/access.log combined > You've only set up mod_python to handle the 'sweetman' directory, not the root. Change the "Location" to "/". Also note that it's a bad idea to keep your Django code and templates under your DocumentRoot. Apart from anything else, it's a potential security hole - if a misconfigured Apache can serve your templates directly, it could also do so with your settings file containing your db credentials. Put it all somewhere else - it just needs to be on your PythonPath, which you're already modifying in the configuration. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: 2D map application: performance and design question
Ok, so having excluded SQLite and the static served files, I'd like to test if the server matters. What would be a minimum Apache install and config to run Django locally (on Windows)? On Nov 1, 7:30 pm, Lars Ruoff wrote: > Ok, thanks all, > > So following Bill's advice, i did:>python manage.py shell > >>> import game.models > >>> list(game.models.Location.objects.filter( \ > > ... x__gte=34, \ > ... x__lte=46, \ > ... y__gte=24, \ > ... y__lte=36)) > > ...and the result showed up instantly! > So it seems DB is not the issue. > Will do other testing... > > On Nov 1, 4:18 pm, Bill Freeman wrote: > > > My experience with Django debug toolbar is that it makes things > > slow all by itself. > > > I have done a couple of apps that use the equivalent query, using > > PostgreSQL, > > without noticing a performance issue, with everything running on a Linux > > server. > > > 1. Have you tried timing the query by hand? That is, run the manage.py > > shell, > > import your model, and type a sample version of the query, wrapped in a > > list() > > operation to force the query to evaluate right away. If it's slow, > > then you problem > > is at least mostly in your DB/query choice. > > > 2. Is the machine in question tight on memory? That could make things > > slower > > that it would be on a production instance. > > > 3. You might look at the "range" field lookup instead of pairs of > > gte, lte. I doubt > > that it makes a performance difference, and I don't know if SQLite supports > > BETWEEN, but it's easy to try. > > > 4. You show x and y as integers, but if that was just by way of example, and > > they are really some complex (non-scalar) data type, the comparisons may not > > be cheap on the database. > > > Bill > > > On Mon, Nov 1, 2010 at 8:13 AM, Javier Guerra Giraldez > > > wrote: > > > On Mon, Nov 1, 2010 at 5:55 AM, Cal Leeming [Simplicity Media Ltd] > > > wrote: > > >> 9 out of 10 times, the bottleneck is usually the database > > > > true, but 8.7 of those 9 are about how the database is used, and not > > > about the engine choice. simply changing SQLite won't improve > > > significantly the one-user case. > > > > the trick is: 1) get as few db queries as possible for each page. 2) > > > use appropriate indices for those queries > > > > but first of all, you have to identify if it is really the DB where > > > you're spending time. the easiest way to be sure is to install > > > django_debug_toolbar app, it's great to tell you exactly what's going > > > on with the time and the DB accesses. > > > > -- > > > Javier > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com. > > > For more options, visit this group > > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
html in django password_reset_email.html
I recently tried to send the following in a test password email from a site I am creating: This is a test reset password email. However when I received the email it displayed the "This is a test reset password email.". My question is how can I send a styled email using html tags and possibly even css when using the password_reset_email.html template that goes with django's view.password_reset? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: 2D map application: performance and design question
On Tue, 2010-11-02 at 01:35 -0700, Lars Ruoff wrote: > Ok, so having excluded SQLite and the static served files, I'd like to > test if the server matters. What would be a minimum Apache install and > config to run Django locally (on Windows)? try nginx+fcgi/tornado/your favourite webserver -- regards Kenneth Gonsalves Senior Associate NRC-FOSS at AU-KBC -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-voting url pattern
On Nov 1, 3:08 pm, Sithembewena Lloyd Dube wrote: > Thanks Daniel, makes sense. Also, I was making the mistake of thinking that > I had to create a separate view, forgetting that I am calling the one > supplied by django-voting. That correct? I'm not familiar with django-voting, but yes that sounds right. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: html in django password_reset_email.html
On Tue, Nov 2, 2010 at 9:07 AM, andy wrote: > I recently tried to send the following in a test password email from a > site I am creating: > > This is a test reset password email. > > However when I received the email it displayed the "This is a test > reset password email.". > > My question is how can I send a styled email using html tags and > possibly even css when using the password_reset_email.html template > that goes with django's view.password_reset? > I don't know about the specifics of your particular issues, but to send HTML emails: Create an instance of django.core.mail.EmailMultiAlternatives, passing in your subject, text version of the email, from address, list of recipients. Render your HTML version of the email, and attach it to the email, and then send it. eg: from django.core.mail import EmailMultiAlternatives msg = EmailMultiAlternatives('Subject', 'This is the text version', 'f...@address.com', [ 'recipie...@address.com',]) html_version = ... msg.attach_alternative(html_version, 'text/html') msg.send() There are lots of 'gotchas' when sending HTML email. Don't expect externally referenced resources to be available, don't expect styles to work correctly in all UAs, don't expect any JS to work. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
ATTRIBUTE ERROR
If i am doing anything wrong forgive me i am newbe MY error is Exception Type: AttributeError Exception Value: 'str' object has no attribute 'resolve' Exception Location: D:\Python25\lib\site-packages\django\core\urlresolvers.py in resolve, line 25 My url.py look like this from django.conf.urls.defaults import * from it.view import current_datetime # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Example: (r'^wap/di/sub/$",current_datetime') # Uncomment the admin/doc line below to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: # (r'^admin/', include(admin.site.urls)), ) ~~~ My view.py looks like this from django.http import * import urllib def current_datetime(request): word = request.GET['word'] message = urllib.urlopen('http://m.broov.com/wap/di/sub?word='+word+'&type=00submit=Submit',) return HttpResponse (message) ~~ Thank u for notification -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Query help
Hi people, Given this: class Category(models.Model): name = models.CharField() parent = models.ForeignKey('self', blank=True, null=True) tree_path = models.CharField() # //.../// class Item(models.Model): name = models.CharField() categories = models.ManyToManyField(Category) I need a Category queryset, with each category annotated with a count of items which have categories whose tree_path starts with the tree_path of the current category, and with categories for which this count is 0 filtered out. In case that wasn't clear - I need an efficient way to do this: for category in Category.objects.all(): category.num_items = Item.objects.filter(categories__tree_path__startswith=category.tree_path).count() if category.num_items > 0: yield category Suggestions? TIA, Itai -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django: How to get field value dynamically using custom template tags?
I recently got a problem where I need to get field's value automatically using templatetags.The idea follows which mentioned in the book "Practical Django Project 2nd Edition", but the book version is getting a list of objects where I want to get only a object's value. I want to get the site settings (Title, Tagline etc.) and pass in the template dynamically so that I don't have to write the code again to get each field's value. Here is what I have done so far. *Define an admin.py for the model (not included here because it's not important)* *Defined a model:* from django.db import models from django.contrib.sites.models import Site class Naming(models.Model): title = models.CharField(max_length=250) site_id = models.ForeignKey(Site) tagline = models.CharField(max_length=250) description = models.TextField(blank=True) def __unicode__(self): return self.title *Defined a template tag file, the commented line is where I get stuck* from django.db.models import get_model from django.contrib.sites.models import Site from django import template def do_site_att(parser, token): bits = token.split_contents() if len(bits) != 5: raise template.TemplateSyntaxError("'get_site_att' tag takes exactly four arguments") model_args = bits[1].split('.') if len(model_args) != 2: raise template.TemplateSyntaxError("First argument to 'get_site_att' must be an 'application name'.'model name' string.") model = get_model(*model_args) if model is None: raise template.TemplateSyntaxError("'get_site_att' tag got an invalid model: %s." % bits[1]) return ContentNode(model, bits[2], bits[4]) class ContentNode(template.Node): def __init__(self, model, field, varname): self.model = model self.field = field self.varname = varname def render(self, context): current_site = Site.objects.get_current() try: var = self.model.objects.get(site_id=current_site.id) context[self.varname] = var.title #I get stuck here because it not accepts input like var.field (I have extract the field value above) except: context[self.varname] = "Value not found" return '' register = template.Library() register.tag('get_site_att', do_site_att) *The template query in base.html:* {% load general_tags %} {% get_site_att general.Naming title as title %} {{title}} {% get_site_att general.Naming tagline as tagline %} {{tagline}} I have tried all the possible ways I can think of, but just can't get it works. Any help is really appreciated. Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ATTRIBUTE ERROR
On Tue, Nov 2, 2010 at 11:08 AM, sami nathan wrote: > If i am doing anything wrong forgive me i am newbe > > > MY error is > Exception Type: AttributeError > Exception Value: > > 'str' object has no attribute 'resolve' > > Exception Location: > D:\Python25\lib\site-packages\django\core\urlresolvers.py in resolve, > line 25 > > > My url.py look like this > from django.conf.urls.defaults import * > from it.view import current_datetime > > # Uncomment the next two lines to enable the admin: > from django.contrib import admin > admin.autodiscover() > > urlpatterns = patterns('', > # Example: > (r'^wap/di/sub/$",current_datetime') This line is wrong ^^^ Quote your strings correctly and you won't get this error. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
od-erdene
hi everyone {% if qs %} {% autopaginate qs 5 %} {% for q in qs %} {% endfor %} {% paginate %} {% endif %} -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
page back
hi everyone {% if qs %} {% autopaginate qs 5 %} {% for q in qs %} {% endfor %} {% paginate %} {% endif %} I'm using Django Forms to do a filtered/faceted search via POST, and I would like to Django's paginator class to organize the results. How do I preserve the original request when passing the client between the various pages? In other words, it seems that I lose the POST data as soon as I pass the GET request for another page back to my views. I've seen some recommendations to use AJAX to refresh only the results block of the page, but I'm wondering if there is a Django-native mechanism for doing this. thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Is it madness to process uploaded tars and zips completely in memory?
Hi, I am writing an app to "apply some rainbows and unicorns" to a bunch of uploaded XML files (which can be uploaded as a compressed tar or zip file). Celery and rabbitmq will be used for the asynchronous tasks with jQuery (maybe with dajaxproject) to get updates on progress to the browser. I'm at the point where I'm passing the uploaded files to my offline tasks and using cStringIO with both the tarfile and zipfile modules to handle the whole compressed files as strings and then saving the decompressed XML files in an array of strings to be later manhandled by cElementTree. There is a closed audience for this app and uncompressed filesizes will never be more than 3 or 4 MB (mostly they'll under 100KB). I don't expect this to be used by more than a handful of people per day (but it will save _alot_ of man hours). Is it madness to try to do this all in memory? Should I write out the file contents to the filesystem first using "for i in uploadedfile.chunks()"? Does anyone know of any open Django apps that do anything similar (upload a file, get presented with the results) so I can have a look? Thanks in advance W -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Attributr error
THIS IS HOW MY URL.PY LOOKS LIKE from django.conf.urls.defaults import * from it.view import current_datetime # Uncomment the next two lines to enable the admin: #from django.contrib import admin #admin.autodiscover() urlpatterns = patterns('', # Example: (r"^wap/di/sub/$",current_datetime), # Uncomment the admin/doc line below to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: # (r'^admin/', include(admin.site.urls)), ) `~~~ My view .py looks like this from django.http import * import urllib from django_restapi.responder import XMLResponder def current_datetime(request): word = request.GET['word'] message = urllib.urlopen('http://m.broov.com/wap/di/sub?word='+word+'&type=00submit=Submit',) return XMLResponder(message) But my error is Exception Value: 'XMLResponder' object has no attribute 'status_code' Exception Location: D:\Python25\lib\site-packages\django\middleware\common.py in process_response, line 94 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is it madness to process uploaded tars and zips completely in memory?
All depends on whether; - you have enough memory - you are going to enforce the file size - you have appropriate resource limitations in place on the server - you are going to enforce the maximum number of processing requests etc etc... Personally, if all those conditions were met, I'd probably do it in memory to avoid the unnecessary disk IO overhead.. but it all depends on what you need :) On Tue, Nov 2, 2010 at 1:00 PM, wawa wawawa wrote: > Hi, > > I am writing an app to "apply some rainbows and unicorns" to a bunch > of uploaded XML files (which can be uploaded as a compressed tar or > zip file). Celery and rabbitmq will be used for the asynchronous tasks > with jQuery (maybe with dajaxproject) to get updates on progress to > the browser. > > I'm at the point where I'm passing the uploaded files to my offline > tasks and using cStringIO with both the tarfile and zipfile modules to > handle the whole compressed files as strings and then saving the > decompressed XML files in an array of strings to be later manhandled > by cElementTree. > > There is a closed audience for this app and uncompressed filesizes > will never be more than 3 or 4 MB (mostly they'll under 100KB). I > don't expect this to be used by more than a handful of people per day > (but it will save _alot_ of man hours). > > Is it madness to try to do this all in memory? > > Should I write out the file contents to the filesystem first using > "for i in uploadedfile.chunks()"? > > Does anyone know of any open Django apps that do anything similar > (upload a file, get presented with the results) so I can have a look? > > Thanks in advance > > W > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Cal Leeming Operational Security & Support Team *Out of Hours: *+44 (07534) 971120 | *Support Tickets: * supp...@simplicitymedialtd.co.uk *Fax: *+44 (02476) 578987 | *Email: *cal.leem...@simplicitymedialtd.co.uk *IM: *AIM / ICQ / MSN / Skype (available upon request) Simplicity Media Ltd. All rights reserved. Registered company number 7143564 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is it madness to process uploaded tars and zips completely in memory?
On 2 November 2010 14:03, Cal Leeming [Simplicity Media Ltd] wrote: > All depends on whether; > > you have enough memory > you are going to enforce the file size > you have appropriate resource limitations in place on the server > you are going to enforce the maximum number of processing requests > > etc etc... > Personally, if all those conditions were met, I'd probably do it in memory > to avoid the unnecessary disk IO overhead.. but it all depends on what you > need :) Hi Cal Thanks for this. I think I'll continue as I am then, taking into account your suggestions. Kind Regards Wa -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: od-erdene
do not use {% if qs %} {% endif %} use {% for q in qs %} {% empty %} {% endfor %} then it will work Brano On Nov 2, 1:50 pm, Odkoo Ch wrote: > hi everyone > > > > {% if qs %} > {% autopaginate qs 5 %} > {% for q in qs %} > > name="payment_value{{forloop.counter}}" type="text" > id="id_payment_value{{forloop.counter}}" size="20" > onchange="onChange({{forloop.counter}})"/> > name="note{{forloop.counter}}" type="text" id="id_note{{forloop.counter}}" > size="20" onchange="onChange({{forloop.counter}})"/> > {% endfor %} > {% paginate %} > {% endif %} > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Attributr error
On Tue, Nov 2, 2010 at 1:00 PM, sami nathan wrote: > THIS IS HOW MY URL.PY LOOKS LIKE > > from django.conf.urls.defaults import * > from it.view import current_datetime > > > > # Uncomment the next two lines to enable the admin: > #from django.contrib import admin > #admin.autodiscover() > > > urlpatterns = patterns('', > # Example: > (r"^wap/di/sub/$",current_datetime), > # Uncomment the admin/doc line below to enable admin documentation: > # (r'^admin/doc/', include('django.contrib.admindocs.urls')), > > # Uncomment the next line to enable the admin: > # (r'^admin/', include(admin.site.urls)), > ) > > `~~~ > My view .py looks like this > > from django.http import * > import urllib > from django_restapi.responder import XMLResponder > > > def current_datetime(request): > word = request.GET['word'] > message = > urllib.urlopen('http://m.broov.com/wap/di/sub?word='+word+'&type=00submit=Submit',) > return XMLResponder(message) > > But my error is > Exception Value: > > 'XMLResponder' object has no attribute 'status_code' > > Exception Location: > D:\Python25\lib\site-packages\django\middleware\common.py in > process_response, line 94 > Judging from http://code.google.com/p/django-rest-interface/ you aren't using the XMLResponder class at all correctly. As far as I can tell, one is supposed to use XMLResponder to define a 'resource', which is then provide as the callable in urls.py. You are using it as a replacement for HttpResponse, which it isn't, and because it isn't you get the error you describe. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Query help
On Tue, Nov 2, 2010 at 9:35 AM, Itai Tavor wrote: > Hi people, > > Given this: > > class Category(models.Model): >name = models.CharField() >parent = models.ForeignKey('self', blank=True, null=True) >tree_path = models.CharField() # //.../// > > class Item(models.Model): >name = models.CharField() >categories = models.ManyToManyField(Category) > > I need a Category queryset, with each category annotated with a count of > items which have categories whose tree_path starts with the tree_path of the > current category, and with categories for which this count is 0 filtered > out. > > In case that wasn't clear - I need an efficient way to do this: > > You probably need to use annotate http://docs.djangoproject.com/en/dev/ref/models/querysets/#annotate-args-kwargs -- regards, Prashanth twitter: munichlinux blog: honeycode.in irc: munichlinux, JSLint, munichpython. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: 2D map application: performance and design question
On Tue, Nov 2, 2010 at 3:35 AM, Lars Ruoff wrote: > Ok, so having excluded SQLite and the static served files, I'd like to > test if the server matters. What would be a minimum Apache install and > config to run Django locally (on Windows)? again, that's _very_ unlikely to be the cause. why not profile a little? if you're not handy with a python profiler, just set a var 'starttime = datetime.now()' at the beginning of your view function and a few 'print(datetime.now() - starttime)' at strategic points. -- Javier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Repost Admin Site Without Graphics
Thanks. I'll try your suggestions. I am using the phrase no graphics to mean the admin site comes up, but doesn't have all the nice background. On Nov 1, 3:41 pm, Robbington wrote: > Hi, > > By 'with out graphics' do you mean no css or Javascript? > > If so you want to make sure the value for these 3 varibles are correct > as its not governed by the templates list. > > MEDIA_ROOT = ' /var/www/django_project/media' # Where media is the > copied folder of admin media or a symbolic link if you are using > Linux. > > MEDIA_URL = 'media/' > > ADMIN_MEDIA_PREFIX = '/media/' > > Rob -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Repost Admin Site Without Graphics
Tried suggestions, and still do not get full graphics. Everything else works. Users are displayed, and so on. On Nov 2, 12:24 pm, octopusgrabbus wrote: > Thanks. I'll try your suggestions. I am using the phrase no graphics > to mean the admin site comes up, but doesn't have all the nice > background. > > On Nov 1, 3:41 pm, Robbington wrote: > > > Hi, > > > By 'with out graphics' do you mean no css or Javascript? > > > If so you want to make sure the value for these 3 varibles are correct > > as its not governed by the templates list. > > > MEDIA_ROOT = ' /var/www/django_project/media' # Where media is the > > copied folder of admin media or a symbolic link if you are using > > Linux. > > > MEDIA_URL = 'media/' > > > ADMIN_MEDIA_PREFIX = '/media/' > > > Rob -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
rabbitmq + celery + django + celery.views.task_status ... simple example?
Hi All, So, I've got my django app, rabbitmq and celery working and processing my uploaded files. Next step is to get the client to display status results provided by JSON, ultimately refreshing to a results page when complete. I'm a little new to JSON / AJAX (AJAJ!) and I'm struggling a little with the templates and views part. Are there any easy examples out there? I can't seem to find any! Many thanks in advance for any suggestions. Cheers W -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django Country->State->City Dropdown list
URGENT! The following is my django code. I would like to have 3 column drop- down list. a member can select his location. when a country is selected, then all states for that country will display. the same thing happens to city. Now, I know it has something to do with Javascript. The question is there is no good tutorial for that Please help me. It is super urgent If you want to show links or code, it must come with a real working demo. I have gone thought all links found on google. Please direct me to the right direction. a simple step by step instruction is very helpful thanks from django.db import models class Member(models.Model): residing_country = models.CharField(max_length=50) residing_state = models.CharField(max_length=50) residing_city = models.CharField(max_length=50) class Country(models.Model): country= models.CharField(max_length=20) class State(models.Model): state=models.CharField(max_length=20) country = models.ForeignKey(Country) class City(models.Model): city=models.CharField(max_length=20) state=models.ForeignKey(State) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Country->State->City Dropdown list
Sounds like AJAX is your answer, there are lots of AJAX libraries out there that have examples on this. J On Nov 2, 10:31 am, d wrote: > URGENT! > The following is my django code. I would like to have 3 column drop- > down list. > > a member can select his location. > when a country is selected, then all states for that country will > display. the same thing happens to city. > > Now, I know it has something to do with Javascript. The question is > there is no good tutorial for that > > Please help me. It is super urgent > > If you want to show links or code, it must come with a real working > demo. I have gone thought all links found on google. > > Please direct me to the right direction. a simple step by step > instruction is very helpful > > thanks > > from django.db import models > > class Member(models.Model): > > residing_country = models.CharField(max_length=50) > residing_state = models.CharField(max_length=50) > residing_city = models.CharField(max_length=50) > > class Country(models.Model): > > country= models.CharField(max_length=20) > > class State(models.Model): > > state=models.CharField(max_length=20) > country = models.ForeignKey(Country) > > class City(models.Model): > > city=models.CharField(max_length=20) > state=models.ForeignKey(State) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Executing ssh scripts with django
> Would you execute the save function through celery? Is it safe? or maybe if > save() is executed asynchronously it can cause some unexpected behavior? You could use signals to trigger execution of celery tasks, e.g. the post_save signal: http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.post_save - Sævar -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Country->State->City Dropdown list
> The following is my django code. I would like to have 3 column drop- > down list. It sounds like you might want to check out Dajax (http://www.dajaxproject.com/), Dojango (http://code.google.com/p/dojango/) or JQuery (there are plenty of examples for using JQuery with Django out there). Cheers Jirka P.S. Starting your email with "URGENT" it likely to give you less responses, not more -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Physical / Logical Hrefs
Given the following in my main page template how does Django process logout? I am asking this, because I want an href to take an authenticated user to a page that, for example, allows the collection of some data (billing reads). I have an application within the project that will handle read snaps. I am assuming /read_snap will cause Django to jump to the read_snap application. Is that correct? tnx cmn {% extends "base.html" %} {% block title %}AMR Main Page {% endblock %} {% block head %}AMR Main Page {% endblock %} {% block content %} {% if user.is_authenticated %} Snap Billing Reads Log out {% else %} Log in {% endif %} {% endblock %} -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Country->State->City Dropdown list
Thanks. I can't find intuitive examples. Can anyone post a little simple 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Mod_Python and everything loaded, Apache serving HTML files without using Django first
Yeah i managed to get it all working before this ended up being posted. Thank you though. Also i host my stuff in different directories. Templates are served from /srv/www/sweetman, while my project code is stored in / sweetman_live/sweetman. So yeah. Thank you. I'm just fiddling with addressing errors now. It's a bit different than the manage.py runserver apparently :P On Nov 2, 3:31 am, Daniel Roseman wrote: > On Nov 1, 9:15 pm, The End wrote: > > > > > I've finally got mod_python and mysqldb working with apache (long > > story short, can't install wsgi for various reasons and i'm using > > python 2.4.3... for various reasons...). > > > However > > > Now when i load up the home page (just typing 'localhost' into > > firefox) i get the literal HTML representation of index.html, without > > the dynamics filling in. I can only assume that apache is not using > > Django to return these requests. > > > I only have 1 Virtual Host and Location tag in my entire Apache > > Configuration File (with all the standard stuff, i didn't turn > > anything off): > > > LoadModule python_module /usr/lib64/httpd/modules/mod_python.so > > > > > ServerName Sweetman > > ServerAdmin sweet...@sweetman.com > > DocumentRoot /srv/www/sweetman/ > > > > > SetHandler python-program > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE sweetman.settings > > PythonDebug On > > PythonPath "[ '/sweetman_live/sweetman' , '/usr/lib/ > > python2.4/site-packages/django/' , '/srv/www/'] + sys.path" > > > > > > > SetHandler none > > > > > ErrorLog /srv/www/sweetman/logs/error.log > > CustomLog /srv/www/sweetman/logs/access.log combined > > > > You've only set up mod_python to handle the 'sweetman' directory, not > the root. Change the "Location" to "/". > > Also note that it's a bad idea to keep your Django code and templates > under your DocumentRoot. Apart from anything else, it's a potential > security hole - if a misconfigured Apache can serve your templates > directly, it could also do so with your settings file containing your > db credentials. Put it all somewhere else - it just needs to be on > your PythonPath, which you're already modifying in the > configuration. > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Mod_Python and everything loaded, Apache serving HTML files without using Django first
This isn't directly related to your question, but mod_python is not a recommended method of deploying Django. Support for it will be deprecated. You might want to check out mod_wsgi. On Nov 1, 5:15 pm, The End wrote: > I've finally got mod_python and mysqldb working with apache (long > story short, can't install wsgi for various reasons and i'm using > python 2.4.3... for various reasons...). > > However > > Now when i load up the home page (just typing 'localhost' into > firefox) i get the literal HTML representation of index.html, without > the dynamics filling in. I can only assume that apache is not using > Django to return these requests. > > I only have 1 Virtual Host and Location tag in my entire Apache > Configuration File (with all the standard stuff, i didn't turn > anything off): > > LoadModule python_module /usr/lib64/httpd/modules/mod_python.so > > > ServerName Sweetman > ServerAdmin sweet...@sweetman.com > DocumentRoot /srv/www/sweetman/ > > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE sweetman.settings > PythonDebug On > PythonPath "[ '/sweetman_live/sweetman' , '/usr/lib/ > python2.4/site-packages/django/' , '/srv/www/'] + sys.path" > > > > SetHandler none > > > ErrorLog /srv/www/sweetman/logs/error.log > CustomLog /srv/www/sweetman/logs/access.log combined > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to log all the error and warning messages with apache ???
Hi everybody: This is a configuration question I am having an error in a django website that is hosted in a debian apache mysql server, I have DEPLOY_DEBUG = True but the error is not showed when is raised, I have searched in some logs files like /var/log/syslog , error.log and access.log but the errors are no record in there. Could you help me please, how can I registered in logs files all the errors of the django aplications with apache ??? I need help urgent. I would thanks any help. Regards Ariel -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: admin usage
I always had the opposite impression. The Admin can be modified quite extensively to handle most cases for regular, on-going, data entry for multiple models. This means you have consistency and built-in cohesiveness (less chance for errors because you are using existing code). Its for specialised edge-cases that you will need your own interface. This might be your situation...? On Oct 29, 11:16 pm, Carlos Daniel Ruvalcaba Valenzuela wrote: > I have always had the notion that the admin interface is more about > adding data to the system quickly rather than being the system itself, > the admin interface is very powerful indeed, but I think you may have > better customization/simplification options on your own and reserve > the admin interface for certain tasks (such as adding data like > inventory part numbers) that are not your daily use case o central > functionality. > > Regards, > Carlos Daniel Ruvalcaba > > > > > > > > On Fri, Oct 29, 2010 at 1:55 PM, Frank Wiles wrote: > > On Fri, Oct 29, 2010 at 3:13 AM, Alex Kreimer > > wrote: > >> Hi All, > > >> I'm building an app for small retail chain management. It requires > >> inventory/salespeople/wages etc. management. There 2 kinds of users: > >> updaters (non-tech managers that are responsible sales locations) and > >> viewers (main office managers that control the organization). > > >> 1 Would django admin be suitable for all the update tasks (it looks > >> like admin would be seriously tweaked for this) or should a separate > >> interface be built? > > >> 2 Is there a ready piece of code that could be used as a stub for such > >> a task? > > > While you could definitely shoe horn this into the admin with a bunch > > of customizations, you're likely better off just writing your own > > interface for these tasks. My general rule of thumb is if the end user > > isn't "techie" or they will be using the interface many times per day > > I don't use the admin. > > > Don't get me wrong, the admin is great, but it isn't ideal for many > > repetitive tasks. > > > -- > > Frank Wiles > > Revolution Systems |http://www.revsys.com/ > > fr...@revsys.com | (800) 647-6298 > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: admin usage
And my thoughts are echoed in this parallel thread I just came across: http://groups.google.com/group/django-users/browse_thread/thread/935d64cb03730b73 On Nov 2, 9:12 pm, derek wrote: > I always had the opposite impression. The Admin can be modified quite > extensively to handle most cases for regular, on-going, data entry for > multiple models. This means you have consistency and built-in > cohesiveness (less chance for errors because you are using existing > code). Its for specialised edge-cases that you will need your own > interface. This might be your situation...? > > On Oct 29, 11:16 pm, Carlos Daniel Ruvalcaba Valenzuela > > > > > > > > wrote: > > I have always had the notion that the admin interface is more about > > adding data to the system quickly rather than being the system itself, > > the admin interface is very powerful indeed, but I think you may have > > better customization/simplification options on your own and reserve > > the admin interface for certain tasks (such as adding data like > > inventory part numbers) that are not your daily use case o central > > functionality. > > > Regards, > > Carlos Daniel Ruvalcaba > > > On Fri, Oct 29, 2010 at 1:55 PM, Frank Wiles wrote: > > > On Fri, Oct 29, 2010 at 3:13 AM, Alex Kreimer > > > wrote: > > >> Hi All, > > > >> I'm building an app for small retail chain management. It requires > > >> inventory/salespeople/wages etc. management. There 2 kinds of users: > > >> updaters (non-tech managers that are responsible sales locations) and > > >> viewers (main office managers that control the organization). > > > >> 1 Would django admin be suitable for all the update tasks (it looks > > >> like admin would be seriously tweaked for this) or should a separate > > >> interface be built? > > > >> 2 Is there a ready piece of code that could be used as a stub for such > > >> a task? > > > > While you could definitely shoe horn this into the admin with a bunch > > > of customizations, you're likely better off just writing your own > > > interface for these tasks. My general rule of thumb is if the end user > > > isn't "techie" or they will be using the interface many times per day > > > I don't use the admin. > > > > Don't get me wrong, the admin is great, but it isn't ideal for many > > > repetitive tasks. > > > > -- > > > Frank Wiles > > > Revolution Systems |http://www.revsys.com/ > > > fr...@revsys.com | (800) 647-6298 > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com. > > > For more options, visit this group > > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Trying to determine the duplicate SQL queries from my view code
OK so I have solved this, the flaw being my understanding of the cacheing of Django database QuerySets. I still have not eliminated the double auth_user request because one is made in the @login_required directive and the other is made in the view code to pass user data to the template. However it is easy to see how in Django: # Set the course_id course_id = enrollment.course.id # Get the requested course course = Course.objects.get(id__exact=course_id) Will result in two separate queries to get the course with that id. It can be solved easily with: # Get requested course and set the course_id course = enrollment.course.id course_id = course.id which reduces the number of SQL queries by 1 each page request or shaves off about .4ms per page view. -Matteius On Nov 1, 1:24 pm, Matteius wrote: > In this case there is no form POST data so that code gets skipped. I > started profiling with the django_debugger_toolbar and my SQL data > results are at the bottom. There are duplicate SQL select statements > for handin_course and auth_user which doesn't make sense to me as I > understand how views should work ... > > # > # courseassignments - Course Assignments View > # > @login_required > def course_assignments(request, enrollment_id): > # Request enrollment > enrollment = Enrollment.objects.get(id__exact=enrollment_id) > > # Determine access level and create default behavior > flag = verifyEnrollment(request, enrollment) > template = loader.get_template('handin/course_blocked.html') > context = RequestContext(request, {"user": request.user, "flag": > flag} ) > > # If access is granted > if flag == 1: > # If we have post data process the form > if request.POST: > > # Determine if submission is late > assignment = > Assignment.objects.get(id__exact=request.POST['assignment']) > onTime = True > try: > # First see if there is a due date override > dueDate = > DueDateOverride.objects.filter(enrollment=enrollment.id).filter(assignment=assignment.id) > [0] > if > isLateNow( adjustDateDays( adjustDateWeeks(enrollment.start_date, > dueDate.weeks_after), dueDate.days_after)): > onTime = False > except IndexError: > # If not, see if there is a global due date > if assignment.apply_due_date: > if > isLateNow( adjustDateDays( adjustDateWeeks(enrollment.start_date, > assignment.weeks_after), assignment.days_after)): > onTime = False > > instance = Submission(enrollment_id=enrollment.id, > assignment_id=request.POST['assignment'], on_time=onTime) > newSubmission = SubmissionForm(request.POST, request.FILES, > instance=instance) > newSubmission.save() > return > HttpResponseRedirect(reverse('classcomm.handin.views.course_assignments', > args=(enrollment.id,))) > > # Set the course_id > course_id = enrollment.course.id > > # Get the requested course > course = Course.objects.get(id__exact=course_id) > > # Find the assignments for the requested course > assignments = Assignment.objects.all().filter(course=course_id) > > # Find the grades for the current enrollment > grades = Grade.objects.all().filter(enrollment=enrollment.id) > > # Find the submissions for the current enrollment > submissions = > Submission.objects.all().filter(enrollment=enrollment.id) > > # Find the due date overrides for the current enrollment > dueDateOverrides = > DueDateOverride.objects.all().filter(enrollment=enrollment.id) > > # Create assignmentDataList for easy template cycle > # [Assignment, current Submission, current Grade, current > DueDateOverride] > assignmentDataList = list() > for assignment in assignments: > # Find the submission > currentSubmission = None > for submission in submissions: > if submission.assignment_id == assignment.id: > currentSubmission = submission > # Find the grade > currentGrade = None > for grade in grades: > if grade.assignment_id == assignment.id: > currentGrade = grade > # Find a due date override > currentDDO = None > for dueDateOverride in dueDateOverrides: > if dueDateOverride.assignment_id == assignment.id: > currentDDO = dueDateOverrides > # Add the tupple to a list > assignmentDataList.append( (assignment, currentSubmission, > currentGrade, currentDDO) ) > > # Create an assignment submission form > form = SubmissionForm() > > # Set template; Create context > template = loader.get_template('handin/course_assignments.html') > context = RequestConte
Re: Repost Admin Site Without Graphics
So your admin media (js, css, images, etc) isn't working? Try two things: 1. Open the source of some admin page. Look at some image, css, or js object. Find the path where it is pointing. Does this path makes sense? (Have you put it in the settings.py file?) 2. Check your site settings. If you are using django's web server, it will serve the admin files automatically, if you are using apache or some other web server, you will have to specify where the admin site's files are, like Robbington said. Compare the path in the settings file to the one that is being served. ... On Tue, Nov 2, 2010 at 11:58 AM, octopusgrabbus wrote: > Tried suggestions, and still do not get full graphics. Everything else > works. Users are displayed, and so on. > > On Nov 2, 12:24 pm, octopusgrabbus wrote: >> Thanks. I'll try your suggestions. I am using the phrase no graphics >> to mean the admin site comes up, but doesn't have all the nice >> background. >> >> On Nov 1, 3:41 pm, Robbington wrote: >> >> > Hi, >> >> > By 'with out graphics' do you mean no css or Javascript? >> >> > If so you want to make sure the value for these 3 varibles are correct >> > as its not governed by the templates list. >> >> > MEDIA_ROOT = ' /var/www/django_project/media' # Where media is the >> > copied folder of admin media or a symbolic link if you are using >> > Linux. >> >> > MEDIA_URL = 'media/' >> >> > ADMIN_MEDIA_PREFIX = '/media/' >> >> > Rob -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
manage.py sqlall and db upgrade
I've got my first major django production app deployed and have to upgrade my DB to meet some new requirements. I've tried South, but got into a death spiral and my changes are not so significant that I can't do it by brute force. In researching brute force, it seems like syncdb loads my initial tables from the .../myqpp/sql/xyz.sql files just fine. So what do I achieve with manage.py sqlall myapp -- I don't see the value and the docs don't say why, only how. Right now I'm planning to 1. use drop/create database to assure a blank slate 2. use syncdb to create my new tables 3. use >mysql mydbname http://groups.google.com/group/django-users?hl=en.
Re: manage.py sqlall and db upgrade
It would be in your benefit to learn why South failed, because it's been very stable for me, and may be an indication of something else being wrong with your app and/or models. -- Michael On Tue, 2010-11-02 at 15:27 -0400, Sells, Fred wrote: > I've got my first major django production app deployed and have to > upgrade my DB to meet some new requirements. I've tried South, but got > into a death spiral and my changes are not so significant that I can't > do it by brute force. > > In researching brute force, it seems like syncdb loads my initial tables > from the .../myqpp/sql/xyz.sql files just fine. > > So what do I achieve with manage.py sqlall myapp -- I don't see the > value and the docs don't say why, only how. > > Right now I'm planning to > 1. use drop/create database to assure a blank slate > 2. use syncdb to create my new tables > 3. use >mysql mydbname options to not include structure, just insert statements > 4. Imay need to reload the data in myapp/sql directory because may wipe > it out. > > Basically the first 10 records in each table contain a template pattern > of which fields are disabled under certain circumstances, and that data > has changed slightly for 2 tables. > > South may make more sense in the future, but I'm up to my #$%%# in > alligators and the swamp must wait. > > Is there anything I'm missing or am I doing something "the hard 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Change the initial data to a modelForm
Hello list. I have a model "PP" with a "float" field "val" and a modelform for this model For update the data of a existent "PP" I use a form like this Form_for_PP(request,POST, instance=instance) Now my question is, Can I change the initial data for the field "val"? I want to do this: If the value in "val" is 12345.6, the resulting form must to have the value "12.345,6" (the same value, but formatted) I can't find the way to do this when I use an instance. Set an "initial" don't work, the returning value is always the existing in the DB. Somebody can help me? Thanks for read, and sorry for my poor english. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Change the initial data to a modelForm
I don't think you need to change the value, but rather add localization so add proper formatting. http://docs.djangoproject.com/en/dev/topics/i18n/localization/#format-localization -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: 2D map application: performance and design question
Ok, thanks for the suggestion, Javier. I implemented this and it showed: I'm spending about 0.2 secs for the queries, but 1.5 secs for t.render(c) ! So rendering the template seems to take a significant amount of time! As you can see, my template code iterates over about 13*13=169 objects that have been passed in the context. I then made tests to reduce this number. Here is the result of time spent for the query and render() as a function of the grid size: 3*3: 0.03s, 0.1s 5*5: 0.04s, 0.25s 7*7: 0.08s, 0.45s 9*9: 0.13s, 0.72s 11*11: 0.17s, 1.1s 13*13: 0.2s, 1.5s Lars On Nov 2, 4:46 pm, Javier Guerra Giraldez wrote: > On Tue, Nov 2, 2010 at 3:35 AM, Lars Ruoff wrote: > > Ok, so having excluded SQLite and the static served files, I'd like to > > test if the server matters. What would be a minimum Apache install and > > config to run Django locally (on Windows)? > > again, that's _very_ unlikely to be the cause. why not profile a > little? if you're not handy with a python profiler, just set a var > 'starttime = datetime.now()' at the beginning of your view function > and a few 'print(datetime.now() - starttime)' at strategic points. > > -- > Javier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Empty Response
I am returning a json structure in one of my views after the user performs a search when I only run Django's built in server. Following the asynchronous GET I get a response with the expected json structure which I can then use to populate the page. However, when I have Apache in front, the response is empty. And this appears to be only when I make an AJAX request since all of the other requests and responses produce the expected results. I don't know how to go about troubleshooting this. Does anybody know what is going on here? Or, how to troubleshoot this? Thanks! Eric -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Change the initial data to a modelForm
Thanks, you are the best -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: 2D map application: performance and design question
I would suggest rewriting the loop in your template as a templatetag. Something like this @register.simple_tag def render_locations(locations): html = u""" html %(x)s stuff %(y)s here %(link)s """ return '\n'.join([html % { 'x': loc.x, 'y': loc.y', 'link': loc.link } for loc in locations]) I've used this approach a few times with good results for my use cases. Regards Knut On Tue, Nov 2, 2010 at 9:28 PM, Lars Ruoff wrote: > Ok, thanks for the suggestion, Javier. > I implemented this and it showed: > I'm spending about > 0.2 secs for the queries, > but 1.5 secs for t.render(c) ! > > So rendering the template seems to take a significant amount of time! > As you can see, my template code iterates over about 13*13=169 objects > that have been passed in the context. > I then made tests to reduce this number. Here is the result of time > spent for the query and render() as a function of the grid size: > 3*3: 0.03s, 0.1s > 5*5: 0.04s, 0.25s > 7*7: 0.08s, 0.45s > 9*9: 0.13s, 0.72s > 11*11: 0.17s, 1.1s > 13*13: 0.2s, 1.5s > > Lars > > > On Nov 2, 4:46 pm, Javier Guerra Giraldez wrote: >> On Tue, Nov 2, 2010 at 3:35 AM, Lars Ruoff wrote: >> > Ok, so having excluded SQLite and the static served files, I'd like to >> > test if the server matters. What would be a minimum Apache install and >> > config to run Django locally (on Windows)? >> >> again, that's _very_ unlikely to be the cause. why not profile a >> little? if you're not handy with a python profiler, just set a var >> 'starttime = datetime.now()' at the beginning of your view function >> and a few 'print(datetime.now() - starttime)' at strategic points. >> >> -- >> Javier > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Validate single field in model
Hello, I try to validate a single field in a model. I know I can validate the field in a ModelForm like: def clean_FIELDNAME(self): if self == 'This is a test': raise forms.ValidationError("ValidationError") But can i do something similar in the Model itself ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Struggling with aggregation/annotation
Hi, currently I am moving my django project towards Django 1.2. During that step I want to replace code like that query_set = query_set.extra(select = { 'image_count': '''SELECT COUNT(*) FROM image WHERE topic.id = image.topic_id AND topic.trashed_at = image.trashed_at''', 'video_count': '''SELECT COUNT(*) FROM video WHERE topic.id = video.topic_id AND topic.trashed_at = video.trashed_at''', }) Selecting a topic instance or a list of topic instances I also want to know the amount of images associated with the topic, which share the same value for trashed_at. Can this be written using the annotate method and the Count class? Best regards, Oliver -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Validate single field in model
> But can i do something similar in the Model itself ? Hi, have you checked the documentation? http://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: html in django password_reset_email.html
On Nov 2, 4:50 am, Tom Evans wrote: > On Tue, Nov 2, 2010 at 9:07 AM, andy wrote: > > I recently tried to send the following in a test password email from a > > site I am creating: > > > This is a test reset password email. > > > However when I received the email it displayed the "This is a test > > reset password email.". > > > My question is how can I send a styled email using html tags and > > possibly even css when using the password_reset_email.html template > > that goes with django's view.password_reset? > > I don't know about the specifics of your particular issues, but to > send HTML emails: > > Create an instance of django.core.mail.EmailMultiAlternatives, passing > in your subject, text version of the email, from address, list of > recipients. Render your HTML version of the email, and attach it to > the email, and then send it. > > eg: > > from django.core.mail import EmailMultiAlternatives > msg = EmailMultiAlternatives('Subject', 'This is the text version', > 'f...@address.com', [ 'recipie...@address.com',]) > html_version = ... > msg.attach_alternative(html_version, 'text/html') > msg.send() > > There are lots of 'gotchas' when sending HTML email. Don't expect > externally referenced resources to be available, don't expect styles > to work correctly in all UAs, don't expect any JS to work. > > Cheers > > Tom Thanks for the reply, Django password_reset view used send_mail() which seem to send only text. apparently you have to use EmailMultiAlternatives as you pointed out to send html content guess I will have to create my own view and use this instead if I want to send html. Then again it is probably a good idea to send password reset information in plant text. Since it pretty any email client would be able to read plain text. Thanks again Kimani -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: html in django password_reset_email.html
On Nov 2, 4:50 am, Tom Evans wrote: > On Tue, Nov 2, 2010 at 9:07 AM, andy wrote: > > I recently tried to send the following in a test password email from a > > site I am creating: > > > This is a test reset password email. > > > However when I received the email it displayed the "This is a test > > reset password email.". > > > My question is how can I send a styled email using html tags and > > possibly even css when using the password_reset_email.html template > > that goes with django's view.password_reset? > > I don't know about the specifics of your particular issues, but to > send HTML emails: > > Create an instance of django.core.mail.EmailMultiAlternatives, passing > in your subject, text version of the email, from address, list of > recipients. Render your HTML version of the email, and attach it to > the email, and then send it. > > eg: > > from django.core.mail import EmailMultiAlternatives > msg = EmailMultiAlternatives('Subject', 'This is the text version', > 'f...@address.com', [ 'recipie...@address.com',]) > html_version = ... > msg.attach_alternative(html_version, 'text/html') > msg.send() > > There are lots of 'gotchas' when sending HTML email. Don't expect > externally referenced resources to be available, don't expect styles > to work correctly in all UAs, don't expect any JS to work. > > Cheers > > Tom Thanks for the reply, Django password_reset view used send_mail() which seem to send only text. apparently you have to use EmailMultiAlternatives as you pointed out to send html content guess I will have to create my own view and use this instead if I want to send html. Then again it is probably a good idea to send password reset information in plant text. Since it pretty any email client would be able to read plain text. Thanks again Kimani -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: html in django password_reset_email.html
On Nov 2, 4:50 am, Tom Evans wrote: > On Tue, Nov 2, 2010 at 9:07 AM, andy wrote: > > I recently tried to send the following in a test password email from a > > site I am creating: > > > This is a test reset password email. > > > However when I received the email it displayed the "This is a test > > reset password email.". > > > My question is how can I send a styled email using html tags and > > possibly even css when using the password_reset_email.html template > > that goes with django's view.password_reset? > > I don't know about the specifics of your particular issues, but to > send HTML emails: > > Create an instance of django.core.mail.EmailMultiAlternatives, passing > in your subject, text version of the email, from address, list of > recipients. Render your HTML version of the email, and attach it to > the email, and then send it. > > eg: > > from django.core.mail import EmailMultiAlternatives > msg = EmailMultiAlternatives('Subject', 'This is the text version', > 'f...@address.com', [ 'recipie...@address.com',]) > html_version = ... > msg.attach_alternative(html_version, 'text/html') > msg.send() > > There are lots of 'gotchas' when sending HTML email. Don't expect > externally referenced resources to be available, don't expect styles > to work correctly in all UAs, don't expect any JS to work. > > Cheers > > Tom Thanks for the reply, Django password_reset view used send_mail() which seem to send only text. apparently you have to use EmailMultiAlternatives as you pointed out to send html content guess I will have to create my own view and use this instead if I want to send html. Then again it is probably a good idea to send password reset information in plant text. Since it pretty any email client would be able to read plain text. Thanks again Kimani -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Empty Response
On 11/02/2010 09:29 PM, Eric wrote: I am returning a json structure in one of my views after the user performs a search when I only run Django's built in server. Following the asynchronous GET I get a response with the expected json structure which I can then use to populate the page. However, when I have Apache in front, the response is empty. And this appears to be only when I make an AJAX request since all of the other requests and responses produce the expected results. I don't know how to go about troubleshooting this. Does anybody know what is going on here? Or, how to troubleshoot this? Some random tips: Take a hard look at what's actually being returned. Empty response, apparently. But what about the http status code? 200 OK or 500 AARGH_ERROR? Or something that's just not parsed as valid json? Or perhaps an invalid mimetype? Useful tools: firebug (lets you inspect the headers). Or just "wget" in a pretty verbose mode. Reinout -- Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org Collega's gezocht! Django/python vacature in Utrecht: http://tinyurl.com/35v34f9 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: html in django password_reset_email.html
On Nov 2, 4:50 am, Tom Evans wrote: > On Tue, Nov 2, 2010 at 9:07 AM, andy wrote: > > I recently tried to send the following in a test password email from a > > site I am creating: > > > This is a test reset password email. > > > However when I received the email it displayed the "This is a test > > reset password email.". > > > My question is how can I send a styled email using html tags and > > possibly even css when using the password_reset_email.html template > > that goes with django's view.password_reset? > > I don't know about the specifics of your particular issues, but to > send HTML emails: > > Create an instance of django.core.mail.EmailMultiAlternatives, passing > in your subject, text version of the email, from address, list of > recipients. Render your HTML version of the email, and attach it to > the email, and then send it. > > eg: > > from django.core.mail import EmailMultiAlternatives > msg = EmailMultiAlternatives('Subject', 'This is the text version', > 'f...@address.com', [ 'recipie...@address.com',]) > html_version = ... > msg.attach_alternative(html_version, 'text/html') > msg.send() > > There are lots of 'gotchas' when sending HTML email. Don't expect > externally referenced resources to be available, don't expect styles > to work correctly in all UAs, don't expect any JS to work. > > Cheers > > Tom Thanks for the reply, Django password_reset view used send_mail() which seem to send only text. apparently you have to use EmailMultiAlternatives as you pointed out to send html content guess I will have to create my own view and use this instead if I want to send html. Then again it is probably a good idea to send password reset information in plant text. Since it pretty any email client would be able to read plain text. Thanks again Kimani -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin without template (no colors, no css, just simple html)
How can I create that symbolic link? :S __ On Oct 26, 7:07 am, Daniel Roseman wrote: > On Oct 26, 1:25 pm, Giancarlo Razzolini wrote: > > > I had this same problem when hosting it with apache. I solved the > > problem by creating a symbolic link inside my media folder pointing to > > the admin site that is instaled with django. Something like this: > > > admin -> /usr/share/pyshared/django/contrib/admin/media/ > > > Of course, this would only work in unix environments. I've tried to > > solve it by tweaking with the settings.py file, but couldn't find a > > solution. The link did the trick. > > > My regards, > > There's no tweaking of settings.py that can somehow 'fix' this. > Setting up Apache to serve the files is the only correct thing to do, > whether that's by symlinking or whatever. > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
RE: manage.py sqlall and db upgrade
I believe it failed because I changed the tablename in the meta data and that may have conflicted with some tables my boss inserted usring raw sql and basic programming language. -Original Message- From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On Behalf Of Michael Sent: Tuesday, November 02, 2010 3:31 PM To: django-users@googlegroups.com Subject: Re: manage.py sqlall and db upgrade It would be in your benefit to learn why South failed, because it's been very stable for me, and may be an indication of something else being wrong with your app and/or models. -- Michael On Tue, 2010-11-02 at 15:27 -0400, Sells, Fred wrote: > I've got my first major django production app deployed and have to > upgrade my DB to meet some new requirements. I've tried South, but got > into a death spiral and my changes are not so significant that I can't > do it by brute force. > > In researching brute force, it seems like syncdb loads my initial tables > from the .../myqpp/sql/xyz.sql files just fine. > > So what do I achieve with manage.py sqlall myapp -- I don't see the > value and the docs don't say why, only how. > > Right now I'm planning to > 1. use drop/create database to assure a blank slate > 2. use syncdb to create my new tables > 3. use >mysql mydbname options to not include structure, just insert statements > 4. Imay need to reload the data in myapp/sql directory because may wipe > it out. > > Basically the first 10 records in each table contain a template pattern > of which fields are disabled under certain circumstances, and that data > has changed slightly for 2 tables. > > South may make more sense in the future, but I'm up to my #$%%# in > alligators and the swamp must wait. > > Is there anything I'm missing or am I doing something "the hard 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Change the initial data to a modelForm
This don't work to me. Now I must to use the "." like a thousand separator and the "," like decimal separator (x.xxx,xx) (requirement of the boss). I try to follow the guide to "custom format fields" in the Django documentation, but I can't get formatted numbers. I have this: mysite/ formats/ __init__.py es/ __init__.py formats.py -- And in my settings.py USE_I18N = True USE_L10N = True FORMAT_MODULE_PATH = 'formats.es.formats' Nothing more. Where is my error? The FORMAT_MODULE_PATH must to be other? I must to declare the FORMAT_MODULE_PATH in other side? I must to include some library in the view? This is the first time when I work with localization. Thanks for read. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin without template (no colors, no css, just simple html)
I have made somthing like: ln -s $HOME/.local/lib/python2.6/site-packages/django/contrib/admin/ media $HOME/.public_html/media And this create a folder with three folders more in my public_html (js, css, images) but it still don't working. also I do: ln -s $HOME/.local/lib/python2.6/site-packages/django/contrib/admin/ media $HOME/.local/lib/python2.6/site-packages/myproject and nothing. but if I go to: http://mydomain.com/media it tells me that I dont have permission, so that means that the folder has been created, and If i check the sorce code of the admin, and I click the link for the css (href="/media/css/base.css") I can`t because the permission, so I think this part is right. What I need to do? :S On Oct 26, 10:56 am, Giancarlo Razzolini wrote: > So I did the right thing... nice! > > Giancarlo Razzolinihttp://lock.razzolini.adm.br > Linux User 172199 > Red Hat Certified Engineer no:804006389722501 > Verify:https://www.redhat.com/certification/rhce/current/ > Moleque Sem Conteudo Numero #002 > OpenBSD 4.5 > Ubuntu 9.04 Jaunty Jackalope > 4386 2A6F FFD4 4D5F 5842 6EA0 7ABE BBAB 9C0E 6B85 > > > > > > > > Daniel Roseman wrote: > > On Oct 26, 1:25 pm, Giancarlo Razzolini wrote: > > >> I had this same problem when hosting it with apache. I solved the > >> problem by creating a symbolic link inside my media folder pointing to > >> the admin site that is instaled with django. Something like this: > > >> admin -> /usr/share/pyshared/django/contrib/admin/media/ > > >> Of course, this would only work in unix environments. I've tried to > >> solve it by tweaking with the settings.py file, but couldn't find a > >> solution. The link did the trick. > > >> My regards, > > > There's no tweaking of settings.py that can somehow 'fix' this. > > Setting up Apache to serve the files is the only correct thing to do, > > whether that's by symlinking or whatever. > > -- > > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Empty Response
You can easily look at the request/response by using firebug. TIP: Notice if there is a redirect. Sometimes depending on the config, for example, if django is set to append a / at the end, meaning it will do a redirect, then your request or response might be getting lost in the redirect (an HTTP 302) http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html When you have django running with apache config might be different. So first step is look in firebug what requests are being made. On Nov 2, 3:13 pm, Reinout van Rees wrote: > On 11/02/2010 09:29 PM, Eric wrote: > > > I am returning a json structure in one of my views after the user > > performs a search when I only run Django's built in server. Following > > the asynchronous GET I get a response with the expected json > > structure which I can then use to populate the page. > > > However, when I have Apache in front, the response is empty. And this > > appears to be only when I make an AJAX request since all of the other > > requests and responses produce the expected results. > > > I don't know how to go about troubleshooting this. > > > Does anybody know what is going on here? Or, how to troubleshoot this? > > Some random tips: > > Take a hard look at what's actually being returned. Empty response, > apparently. But what about the http status code? 200 OK or 500 > AARGH_ERROR? Or something that's just not parsed as valid json? Or > perhaps an invalid mimetype? > > Useful tools: firebug (lets you inspect the headers). Or just "wget" in > a pretty verbose mode. > > Reinout > > -- > Reinout van Rees - rein...@vanrees.org -http://reinout.vanrees.org > Collega's gezocht! > Django/python vacature in Utrecht:http://tinyurl.com/35v34f9 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Query help
On 03/11/2010, at 2:10 AM, Prashanth wrote: > > > On Tue, Nov 2, 2010 at 9:35 AM, Itai Tavor wrote: > Hi people, > > Given this: > > class Category(models.Model): >name = models.CharField() >parent = models.ForeignKey('self', blank=True, null=True) >tree_path = models.CharField() # //.../// > > class Item(models.Model): >name = models.CharField() >categories = models.ManyToManyField(Category) > > I need a Category queryset, with each category annotated with a count of > items which have categories whose tree_path starts with the tree_path of the > current category, and with categories for which this count is 0 filtered out. > > In case that wasn't clear - I need an efficient way to do this: > > > > You probably need to use annotate > http://docs.djangoproject.com/en/dev/ref/models/querysets/#annotate-args-kwargs Thanks, but I don't think it this particular query can be done just with django annotations. If it can, I don't know how. But I think it would require either an extra select or raw SQL. Itai -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Import csv file in admin
Jirka & Everybody Back to basics is always a good advice. With your help and this guy: http://www.beardygeek.com/2010/03/adding-views-to-the-django-admin/ I can create a form to upload csv files and input their records into the database. Short history: Forms.py: class DataInput(forms.Form): file = forms.FileField() place = forms.ModelChoiceField(queryset=Place.objects.all()) def save(self): records = csv.reader(self.cleaned_data["file"]) for line in records: input_data = Data() input_data.place = self.cleaned_data["place"] input_data.time = datetime.strptime(line[1], "%m/%d/%y %H: %M:%S") input_data.data_1 = line[2] input_data.data_2 = line[3] input_data.data_3 = line[4] This form was imported in a view: @staff_member_required def import(request): if request.method == "POST": form = DataInput(request.POST, request.FILES) if form.is_valid(): form.save() success = True context = {"form": form, "success": success} return render_to_response("imported.html", context, context_instance=RequestContext(request)) else: form = DataInput() contexto = {"form": form} return render_to_response("imported.html", context, context_instance=RequestContext(request)) And add the url pattern & some little changes to the admin index template, and everything works the way i want. Thanks guys! On Oct 31, 6:01 am, Jirka Vejrazka wrote: > > I try to follow the ideas, but i feel like taking the dirty way. > > Here's my work: > > Because i can't replace the modelform created by the admin for the > > "Data" model with a standard form as the Django docs says, i created a > > view to replace the "add" view generated by the admin and put a > > standard form: > > Jorge, > > I think you need to get back to basics and try to understand what is > run where. All the code you are writing for Django is run on the > server and only web pages are *displayed* to users on their machines. > This means that in order to import a CSV file, you need to transfer it > to the server first and then you'll be able to import it there. > > Note that this has nothing to do with the admin site. This is a > fundamental think to understand. > > I'd suggest that you forget the admin site for the moment and focus > on the "transfer CSV file to server first". Take a look at the email > Felix has sent you regarding FileField and try to code the part that > handles file upload to the server. Once you have that, you can start > thinking about importing the contents of the file into the database. > > Cheers > > Jirka > > P.S. OK, there is a way to import data without uploading them to > server first, but it's much more complicated than the one outlined > above and involves multiple different technologies that have to work > together. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: admin usage
Probably so, we do have stuff that tends to be JavaScript intensive at times, in some places we have a few AJAX queries (for example selecting a warehouse and loading the relevant part numbers for the next field based on the client) that may not be necessary, to stuff like Maps with OpenLayers for routing or pinpointing locations. What kind of applications/situations do you find more suited for reusing the admin module? Regards, Carlos Ruvalcaba On Tue, Nov 2, 2010 at 12:12 PM, derek wrote: > I always had the opposite impression. The Admin can be modified quite > extensively to handle most cases for regular, on-going, data entry for > multiple models. This means you have consistency and built-in > cohesiveness (less chance for errors because you are using existing > code). Its for specialised edge-cases that you will need your own > interface. This might be your situation...? > > On Oct 29, 11:16 pm, Carlos Daniel Ruvalcaba Valenzuela > wrote: >> I have always had the notion that the admin interface is more about >> adding data to the system quickly rather than being the system itself, >> the admin interface is very powerful indeed, but I think you may have >> better customization/simplification options on your own and reserve >> the admin interface for certain tasks (such as adding data like >> inventory part numbers) that are not your daily use case o central >> functionality. >> >> Regards, >> Carlos Daniel Ruvalcaba >> >> >> >> >> >> >> >> On Fri, Oct 29, 2010 at 1:55 PM, Frank Wiles wrote: >> > On Fri, Oct 29, 2010 at 3:13 AM, Alex Kreimer >> > wrote: >> >> Hi All, >> >> >> I'm building an app for small retail chain management. It requires >> >> inventory/salespeople/wages etc. management. There 2 kinds of users: >> >> updaters (non-tech managers that are responsible sales locations) and >> >> viewers (main office managers that control the organization). >> >> >> 1 Would django admin be suitable for all the update tasks (it looks >> >> like admin would be seriously tweaked for this) or should a separate >> >> interface be built? >> >> >> 2 Is there a ready piece of code that could be used as a stub for such >> >> a task? >> >> > While you could definitely shoe horn this into the admin with a bunch >> > of customizations, you're likely better off just writing your own >> > interface for these tasks. My general rule of thumb is if the end user >> > isn't "techie" or they will be using the interface many times per day >> > I don't use the admin. >> >> > Don't get me wrong, the admin is great, but it isn't ideal for many >> > repetitive tasks. >> >> > -- >> > Frank Wiles >> > Revolution Systems |http://www.revsys.com/ >> > fr...@revsys.com | (800) 647-6298 >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "Django users" group. >> > To post to this group, send email to django-us...@googlegroups.com. >> > To unsubscribe from this group, send email to >> > django-users+unsubscr...@googlegroups.com. >> > For more options, visit this group >> > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Attributr error
I want my final result in xml format and how can i do that? thanks for notification -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: rabbitmq + celery + django + celery.views.task_status ... simple example?
On Tue, Nov 2, 2010 at 10:42 PM, wawa wawawa wrote: > Hi All, > > So, I've got my django app, rabbitmq and celery working and processing > my uploaded files. Next step is to get the client to display status > results provided by JSON, ultimately refreshing to a results page when > complete. > > I'm a little new to JSON / AJAX (AJAJ!) and I'm struggling a little > with the templates and views part. > > Are there any easy examples out there? > > Is the expectation like user will upload a file and will see a result? if that is case why are using celery? b-list has a ajax example[1]. BTW, if you are trying to upload a file using ajax you need to create iframe using javascript, you might want to use jsupload[2] [1] http://www.b-list.org/weblog/2006/jul/31/django-tips-simple-ajax-example-part-1/ [2] http://valums.com/ -- regards, Prashanth twitter: munichlinux blog: honeycode.in irc: munichlinux, JSLint, munichpython. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: admin usage
My applications are in the science domain, where data entry is quite intensive. Aspects such as AJAX and dynamic lookups have been incorporated into the standard Admin. Obviously there is additional functionality that had to be added; e.g. adding data via uploads from spreadsheets, and point locations on maps. Data "extraction" - reporting and querying - has had to be written as well. These are included as "seamless" parts of an overall customised Admin interface: primarily because the people doing the data entry are the same ones who are extracting data from it. I appreciate that in business scenarios you may have a worker/manager split and need quite different interfaces for each group. On 3 November 2010 06:33, Carlos Daniel Ruvalcaba Valenzuela < clsdan...@gmail.com> wrote: > Probably so, we do have stuff that tends to be JavaScript intensive at > times, in some places we have a few AJAX queries (for example > selecting a warehouse and loading the relevant part numbers for the > next field based on the client) that may not be necessary, to stuff > like Maps with OpenLayers for routing or pinpointing locations. > > What kind of applications/situations do you find more suited for > reusing the admin module? > > Regards, > Carlos Ruvalcaba > > On Tue, Nov 2, 2010 at 12:12 PM, derek wrote: > > I always had the opposite impression. The Admin can be modified quite > > extensively to handle most cases for regular, on-going, data entry for > > multiple models. This means you have consistency and built-in > > cohesiveness (less chance for errors because you are using existing > > code). Its for specialised edge-cases that you will need your own > > interface. This might be your situation...? > > > > On Oct 29, 11:16 pm, Carlos Daniel Ruvalcaba Valenzuela > > wrote: > >> I have always had the notion that the admin interface is more about > >> adding data to the system quickly rather than being the system itself, > >> the admin interface is very powerful indeed, but I think you may have > >> better customization/simplification options on your own and reserve > >> the admin interface for certain tasks (such as adding data like > >> inventory part numbers) that are not your daily use case o central > >> functionality. > >> > >> Regards, > >> Carlos Daniel Ruvalcaba > >> > >> > >> > >> > >> > >> > >> > >> On Fri, Oct 29, 2010 at 1:55 PM, Frank Wiles wrote: > >> > On Fri, Oct 29, 2010 at 3:13 AM, Alex Kreimer > wrote: > >> >> Hi All, > >> > >> >> I'm building an app for small retail chain management. It requires > >> >> inventory/salespeople/wages etc. management. There 2 kinds of users: > >> >> updaters (non-tech managers that are responsible sales locations) and > >> >> viewers (main office managers that control the organization). > >> > >> >> 1 Would django admin be suitable for all the update tasks (it looks > >> >> like admin would be seriously tweaked for this) or should a separate > >> >> interface be built? > >> > >> >> 2 Is there a ready piece of code that could be used as a stub for > such > >> >> a task? > >> > >> > While you could definitely shoe horn this into the admin with a bunch > >> > of customizations, you're likely better off just writing your own > >> > interface for these tasks. My general rule of thumb is if the end user > >> > isn't "techie" or they will be using the interface many times per day > >> > I don't use the admin. > >> > >> > Don't get me wrong, the admin is great, but it isn't ideal for many > >> > repetitive tasks. > >> > >> > -- > >> > Frank Wiles > >> > Revolution Systems |http://www.revsys.com/ > >> > fr...@revsys.com | (800) 647-6298 > >> > >> > -- > >> > You received this message because you are subscribed to the Google > Groups "Django users" group. > >> > To post to this group, send email to django-us...@googlegroups.com. > >> > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > >> > For more options, visit this group athttp:// > groups.google.com/group/django-users?hl=en. > > > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group,