Re: Need help creating model.
I think the Foreign Key route is the way to go. After setting up the fields on both the Student and Point models and establishing the FK relationship between the two, you could write a table-level method that returned the number of corresponding Points. On Tuesday, March 27, 2012 7:18:12 PM UTC-6, Zach wrote: > > I have the following in my Student model. I am wanting to track the > date of each point given to each student. The idea would be so that I > could see not only how many points each student has, but also see the > date each point was given. In the future I want to see the trend of > each students' points. How should I go about this? Should I use a > Foreign Key in another class. I am new to this so thanks for reading. > > > class Student(models.Model): > > CLASS_CHOICES = ( > (u'Yoga','Yoga'), > (u'Spanish', 'Spanish'), > (u'French', 'French'), > (u'Dance', 'Dance'), > ) > > name = models.CharField(max_length=30) > points = models.IntegerField(max_length=4) > classname = models.CharField("Class Name",max_length=20, choices = > CLASS_CHOICES) > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sV-KrZWV8KMJ. 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.
TestCase Client.login() fails
I'm trying to write a unit test that will verify that the login form authenticates a user. Whenever I run 'manage.py test' the runner fails with this message: *AssertionError: False is not True* *tests.py* from django.test import TestCase from django.test.client import Client from django.contrib.auth.models import User class TestAccountLogin(TestCase): def setUp(self): self.client = Client() def test_login(self): user = User.objects.create_user('test', 't...@test.com', 't3stp@s$') response = self.client.login(username=user.username, password=user.password) self.assertTrue(response) After creating the user, I can verify that user.is_active is in fact True, but unfortunately response returns False. Both 'django.contrib.auth.middleware.AuthenticationMiddleware' and 'django.contrib.auth' are declared in settings.py. Any thoughts? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/5zI85qKS4acJ. 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: Http404 and process_exception
On 28/03/2012, at 6:31 AM, Justin Holmes wrote: > Heretofore, I had always believed that Http404 did not cause Middleware > process_exception() to be run. Am I right in this thinking? > > I have a get_object_or_404 that, when the object in question isn't found, is > running process_exception. Http404 is an exception, so yes, it should cause process_exception() to be run. The test suite for middleware processing might be (slightly) illuminating here; it's a bit long winded and gnarly, but it enumerates and validates the full path for every possible combination of middleware and response type. Look at regression_tests/middleware_exceptions; test_process_exception_middleware_not_found is the test for your specific case. Out of interest -- can you put your finger on why you heretofore thought Http404 didn't hit exception middleware? I've done a quick poke through the history of the middleware handling code, and I can't see any obvious reason why this would have changed (even inadvertently). Yours, Russ Magee %-) -- 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.
Need help creating model.
I have the following in my Student model. I am wanting to track the date of each point given to each student. The idea would be so that I could see not only how many points each student has, but also see the date each point was given. In the future I want to see the trend of each students' points. How should I go about this? Should I use a Foreign Key in another class. I am new to this so thanks for reading. class Student(models.Model): CLASS_CHOICES = ( (u'Yoga','Yoga'), (u'Spanish', 'Spanish'), (u'French', 'French'), (u'Dance', 'Dance'), ) name = models.CharField(max_length=30) points = models.IntegerField(max_length=4) classname = models.CharField("Class Name",max_length=20, choices = CLASS_CHOICES) -- 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: LinearRing creation causing WindowsError
The solution I found is as follows: I updated to the latest OSGeo4W (which still uses GEOS 3.2.2 as far as I can tell), added OSGeo4W to my PATH var and LinearRing is working fine. I had been using a work-around configuration referencing (in my PATH var) the GEOS binaries included with a Postgres 9.0 install (also 3.2.2, but from Sept of 2010 while the OSGeo4W GEOS 3.2.2 is from Dec of 2010...seems weird, but that's what I'm seeing). This configuration worked fine until my Django upgrade this morning when LinearRing stopped working (see original email for error details). So, in closing, I'm not really sure what's going on here, but LinearRing is working for me once again. On Mar 27, 1:52 pm, sfletche wrote: > I updated Django today to trunk (last update was Oct 2010) and I'm now > getting an error when creating a LinearRing object. > The following from a python shell will produce the error: > > from django.contrib.gis.geos import * > test = LinearRing ( [ (1,1), (2,1), (2,2), (1,1) ] ) > test > > Accessing 'test' with the last line above causes the following error > to occur: > > WindowsError: exception: access violation writing 0x0291CC80 > > (the string of chars following the 0x will naturally vary) > > As best I can tell, I have GEOS 3.2.2 installed (and will happily give > more information if it helps). > (I say 'As best as I can tell' as this is what is reported when I run > "select postgis_full_version()" from psql command prompt and the > PostgresSQL\9.0\bin is the only entry in my PATH variable that I can > see that would point to the GEOS binaries). > > I can run the same python code on a Linux machine (with the latest > Django and GEOS 3.3.2) and I get no error (not sure if it's the GEOS > library version or the OS that's making the difference...). > > Any ideas? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Upgrading to 1.4, now a test is skipped?
On 03/27/12 18:22, Russell Keith-Magee wrote: On 28/03/2012, at 2:02 AM, Tim Chase wrote: I'm in the process of upgrading from 1.3 to 1.4, and noticed that my test results now say that one of the tests is being skipped. Any way to tell "./manage.py test" to be verbose, or to track down the origin of the test that's skipped? -v VERBOSITY, --verbosity=VERBOSITY Verbosity level; 0=minimal output, 1=normal output, 2=all output Perfect, thanks! Turned out to be the lack of python-bcrypt on my system. An apt-get later, it's passing fully. -tkc -- 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: Upgrading to 1.4, now a test is skipped?
On 28/03/2012, at 2:02 AM, Tim Chase wrote: > I'm in the process of upgrading from 1.3 to 1.4, and noticed that my test > results now say that one of the tests is being skipped. As best I can tell, > this is an internal Django test, rather than one of mine. Since it's not an > actual failure, I'm mostly curious about what it is and what triggers it > (perhaps having something to do with my dev machine sqlite vs. some other DB > backend?). > > Any way to tell "./manage.py test" to be verbose, or to track down the origin > of the test that's skipped? $ ./manage.py test --help Usage: ./manage.py test [options] [appname ...] Runs the test suite for the specified applications, or the entire site if no apps are specified. Options: -v VERBOSITY, --verbosity=VERBOSITY Verbosity level; 0=minimal output, 1=normal output, 2=all output ... Yup. :-) It's -v 2 that you're looking for; look for lines containing "... skipped"; this will then be followed by the reason for the skip. For example, if you don't have markup libraries installed, the contrib.markup tests will return: (lots of test setup noise) ... Creating table transfield_credentials Installing custom SQL ... Installing indexes ... No fixtures found. test_docutils (django.contrib.markup.tests.Templates) ... ok test_markdown (django.contrib.markup.tests.Templates) ... skipped 'markdown not installed' test_no_docutils (django.contrib.markup.tests.Templates) ... skipped 'docutils is installed' test_no_markdown (django.contrib.markup.tests.Templates) ... ok test_no_textile (django.contrib.markup.tests.Templates) ... ok test_textile (django.contrib.markup.tests.Templates) ... skipped 'texttile not installed' -- Ran 6 tests in 1.234s OK (skipped=3) Destroying test database for alias 'default' ('test_example')... Yours, Russ Magee %-) -- 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: locale UTF-8 error
Thank you very much. I edited the ~/.bash_profile file and change the LC_CTYPE env variable to a valid locale and the problem was solved. .. HMA. On Tue, Mar 27, 2012 at 11:08, Tom Evans wrote: > On Tue, Mar 27, 2012 at 5:51 PM, HMA wrote: > > I am following the tutorial part 2 and when creating a superuser once the > > login prompt is showing (after executed python manage.py run server ). > I am > > using python 2.7.2 for Mac OS 10.7.3, Django 1.4 and I get the following > > error: > > > > python manage.pcreatesuperuser --username=horacio > > --email=horacio...@gmail.com > > Traceback (most recent call last): > > File "manage.py", line 10, in > > execute_from_command_line(sys.argv) > > File > > "/Library/Python/2.7/site-packages/django/core/management/__init__.py", > line > > 443, in execute_from_command_line > > utility.execute() > > File > > "/Library/Python/2.7/site-packages/django/core/management/__init__.py", > line > > 382, in execute > > self.fetch_command(subcommand).run_from_argv(self.argv) > > File > "/Library/Python/2.7/site-packages/django/core/management/base.py", > > line 196, in run_from_argv > > self.execute(*args, **options.__dict__) > > File > "/Library/Python/2.7/site-packages/django/core/management/base.py", > > line 232, in execute > > output = self.handle(*args, **options) > > File > > > "/Library/Python/2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", > > line 70, in handle > > default_username = get_default_username() > > File > > > "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", > > line 105, in get_default_username > > default_username = get_system_username() > > File > > > "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", > > line 85, in get_system_username > > return getpass.getuser().decode(locale.getdefaultlocale()[1]) > > File > > > "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", > > line 496, in getdefaultlocale > > File > > > "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", > > line 428, in _parse_localename > > ValueError: unknown locale: UTF-8 > > > > Has some got something similar and have a solution for this? > > > > Thanks in advanced. > > > > .. HMA. > > > > "UTF-8" isn't a locale name. A locale name would look like "es_ES.UTF-8". > > Run "locale -a", which should give you a list of all available locales > on your machine. > > I have no idea how you change locale on OS X. On BSD, you simply set > it in your environment via .profile/.cshrc. > > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Http404 and process_exception
Heretofore, I had always believed that Http404 did not cause Middleware process_exception() to be run. Am I right in this thinking? I have a get_object_or_404 that, when the object in question isn't found, is running process_exception. -- Justin Holmes Head Instructor, SlashRoot Collective SlashRoot: Coffee House and Tech Dojo 60 Main Street New Paltz, NY 12561 845.633.8330 -- 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.
LinearRing creation causing WindowsError
I updated Django today to trunk (last update was Oct 2010) and I'm now getting an error when creating a LinearRing object. The following from a python shell will produce the error: from django.contrib.gis.geos import * test = LinearRing ( [ (1,1), (2,1), (2,2), (1,1) ] ) test Accessing 'test' with the last line above causes the following error to occur: WindowsError: exception: access violation writing 0x0291CC80 (the string of chars following the 0x will naturally vary) As best I can tell, I have GEOS 3.2.2 installed (and will happily give more information if it helps). (I say 'As best as I can tell' as this is what is reported when I run "select postgis_full_version()" from psql command prompt and the PostgresSQL\9.0\bin is the only entry in my PATH variable that I can see that would point to the GEOS binaries). I can run the same python code on a Linux machine (with the latest Django and GEOS 3.3.2) and I get no error (not sure if it's the GEOS library version or the OS that's making the difference...). Any ideas? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
get all models for app with ContentType
How do I get all the models for an app with ContentType? I have this code the works on the local server but throws “DoesNotExist: ContentType matching query does not exist” in production: ct = ContentType.objects.get(app_label=app_label, name=modelName) This works: ct = ContentType.objects.get(app_label) So it has to be something to do with the modelName. How do can I print out all the models for this app with ContentType. I've tried the following at the model appears to be there: app = get_app(app_label) for model in get_models(app): -- 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.
Upgrading to 1.4, now a test is skipped?
I'm in the process of upgrading from 1.3 to 1.4, and noticed that my test results now say that one of the tests is being skipped. As best I can tell, this is an internal Django test, rather than one of mine. Since it's not an actual failure, I'm mostly curious about what it is and what triggers it (perhaps having something to do with my dev machine sqlite vs. some other DB backend?). Any way to tell "./manage.py test" to be verbose, or to track down the origin of the test that's skipped? Thanks, -tkc -- 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: locale UTF-8 error
On Tue, Mar 27, 2012 at 5:51 PM, HMA wrote: > I am following the tutorial part 2 and when creating a superuser once the > login prompt is showing (after executed python manage.py run server ). I am > using python 2.7.2 for Mac OS 10.7.3, Django 1.4 and I get the following > error: > > python manage.pcreatesuperuser --username=horacio > --email=horacio...@gmail.com > Traceback (most recent call last): > File "manage.py", line 10, in > execute_from_command_line(sys.argv) > File > "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line > 443, in execute_from_command_line > utility.execute() > File > "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line > 382, in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File "/Library/Python/2.7/site-packages/django/core/management/base.py", > line 196, in run_from_argv > self.execute(*args, **options.__dict__) > File "/Library/Python/2.7/site-packages/django/core/management/base.py", > line 232, in execute > output = self.handle(*args, **options) > File > "/Library/Python/2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", > line 70, in handle > default_username = get_default_username() > File > "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", > line 105, in get_default_username > default_username = get_system_username() > File > "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", > line 85, in get_system_username > return getpass.getuser().decode(locale.getdefaultlocale()[1]) > File > "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", > line 496, in getdefaultlocale > File > "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", > line 428, in _parse_localename > ValueError: unknown locale: UTF-8 > > Has some got something similar and have a solution for this? > > Thanks in advanced. > > .. HMA. > "UTF-8" isn't a locale name. A locale name would look like "es_ES.UTF-8". Run "locale -a", which should give you a list of all available locales on your machine. I have no idea how you change locale on OS X. On BSD, you simply set it in your environment via .profile/.cshrc. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
locale UTF-8 error
I am following the tutorial part 2 and when creating a superuser once the login prompt is showing (after executed *python manage.py run server* ). I am using python 2.7.2 for Mac OS 10.7.3, Django 1.4 and I get the following error: python manage.pcreatesuperuser --username=horacio --email=horacio...@gmail.com Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line utility.execute() File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv self.execute(*args, **options.__dict__) File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 232, in execute output = self.handle(*args, **options) File "/Library/Python/2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle default_username = get_default_username() File "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", line 105, in get_default_username default_username = get_system_username() File "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username return getpass.getuser().decode(locale.getdefaultlocale()[1]) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename *ValueError: unknown locale: UTF-8* Has some got something similar and have a solution for this? Thanks in advanced. .. HMA. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/2P6758dPv0cJ. 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.
postresql integer array in django model
Hi , I ve a integer array field. How do i represent it in django models ? representing it in text field is not a feasible solution. I want that array to be represented in a drop down box so which is the best way to represent them in models ? -- 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.
Getting started with Django workshop - Nottingham 18 May
Hi - we're holding a workshop for developers interested in getting stuck into Django. It’ll cover all the essentials including: * Setting up a new project * Package management * Database migration with South * The model, view template structure * Working with forms * Customising the admin interface Then you’ll put it all into action by building a Tumblog. By the end of the workshop you should have all the necessary skills to start developing with Django. Andrew Godwin will be opening the workshop with an insight into Django’s architecture, an update on the new features just released in 1.4 and some insights into the often-missed secrets of Django. He’ll also be on hand throughout the workshop to chat and answer questions. Andrew is a co-founder of ep.io, a Python platform-as-a-service (PaaS) hosting provider. He is also a Django core contributor and is one of the creators of South, a tool that brings migrations to Django applications. When it comes to Django there are few more knowledgeable people, so we’re delighted to have him. We've kept costs to a minimum and included a special rate for students (if you register as a student, please bring your ID along to the event registration). Here's how the workshop will run... 12:00: Arrival, lunch (included) 12:45: Welcome 12:50: Andrew Godwin - Django’s architecture: the good, bad and ugly, update on 1.4 features and the often-missed secrets of Django 13:10: Q&A 13:30: Workshop session one - Introduction to various Django elements 15:15: Break 15:30 Workshop session two- Build a Tumblog with Django 17:15: Washup, Q&A 18:00: Social Book via Eventbrite: http://erskineworkshops.eventbrite.co.uk/ -- 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: User/UserProfile Queryset problem
Oh. I see. So...that wasn't very complicated at all then, was it? Thanks DR - didn't realize you could access userprofile directly from user that way. On Mar 27, 2:31 am, Daniel Roseman wrote: > On Tuesday, 27 March 2012 02:15:04 UTC+1, bcrem wrote: > > > Hello Django Nerds! > > > So I have a (somewhat) complicated lookup I'm trying to do; here's the > > gist of it: > > > 1. I have a Store class, with a User ManyToManyField, Store.users > > 2. I have a user profile class associated with each user, > > UserProfile, accessible through the usual User.get_profile() > > 3. UserProfile has a status variable, UserProfile.status, which can > > be 'Active', 'Inactive', or 'Deleted' > > > I'm trying to display a list of users for a particular store; > > currently I generate this list using the following line: > > > userList = request.session['currentStore'].users.all() > > > Works great; however, now I'd like to filter out all users with a > > status of 'Deleted'. Now, if status were a User attribute, I could > > just try this: > > > userList = > > request.session['currentStore'].users.exclude(status=='Deleted') > > > or something similar. > > > THE PROBLEM: How do I generate this no-deleted-users list for the > > given store, using the ManyToManyField Store.users, but based on the > > store.users UserProfile.status? I know there's some kinky django > > black magic reverse-lookup way to do it in a single magnificent > > line...just haven't a clue what it might be. Ideas? > > > First person with the right answer: thank you - please treat yourself > > to a donut... > > The session seems to be a red herring here. You're just doing a filter > across a related field, which is done with the normal double-underscore > syntax: > > current_store.users.exclude(userprofile__status='Deleted') > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Looking for a developer who knows Django well
On Tuesday, 27 March 2012 12:34:46 UTC+1, MSSONI wrote: > > I have just started a company. The company is yet to be registered. We > have launched our product www.instashare.me. Our alpha has just > launched. We are looking for passionate developers. Our salary will > range from 15-25k depending on the developers abilities. Seems legit... No location, salary absurdly low even though it's not clear what currency we're talking about, no contact details. Yes, this must be a real startup. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Ijh5LE1YAdgJ. 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.
Looking for a developer who knows Django well
I have just started a company. The company is yet to be registered. We have launched our product www.instashare.me. Our alpha has just launched. We are looking for passionate developers. Our salary will range from 15-25k depending on the developers abilities. -- 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: IE9+Django,Don't respond or Socket error!!!
This is a problem of django development server, running on windows, and IE(7-9). Basically, the server locks up, and it doesn't really give much as far as useful errors go. Apparently no one that contributes to django uses IE for development and has been able to replicate this issue, because the issue has been closed as "works for me". https://code.djangoproject.com/ticket/15178 . This bug was a huge problem for our windows developers, and took a few days to figure out. It happened after we'd been developing for a while, and I'm not sure what it was about our particular project that makes it fail. This is only a problem with runserver , and will not effect your production server. Here are work-arounds: 1) install and use another web server for development - I recommend either django-extension's runserver_plus , or gunicorn (for either, just install the package, add to installed_apps, and then run either "manage.py runserver_plus" or "manage.py run_gunicorn" just like you would runserver).docs: https://github.com/django-extensions/django-extensions or http://gunicorn.org/run.html#contents 2) If you want to use the runserver that comes with django: - to run runserver, use "manage.py runserver 0.0.0.0:8000" instead of the default (which goes to localhost or 127.0.0.1) , and then figure out your computer's IP address in your intranet (ivarious ways to do this, i use "ipconfig" from command line and pick the one that probably starts with 192.168). Then when you want to access your app, do it at http://:8000 Good luck, hope that solves it Ben PS Django extensions has other good stuff too. I love shell_plus, the model graphing, and the profile server . On Mar 25, 1:19 am, Aommonly wrote: > === > > Exception happened during processing of request from ('127.0.0.1', > 60076) > Traceback (most recent call last): > File "C:\Python27\Lib\SocketServer.py", line 284, in > _handle_request_noblock > self.process_request(request, client_address) > File "C:\Python27\Lib\SocketServer.py", line 310, in process_request > self.finish_request(request, client_address) > File "C:\Python27\Lib\SocketServer.py", line 323, in finish_request > self.RequestHandlerClass(request, client_address, self) > File "E:\workspace\Police\lib\site-packages\django\core\servers > \basehttp.py", > line 560, in __init__ > BaseHTTPRequestHandler.__init__(self, *args, **kwargs) > File "C:\Python27\Lib\SocketServer.py", line 639, in __init__ > self.handle() > File "E:\workspace\Police\lib\site-packages\django\core\servers > \basehttp.py", > line 600, in handle > self.raw_requestline = self.rfile.readline() > File "C:\Python27\Lib\socket.py", line 447, in readline > data = self._sock.recv(self._rbufsize) > error: [Errno 10054] > > > > what can I do -- 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: IE9+Django,Don't respond or Socket error!!!
With IE, we have had to use the a non-local IP for the machine. Using 'localhost' or '127.0.0.1' did not work. On Mar 25, 12:19 am, Aommonly wrote: > === > > Exception happened during processing of request from ('127.0.0.1', > 60076) > Traceback (most recent call last): > File "C:\Python27\Lib\SocketServer.py", line 284, in > _handle_request_noblock > self.process_request(request, client_address) > File "C:\Python27\Lib\SocketServer.py", line 310, in process_request > self.finish_request(request, client_address) > File "C:\Python27\Lib\SocketServer.py", line 323, in finish_request > self.RequestHandlerClass(request, client_address, self) > File "E:\workspace\Police\lib\site-packages\django\core\servers > \basehttp.py", > line 560, in __init__ > BaseHTTPRequestHandler.__init__(self, *args, **kwargs) > File "C:\Python27\Lib\SocketServer.py", line 639, in __init__ > self.handle() > File "E:\workspace\Police\lib\site-packages\django\core\servers > \basehttp.py", > line 600, in handle > self.raw_requestline = self.rfile.readline() > File "C:\Python27\Lib\socket.py", line 447, in readline > data = self._sock.recv(self._rbufsize) > error: [Errno 10054] > > > > what can I do -- 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: Adding link to admin page
On Mon, Mar 26, 2012 at 9:19 PM, Mike Dewhirst wrote: > Larry > > Here is a working setup ... > > From settings.py > # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # > # > # if templates are not found here look in app_name/templates > TEMPLATE_DIRS = ( > os.path.join(SRC_ROOT, 'templates/').replace('\\','/'), > ) > > # List of callables that know how to import templates from various sources. > TEMPLATE_LOADERS = ( > # filesystem ahead of app_directories looks in project before django > 'django.template.loaders.filesystem.Loader', > 'django.template.loaders.app_directories.Loader', > ) > > TEMPLATE_CONTEXT_PROCESSORS = ( > 'django.contrib.auth.context_processors.auth', > 'django.core.context_processors.debug', > 'django.core.context_processors.i18n', > 'django.core.context_processors.media', > 'django.core.context_processors.static', > 'django.contrib.messages.context_processors.messages', > ) > # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # > # # # > > ... where SRC_ROOT is the directory containing settings.py. > > So my templates directory seems much the same as yours like this ... > > SRC_ROOT/templates/admin/base_site.html > > ... and inside base_site.html I have ... > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > {% extends "admin/base.html" %} > {# admin/base.html is in site-packages/django/contrib/admin/templates/admin > #} > {% load i18n %} > {% block title %}{{ title }} | {% trans 'Ssds' %}{% endblock %} > {% block extrastyle %}{% endblock %} > {% block branding %} > {% trans 'http://www.myproj.com.au";>MyProj > Administration' %} > {% endblock %} > {% block nav-global %}{% endblock %} > {% block extrahead %}{% endblock %} > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > ... and you can see where I tested a link inside {% block branding %} and I > can confirm it works. > > Hth I found my problem - I was putting the full path to the dir with my base_site.html in TEMPLATE_DIRS (e.g. SRC_ROOT/templates/admin/). When I removed the last dir and changed it to SRC_ROOT/templates/ it then picked up my file. Thanks very much Mike, I really appreciate all your help. -larry > On 27/03/2012 12:46pm, Larry Martell wrote: >> >> On Mon, Mar 26, 2012 at 7:25 PM, Mike Dewhirst >> wrote: >>> >>> On 27/03/2012 10:16am, Larry Martell wrote: On Mon, Mar 26, 2012 at 4:37 PM, Mike Dewhirst wrote: > > On 27/03/2012 9:16am, larry.mart...@gmail.com wrote: >> >> On Mar 25, 3:29 pm, Larry Martell wrote: >>> >>> I have a client that has an app built with django. On every page of >>> their app is a link to their admin site. They tell me the admin site >>> is generated entirely by django, and they've never customized it >>> before. On the very first line of the admin page it says: >>> >>> Django administration Welcome, admin. Change password / Log >>> out >>> >>> They want me to add a link to that line, to the left of "Django >>> administration" that will take them back to the page they were on >>> when >>> they clicked on the link to get them to the admin site. >>> >>> So I have 2 issues here: >>> >>> 1) How do I override that line to add the link? It appears that page >>> is generated by contrib/admin/templates/admin/base.html, and I tried >>> to override it by following the directions >>> >>> >>> athttps://docs.djangoproject.com/en/1.2/ref/contrib/admin/#overriding-a..., >>> but whatever I do seems to have no effect. >>> >>> 2) How can I get the link of the page of the app they came from? It's >>> not simply just going back one page, as they could have navigated all >>> over the place of the admin site before clicking the "Back to app" >>> link. >>> >>> Thanks! >>> -larry >> >> Is there anyone that can provide some assistance with overriding >> base_site.html? I copied django/contrib/admin/templates/admin/ >> base_site.html to my projects's templates/admin dir, but changes to it >> are not getting picked up. I also tried adding that to TEMPLATE_DIRS >> (there was nothing in it before). In urlpatterns I have: (r'^admin/', >> include(admin.site.urls)) - does that need to change? > > > Check > https://docs.djangoproject.com/en/1.4/ref/settings/#template-loaders > > Basically, django uses the first template it finds so if it finds the > "real" > one in site-packages first, it stops looking. Try reversing the > sequence > of > loaders in your settings.py Thanks. Perhaps that's related to the problem. TEMPLATE_LOADERS has this: TEMPLATE_LOADERS = ( 'appmngr.load_app_template', 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', ) W
Re: Django error about utf8 with BOM when running "python manage.py compilemessages"
On Tue, Mar 27, 2012 at 3:52 AM, Davide Setti wrote: > But that file is in django, not in his code, am i wrong? many brain-dead editors silently add BOMs to files when saving. being a .po file, i'd guess somebody did a small localization by editing it with the wrong tool. -- Javier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Simple question on queryset.
On Tue, Mar 27, 2012 at 1:57 AM, Stanwin Siow wrote: > queryset = Memberships.objects.get(id__exact=4) the .get() method doesn't return a queryset, it returns a record object, so your 'queryset' variable is the 'membership' object itself. the error you get: > Memberships has no attribute all. means exactly that, you already have a Membership object, no need to iterate it calling .all() using the .filter() call you do get a queryset, but since you're using the primary key, you won't ever get more than one object, so it is more appropriate to use .get() -- Javier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: De-serialization of ManyToManyField
Hi, So a brief update. I changed the way I was building this model and explicitly created a 'joining' table and added a through clause to the ManyToManyField definition as well as allowing null values. This meant I was able to populate the joining table using YAML after building the test/instance tables using the natural keys for each of 'test' and 'instance'. However when I view the table in the admin interface there is no multiple selector for 'test' when I edit the instance in the admin interface. I have added the joining table to the list of admin tables (if this makes a difference). Can anyone explain to me whether this is another error on my part, or if it is expected that if you explicitly define a joining table then Django suppresses the management of the relationship outside of the joining table itself? Obviously if it were possible to use the built in manytomany management and be able to import the YAML defining this that I included in the initial question that would be favourable. For context this is a simplified example of a reasonably large database that I am trying to port to a Django model so manually building the contents of the joining table is not a reasonable solution. I can generate the YAML, or similar, fairly trivially and so it is best for me to build the fixtures to get the initial DB set up and import them after the initial syndb. Any guidance on this would be much appreciated - I am really enjoying the elegance of Django but little issues caused by my (lack of) understanding are definitely holding me up! Regards Stephen On Mar 26, 12:01 pm, sk <6b656...@gmail.com> wrote: > Hi, > > I have searched high and low to an answer to this, but have been > unable too turn anything up. Apologies if I have overlooked an answer > or explanation elsewhere. > > I have set up a very simple model as follows: > --- > from django.db import models > class TestManager(models.Manager): > def get_by_natural_key(self, name): > return self.get(name=name,) > > class Test(models.Model): > name = models.CharField(max_length = 100, unique = True) > date = models.DateField() > > def __unicode__(self): > return self.name > > def natural_key(self): > return (self.name) > > class InstanceManager(models.Manager): > def get_by_natural_key(self, name): > return self.get(name=name,) > > class Instance(models.Model): > name = models.CharField(max_length = 100, unique = True) > test = models.ManyToManyField(Test) > date = models.DateField() > > def __unicode__(self): > return self.name > > def natural_key(self): > return (self.name) > --- > > looking at the admin interface I am able to add a couple of > 'tests' (test 1 and test 2). I am then able to add an instance which > is linked to both test 1 and test 2. If I dump the data to YAML format > then I get the following (for the two tables in question): > > --- > - fields: {date: 2012-03-26, name: test 1} > model: TempDB.test > pk: 1 > - fields: {date: 2012-03-26, name: test 2} > model: TempDB.test > pk: 2 > - fields: > date: 2012-03-26 > name: Instance 1 > test: [test 1, test 2] > model: TempDB.instance > pk: 1 > --- > > This is roughly what I would expect to see, although the documentation > does not explicitly state that a manytomany serialization will be a > multi-element list, it seems to be a reasonable assumption. > > When I try to perform a loaddata with this output (and after manually > deleting the tables from the admin interface, to be sure). I get the > following error: > > Problem installing fixture '/home//workspace/THMDB/THMDB/TempDB/ > fixtures/test.yaml': Traceback (most recent call last): > File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/ > django/core/management/commands/loaddata.py", line 190, in handle > for obj in objects: > File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/ > django/core/serializers/pyyaml.py", line 62, in Deserializer > raise DeserializationError(e) > DeserializationError: [u"'test 1' value must be an integer."] > > What exactly have I done wrong? I suspect I have made an error in > defining the managers. I have defined two as I planned to link too > instances from another table. I left in the definition in case it is > the cause of the error. However it still does the same thing if I > comment it out. > > I am running Django 1.4 on python 2.7 under Ubuntu 11.10. > > Many thanks for your help. > > Stephen -- 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 ema
Re: Django error about utf8 with BOM when running "python manage.py compilemessages"
On Thursday, March 8, 2012 10:04:09 PM UTC+1, Tom Evans wrote: > > Yes, just remove the BOM: > > http://en.wikipedia.org/wiki/Byte_order_mark > But that file is in django, not in his code, am i wrong? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Rc7vQY_Gnq8J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django With Tweepy
Hi guys, I’m confused on how to make this work. I want to stream user’s tweets in my django app using tweepy. I’ve written the streaming code but the problem I’m facing is: should I paste the code in views.py and input- return render_to_response('tweet.html',context_instance=RequestContext(request)) after writing the code. Just like this: Q= sys.argv[1:] db=MySQLdb.connect("localhost","","","Juzme") auth=tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) cur=db.cursor() class CustomStreamListener(tweepy.StreamListener): def on_status(self, status): try: print "%s\t%s\t%s\t%s" % (status.text, status.author.screen_name, status.created_at, status.source,) cur.execute("INSERT INTO tweets VALUES (%s, %s, %s, %s)", (status.text, status.author.screen_name, status.created_at, status.source)) except Exception, e: print >> sys.stderr, 'Encountered Exception:', e pass def on_error(self, status_code): print >> sys.stderr, 'Encountered error with status code:', status_code return True def on_timeout(self): print >> sys.stderr, 'Timeout...' return True streaming_api=tweepy.streaming.Stream(auth, CustomStreamListener(), timeout=60) print >> sys.stderr, 'Filtering the public timeline for "%s"' % (' '.join(sys.argv[1:]),) streaming_api.filter(follow=[], track=Q) return render_to_response('tweet.html',context_instance=RequestContext(request)) If I can do it like this, won’t there be any code in template? Or what’s the best way I can carry out this operation. I hope you get my point? Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Simple question on queryset.
ok i managed to get it to work by using filter. Cheers Best Regards, Stanwin Siow On Mar 27, 2012, at 3:32 PM, Denis Darii wrote: > I think the error "Memberships has no attribute all" is not related to your > QuerySet. Try to look deeply into your code. > > BTW, your QuerySet must be: > > queryset = Memberships.objects.get(id=4) > > or better, if your id is also the primary key: > > queryset = Memberships.objects.get(pk=4) > > On 27 March 2012 08:57, Stanwin Siow wrote: > > Hello, > > How do i transform this SQL query into a queryset? > > select membership_type from memberships where id ='4' > > i tried the following: > > queryset = Memberships.objects.get(id__exact=4) > > however django is throwing me an error with the following: > > Memberships has no attribute all. > > > I know this is a trivial question but i've been through the tutorials > https://docs.djangoproject.com/en/dev/topics/db/queries/ > > and i don't unds where this error is coming from. > > Do appreciate any help rendered. > > Thank you. > > > Best Regards, > > Stanwin Siow > > > > > -- > 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. > > > > -- > I'm using Linux because i'm freedom dependent. > > > -- > 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.
Custom template tag for django-voting
Hi everybody, I have a weird problem with a custom template tag I made. The template tag is built on top of django-voting app and provides upvote and downvote counts, while standard django-voting tags only provides total number of votes and score. Here is the snippet I wrote: http://dpaste.com/722024/ I inserted a couple of "print"s and understood I have a problem when calling Vote.objects.get_score(object) from within the snippet. Eg. I call Vote.objects.get_score() from the python shell and get {'score': 0, 'num_votes': 2}. Then I call it from the snippet against the same object and get {'score': 0, 'num_votes': 0}. I really don't understand where the problem may lay. Any tips appreciated. Cheers, Fabio. -- Fabio Natali -- 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: Simple question on queryset.
I tried changing it to what you said. It's still showing the error. "Memberships object has no attribute all" This only happens when i use get. When i use order_by. the page shows but with unnecessary options. Best Regards, Stanwin Siow On Mar 27, 2012, at 3:32 PM, Denis Darii wrote: > I think the error "Memberships has no attribute all" is not related to your > QuerySet. Try to look deeply into your code. > > BTW, your QuerySet must be: > > queryset = Memberships.objects.get(id=4) > > or better, if your id is also the primary key: > > queryset = Memberships.objects.get(pk=4) > > On 27 March 2012 08:57, Stanwin Siow wrote: > > Hello, > > How do i transform this SQL query into a queryset? > > select membership_type from memberships where id ='4' > > i tried the following: > > queryset = Memberships.objects.get(id__exact=4) > > however django is throwing me an error with the following: > > Memberships has no attribute all. > > > I know this is a trivial question but i've been through the tutorials > https://docs.djangoproject.com/en/dev/topics/db/queries/ > > and i don't unds where this error is coming from. > > Do appreciate any help rendered. > > Thank you. > > > Best Regards, > > Stanwin Siow > > > > > -- > 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. > > > > -- > I'm using Linux because i'm freedom dependent. > > > -- > 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: Simple question on queryset.
I think the error "Memberships has no attribute all" is not related to your QuerySet. Try to look deeply into your code. BTW, your QuerySet must be: queryset = Memberships.objects.get(id=4) or better, if your id is also the primary key: queryset = Memberships.objects.get(pk=4) On 27 March 2012 08:57, Stanwin Siow wrote: > > Hello, > > How do i transform this SQL query into a queryset? > > select membership_type from memberships where id ='4' > > i tried the following: > > queryset = Memberships.objects.get(id__exact=4) > > however django is throwing me an error with the following: > > Memberships has no attribute all. > > > I know this is a trivial question but i've been through the tutorials > https://docs.djangoproject.com/en/dev/topics/db/queries/ > > and i don't unds where this error is coming from. > > Do appreciate any help rendered. > > Thank you. > > > Best Regards, > > Stanwin Siow > > > > -- > 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. > -- I'm using Linux because i'm freedom dependent. -- 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: Custom option for Model Meta Options
Hello Anssi, thanks! Seems to work. I tried it like this: from django.db import models class MyModelBase(models.base.ModelBase): def __new__(cls, name, bases, attrs): attr_meta = attrs.pop('Meta', None) try: has_cpk= attr_meta.has_composite_primary_key del attr_meta.has_composite_primary_key except AttributeError: has_cpk = False model = super(MyModelBase,cls).__new__(cls, name, bases, attrs) model._meta.has_composite_primary_key = has_cpk return model And I then assigned this as the __metaclass__ to my Model class. However I droped the whole composite forreign key idea in favor of another solution. So: Problem solved! Thanks! Roman -- 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.