How do you write a django model that can crunch numbers and automatically populate another field with results?
There's a more detailed version of this question where I've embedded graphics and explained my algorithm to make it more clear on stackoverflow. I haven't gotten a response on it yet so I thought I might come here and see if anyone can help me out. http://stackoverflow.com/questions/10493279/how-do-you-write-a-django-model-that-can-automatically-normalize-data In a nutshell, I'm putting together a music recommendation engine and I need to store data about the different tracks in a sqlite database. I've set it up so that you can easily add the data using the admin interface. There's one particular piece of data for each track called tfidf that's basically a sentiment score for the lyrics. I'm trying to set up the model in such a way once you manually enter the tfidf value of the track in admin, it automatically calculates a normalized value for it. The algorithm basically just looks at the tfidf value of the track and subtracts the smallest tfidf value of all the tracks in the column from that. Then it divides that number by the difference of the largest tfidf and the smallest tfidf values in the column. That gives you a number between 0 and 1. The problem is that django doesn't seem to have the methods that would allow me to automatically select minimum and maximum tfidf values in a table the way I could with SQL statements. Basically, to code this algorithm, I need to be able to select minimum and maximum tfidf values in a column, along with the tfidf value of the track, and then it's just a matter of doing calculations. I'm pretty new to django and am not fully aware of what it's capable of. The model for the table I'm talking about is this: class Party(models.Model): song = models.CharField(max_length = 30) tfidf = models.FloatField(max_length = 50) normalized_tfidf = models.FloatField(max_length = 50) Anybody have any idea what tools are available in django to automatically take the tfidf data, do calculations on it, and then automatically have the results populate the normalized_tfidf field? thnx -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Can't get model to show up in admin interface
I'm working through James Bennet's Practical Django Projects 2nd edition. I have a folder called "coltrane" which has a models.py file with the following: from django.db import models class Category(models.Model): title = models.CharField(max_length = 250) slug = models.SlugField(unique = True) description = models.TextField() def__unicode__(self): return self.title I want to be able to manage this model through the admin interface so I've added the folder name to the INSTALLED_APPS setting of the project like so: INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.flatpages', 'coltrane', ) Now I want to see it on the dev server, so I cd into the directory that contains the INSTALLED_APPS setting and run python manage.py syncdb to install the table. But I keep getting an error message that reads "Error: No module named coltrane". Any idea why this is happening? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Template file not recognized for some strange reason
I'm working through one of the template examples in the django book and the template file I created isn't being recognized for some reason even though it's in the folder. The error report is at the bottom of the page. The TEMP_DIRS variable is set to the correct file path in my settings file: TEMPLATE_DIRS = ("/Users/Documents/Music\ App/redlab/ templates",) The view function is in order too: from django.template.loader import get_template from django.template import Context from django.http import HttpResponse import datetime def current_datetime(request): now = datetime.datetime.now() t = get_template('current_datetime.html') html = t.render(Context({'current_date':now})) return HttpResponse(html) The url file is also in order: from django.conf.urls.defaults import* from redlab.views import current_datetime urlpatterns = patterns('', (r'^time/$', current_datetime)) And there is a current_datetime.html file in the templates directory with the following code in it: It is now {{ current_date }}. But the file isn't being recognized for some reason. Please advise. thnx. Environment: Request Method: GET Request URL: http://127.0.0.1:8000/time/ Django Version: 1.3.1 Python Version: 2.7.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware') Template Loader Error: Django tried loading these templates, in this order: Using loader django.template.loaders.filesystem.Loader: /Users/Documents/Music\ App/redlab/templates/current_datetime.html (File does not exist) Using loader django.template.loaders.app_directories.Loader: Traceback: File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ site-packages/django/core/handlers/base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "/Users/mikaschiller/Documents/Music App/redlab/../redlab/ views.py" in current_datetime 11. t = get_template('current_datetime.html') File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ site-packages/django/template/loader.py" in get_template 157. template, origin = find_template(template_name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ site-packages/django/template/loader.py" in find_template 138. raise TemplateDoesNotExist(name) Exception Type: TemplateDoesNotExist at /time/ Exception Value: current_datetime.html -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Keep getting 404 error
I'm a total newbie to django and just started the book. I created a project and I'm now trying to create my first page, but I keep getting an error page that says: Page not found (404) Request Method: GET Request URL:http://127.0.0.1:8000/ Using the URLconf defined in redlab.urls, Django tried these URL patterns, in this order: ^hello/$ The current URL, , didn't match any of these. Here's what's in my urls.py file: from django.conf.urls.defaults import* from redlab.views import hello urlpatterns = patterns('', ('^hello/$', hello),) # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() # Examples: # url(r'^$', 'redlab.views.home', name='home'), # url(r'^redlab/', include('redlab.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: # url(r'^admin/', include(admin.site.urls)), please advise. thnx. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problems creating django project in Windows 7
Thanks Jason. Putting python in front of 'django-admin' did work. I appreciate your help with this. I'm relatively new to Python and programming in general. All I've ever used is Windows and I don't know much about Linux-related operating systems. I'll probably go with Ubuntu because it seems everyone who knows what they're doing is using Linux(and Paul Graham mentions that just about all of Y Combinator's startups use either Mac OSX or Linux). But I'm just curious about the objective advantages of Ubuntu over Windows vis a vis django?Why would Windows cause headaches down the road? Also, is VMWare or Virtualbox necessary? How would it benefit my development environment? thnx On Mar 7, 12:35 pm, Jason <goodri...@gmail.com> wrote: > Use python before all your commands. Even if you setup windows to > automatically work without this, it's still a really good habit to get > into. > > python django-admin.py > > My guess is that either will work or you have a problem with your > python environment. > > Eventually you'll stop using Windows for Django development (I was > like you once!). I suggest installing VirtualBox or VMWare (or > whatever else) and do all this stuff from Ubuntu. It will save you > many, many headaches. > > On Mar 6, 8:56 pm, Mika <schillerm...@gmail.com> wrote: > > > > > > > > > Hi, > > I uninstalled and reinstalled django to see if that would solve > > things, but I still can't create a project. Here are the steps I'm > > taking: > > > 1) Made sure the correct path was set so that the command prompt can > > find the django-admin.py file. Here's the path I set to locate the > > appropriate folder: %SystemRoot%\system32;%SystemRoot%;%SystemRoot% > > \System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C: > > \Python26\;C:\Python26\Scripts > > > 2) Went into the command prompt and typed in django-admin.py. It > > didn't automatically show me any of the available commands as I > > presume it should have, but it didn't generate any error message > > either. > > > 3) Typed in django-admin.py startproject mysite. I assumed I would > > then be able to go find the newly created mysite folder in my home > > directory because that's where it was set to start the project in the > > prompt > > > 4) Went into my user directory(C:\Users\Mika) to find mysite folder, > > but it wasn't there. I'm not getting any error messages at all either > > in the command prompt, so I'm not sure what's going on. Please advise. > > > thnx > > > Mika -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Problems creating django project in Windows 7
Hi, I uninstalled and reinstalled django to see if that would solve things, but I still can't create a project. Here are the steps I'm taking: 1) Made sure the correct path was set so that the command prompt can find the django-admin.py file. Here's the path I set to locate the appropriate folder: %SystemRoot%\system32;%SystemRoot%;%SystemRoot% \System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C: \Python26\;C:\Python26\Scripts 2) Went into the command prompt and typed in django-admin.py. It didn't automatically show me any of the available commands as I presume it should have, but it didn't generate any error message either. 3) Typed in django-admin.py startproject mysite. I assumed I would then be able to go find the newly created mysite folder in my home directory because that's where it was set to start the project in the prompt 4) Went into my user directory(C:\Users\Mika) to find mysite folder, but it wasn't there. I'm not getting any error messages at all either in the command prompt, so I'm not sure what's going on. Please advise. thnx Mika -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Hi GQuery but for Django? Is somebody developing it?
Hi I was just super wowed by this Google Talk about GQuery (GWTQuery). gwtquery.com http://www.youtube.com/watch?v=sl5em1UPuoI I am wondering if anyone is developing something similar for django? I really hate Java and love python, but I love the idea of developing the JQuery into the django code like they do with java and jquery (sort of) in GQuery. Also creating a new DjQuery, would mean that developers could stick to writing the code inside their python code instead of having a second front end language like JQuery. What do you guys think of the idea? Cheers Mika -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Hi multilingual charfields?
Hi The content of my models have fields that need to be translated in the django admin in several languages. I found it to be a major hassle to get it working. Since django is having internationalization built in, why does it not also allow you to easily mark model fields for translation? I think it should be built in to core since so many of us use multiple languages in our webapps, so using it would be something like this: 1. import the multilang in models.py 2. flag specific fields for content translation 3. set the LANGUAGES in settings.py What do you guys think? // mika -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Instructions for code changing to Django 1.3
Hi I missed out on that one, is it possible to see it online afterwards? I have no problem paying the everbrite fee. // mika On Wed, Mar 30, 2011 at 10:17 PM, Shawn Milochik <sh...@milochik.com> wrote: > It just so happens that there's a two-hour Webinar by Jacob > Kaplan-Moss tomorrow on this very topic: > > http://www.eventbrite.com/event/1008507473 > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there any Open Source Django Newspaper CMS?
django-cms.org //mika On Wed, Mar 23, 2011 at 7:14 PM, Rehmetjan Tursun < rehmetjan.tur...@gmail.com> wrote: > I Googled many times, not a beautifull answer (except > http://code.google.com/p/crimson-online/ ) Demo: > http://www.thecrimson.com/ > > Do you know others? > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there any Open Source Django Newspaper CMS?
Hi What about trying google first before asking? Try to google> Django cms. // mika On Wed, Mar 23, 2011 at 7:03 PM, Rehmetjan <rehmetjan.tur...@gmail.com>wrote: > I mean a out-of-box ready for production newspaper CMS. thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Clueless Monk
Hi It is installed by default in Mac OS X since it is a unix system. No need to install anything else than django - if you want that too will say. If you wanna learn python programing, I can recommend TheNewBoston python tutorials on youtube. Google it and you will find his videos. You can run the python interpreter by opening up the Terminal app in the /Applications/Utillities/ folder and just write pyton and hit enter. happy coding! //mika On Wed, Mar 23, 2011 at 1:24 PM, Sadra Kasraian <mska...@gmail.com> wrote: > I have a black Macbook with OS-X. I was wondering how do I start using it > python. What do I download? > > On Tue, Mar 22, 2011 at 4:38 PM, Cal Leeming [Simplicity Media Ltd] < > cal.leem...@simplicitymedialtd.co.uk> wrote: > >> Shawn is right, Python *is* awesome ^_^ >> >> Soon you will be whispering sweet nothings to your IDE as your code just >> gracefully glides along. But then, you will hit a glass window, and fall >> swiftly to the ground with all the grace of a blind pigeon, whilst screaming >> at your IDE because python/stackless is throwing memory errors or seg >> faulting when you try implementing threads. >> >> It's at that point, that these mailing lists become *very* handy :D >> >> On Tue, Mar 22, 2011 at 8:28 PM, Shawn Milochik <sh...@milochik.com>wrote: >> >>> A good way to start is to go to the Python Web site, do the tutorial, >>> and then graduate to the Python mailing list. Welcome to Python -- >>> it's awesome! >>> >>> This list is for Django, so this isn't on-topic for this list. >>> >>> Tutorial: http://python.org/doc/ >>> >>> Mailing list: http://mail.python.org/mailman/listinfo/python-list >>> >>> Shawn >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Question about including views in base templates
I see now what you mean. I can really use that. Thanks for the answer! Michael 2011/1/27 Shawn Milochik> I think you're looking for context processors. > > > http://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own-context-processors > > You write functions that add to the context each page receives. That info > is available in the template regardless of which view called the rendering. > > Shawn > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: def __str__(self,):
You could try return str(self.name) or return '%i' % self.name On 9/20/07, Greg <[EMAIL PROTECTED]> wrote: > > Do this method have to return a string? I have the following model: > > class Price(models.Model): > name = models.DecimalField(max_digits=6, decimal_places=2) > price_cat = models.ForeignKey(PriceCategory) > > def __str__(self,): >return self.name > > class Admin: > pass > > > // > > However, when I view this is the admin I get the following error: > '__str__ returned non-string (type float)'. Is there anyway to solve > this problem? Do I have to return a string? > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---