Re: UnicodeEncodeError
On Jul 30, 11:17 pm, EricBrian wrote: > Daniel, if I don't do that, I get the unicode error in the list of > dashboards in the admin section. > You'd better post the traceback for that, then. Just to be clear, your method should look like this: def __unicode__(self): return self.name -- 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.
How do I populate a multi-select field with a single column from a model?
I want to grab a single column in a model and use it to populate a multi-select form field. Here's the code that I'm currently using: areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), label='Preferred Areas', help_text='Select the areas that you\'d like to serve.') This code returns the entire Model. I tried using queryset=Area.values('name') and it didn't work. How am I suppose to grab a single column out of a model? My model and form code have been provided below. Thanks. #register.forms from django import forms from django.db import models from django.forms import ModelForm from ylbbq.areas.models import Area STATES = ( ('AK', 'Alaska'), ... ('YT', 'Yukon'), ) COUNTRIES = ( ('USA', 'United States'), ('Canada', 'Canada') ) class RegisterForm(forms.Form): username = forms.CharField(max_length=30) first_name = forms.CharField(max_length=30) last_name = forms.CharField(max_length=30) password1 = forms.CharField(max_length=60) password2 = forms.CharField(max_length=60) email = forms.EmailField(help_text='Enter a valid e-mail address.') phone = forms.CharField(max_length=12) address = forms.CharField(max_length=70) city = forms.CharField(max_length=50) state_province = forms.ChoiceField(choices=STATES, label='State or Province') country = forms.ChoiceField(choices=COUNTRIES) zip_code = forms.CharField(max_length=5) birth_date = forms.DateField() areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), label='Preferred Areas', help_text='Select the areas that you\'d like to serve.') # areas.model from django.db import models class Area(models.Model): name = models.CharField(max_length=40) city = models.CharField(max_length=50) phone = models.CharField(max_length=12) email = models.EmailField() -- 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.
Getting http://http://domain.com/sitemaps.xml on production server using django sitemaps
I'm trying to get sitemaps configured properly for http://newsley.com, but I'm having weird issues with the URLs that are being created for the sitemaps.xml on my production server. e.g. http://newsley.com/sitemap.xml When I run the code on my development server, using ./manage.py runserver, the urls are produced correctly, but when I run the code on my production server (apache running on Windows server), it's adding an extra "http://"; to every url in the sitemaps.xml file. For what it's worthy, my sitemaps.py, urls.py and models.py are here: http://dpaste.com/hold/223712/ I'm guessing that I have apache configured wrong somehow, but this is the first time I've run into this problem, and I'm stumped. Any suggestions? -- 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: How do I populate a multi-select field with a single column from a model?
On Jul 31, 10:07 am, strayhand wrote: > I want to grab a single column in a model and use it to populate a > multi-select form field. Here's the code that I'm currently using: > > areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), > label='Preferred Areas', help_text='Select the areas that you\'d like > to serve.') > > This code returns the entire Model. I tried using > queryset=Area.values('name') and it didn't work. How am I suppose to > grab a single column out of a model? My model and form code have been > provided below. Thanks. I don't know what you mean by 'returns the entire Model'. Model choice fields use as their display values the __unicode__ value of the items in the queryset. If that isn't defined, you'll get something like "Area object". The solution is simply to define a __unicode__ method, which is good practice anyway. -- 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.
Form label suffix
Hello, If i do following, it works: form = ContactForm(label_suffix=":") print form Your name:... but here it is missing ':': form['name'].label_tag() u'Your name' I need to customize form output, so I can not use print form or as_p(), etc. and I am using following: {% for field in form %} {% if not field.is_hidden %} {{ field.label_tag }} {{ field.errors }} {{ field }} {{ field.help_text}} {% else %} {{ field.as_hidden }} {% endif %} {% endfor %} What I have to do to add the label suffix? Thanks, Martin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: moving to django 1.2.1
On 30/07/10 tiemonster said: > I cover some of the new changes in Django 1.2 in this article: > http://www.tiemonster.info/a/24005/ > > Most of this information comes straight from the changelist. Others > were things that the core developers must have assumed were common > sense, but that I didn't think about when upgrading. If you run across > anything that's not on the list, let me know and I'll update the > article. That's helpful, thanks. What would be more helpful is backwards compatability in Django. Now I have to sell the upgrade to my peers at work, since work will be involved. Mike signature.asc Description: Digital signature
Re: moving to django 1.2.1
On Fri, Jul 30, 2010 at 8:14 PM, tiemonster wrote: > I cover some of the new changes in Django 1.2 in this article: > http://www.tiemonster.info/a/24005/ > > Most of this information comes straight from the changelist. Others > were things that the core developers must have assumed were common > sense, but that I didn't think about when upgrading. If you run across > anything that's not on the list, let me know and I'll update the > article. Hi Mark, Since this conversation is happening in the context of a backwards compatibility discussion, I want to provide some clarification to a couple of elements of your blog post: * Although we have introduced a new format for defining databases, you aren't required to make any modifications in order to upgrade. Old-style DATABASE_* settings will continue to work, as the release notes describe [1]. [1] http://docs.djangoproject.com/en/dev/releases/1.2/#specifying-databases * The problem with database caching isn't a backwards incompatible problem; it's a bug with the database cache backend when used with multiple database support. Since Django 1.1 didn't have support for multiple databases, it's impossible for a Django 1.1 project to experience a backwards incompatibility problem here. It is, however, a bug in the a Django 1.2 feature. Ticket #13946 is tracking the problem; it is on my radar, and I've just updated the triage state to ensure that it doesn't get forgotten. * If you have an existing project, the introduction of CSRF protection in Django 1.2 shouldn't pose any obstacle to upgrading. CSRF protection is turned on by default in new projects, but you need to manually turn it on for existing projects (i.e., you need to add the new middleware). If you don't add the new middleware, you don't need to do anything in order to run your project under Django 1.2. The only potential backwards incompatibility is if you have written custom templates to override the default templates provided by Django's admin -- but this is clearly highlighted in the release notes [2]. [2] http://docs.djangoproject.com/en/dev/releases/1.2/#csrf-protection * Your comments about messages correctly points out that the changes are completely transparent, and require no immediate action for compatibility. * I don't know where you've got your information on the changes to the unit test system, but your comments are (to use a complex Latin term) wrong :-) The example you point to [3] is exactly the same example that existed in the docs for Django 1.1 [4] and Django 1.0 [5]. Django's Test Client has never had a dependency on either the base unittest library or Django's own unittest extensions. Django 1.2 didn't introduce any significant changes to the test client. There were some changes to the test runner -- the utility that sets up and executes the test environment -- but again, those changes should be completely transparent, and require no immediate change when upgrading. [3] http://docs.djangoproject.com/en/1.2/topics/testing/#example [4] http://docs.djangoproject.com/en/1.1/topics/testing/#example [5] http://docs.djangoproject.com/en/1.0/topics/testing/#example * Your point about admin media is generally good advice, but isn't a backwards compatibility problem. Yes, Django 1.2 has new admin media files, and you will need to have a complete and correct checkout of those files served by your media provider (CDN or otherwise). As I said previously, we take backwards compatibility very seriously as a project. Unless you have been tinkering with internals or relying on behavior that is buggy, you should be able to upgrade from Django 1.1 to Django 1.2 without being required to make *any* changes to your code. This has been my experience on all projects that I have updated. If anyone can provide a documented example to the contrary, then that is a bug that should be fixed, and may well be sufficient to trigger a point release. Note that I said *required* to make changes. There are many updates that are worthwhile making that aren't required (and won't be until Django 1.4 is released). Enabling CSRF protection is a good idea for security sake. Updating database settings will enable new architectural options. Switching to the new messaging framework allows for anonymous users to receive messages, and also allows for cookie based messaging. However, none of these modifications are required in order to update to Django 1.2. 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-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: moving to django 1.2.1
On Sat, Jul 31, 2010 at 9:45 PM, Michael P. Soulier wrote: > On 30/07/10 tiemonster said: > >> I cover some of the new changes in Django 1.2 in this article: >> http://www.tiemonster.info/a/24005/ >> >> Most of this information comes straight from the changelist. Others >> were things that the core developers must have assumed were common >> sense, but that I didn't think about when upgrading. If you run across >> anything that's not on the list, let me know and I'll update the >> article. > > That's helpful, thanks. What would be more helpful is backwards compatability > in Django. Now I have to sell the upgrade to my peers at work, since work will > be involved. Ok - I'm repeating myself here, but we take backwards compatibility *very* seriously. If anyone can point at a specific backwards incompatible change that was introduced in Django 1.2, then that is a bug that we need to address, and would in all likelihood be a trigger for a new point release. It has been my experience that you can upgrade from 1.1 to 1.2 without any code changes. If your project was written against Django 1.0, upgrading to 1.2 will cause some noisy warnings to be raised (about features that have been on the deprecation path since 1.1 -- most notably, the way of importing admin urls), but your code will still work as is. This has also been the experience of others that I have spoken to. The only work is required is if you take the opportunity of the upgrade to introduce some of the new features from Django 1.2 -- such as CSRF protection, multiple databases, or cookie-based/anonymous messaging. However, these are entirely optional activities. The only change I would encourage you to make is the CSRF changes, and that's purely for your own security. In my experience (and I've heard similar stories from others), a reasonably large site can be migrated to use the new CSRF protection in a matter of hours, especially if you've been a good developer and you have lots of unit tests. So - I would kindly ask that anyone who has what they feel is a backwards incompatibility problem to reduce that issue to a reproducible test case and submit a ticket. If they've already done so and the ticket hasn't received any attention, then please speak up. To the best of my knowledge, Django 1.2 has no backwards compatibility issues. 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-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.
Get request path without having a request object
Hi all, Is there any way of getting the request.path value without having the request object that Django pass's around. Is there something similar to os.environ for the web request where I can get the path? I'm developing an app that needs to cache data on a page basis but the data may come from any Python code that is run for the request or it may come from the template layer via custom template tags. I don't want to have to pass the request path around in order to eventually pass it to my caching code for use in the cache key. I just want to be able to find the request path from my caching code. Possible? -- 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: How do I populate a multi-select field with a single column from a model?
Ah... Well that's exactly what's happening. I'm getting "Area Object" for each element in the select box. I've seen the __unicode__ method on a few model examples, but my book and other resources never really showed or explained it. I'll see if I can find some explanation of it. Thanks for the clue. On Jul 31, 4:31 am, Daniel Roseman wrote: > On Jul 31, 10:07 am, strayhand wrote: > > > I want to grab a single column in a model and use it to populate a > > multi-select form field. Here's the code that I'm currently using: > > > areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), > > label='Preferred Areas', help_text='Select the areas that you\'d like > > to serve.') > > > This code returns the entire Model. I tried using > > queryset=Area.values('name') and it didn't work. How am I suppose to > > grab a single column out of a model? My model and form code have been > > provided below. Thanks. > > I don't know what you mean by 'returns the entire Model'. Model choice > fields use as their display values the __unicode__ value of the items > in the queryset. If that isn't defined, you'll get something like > "Area object". The solution is simply to define a __unicode__ method, > which is good practice anyway. > -- > 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: How do I populate a multi-select field with a single column from a model?
Sweet. That did the trick. I found an example here: http://www.djangoproject.com/documentation/models/str/ # Areas Model UPDATED from django.db import models # Create your models here. class Area(models.Model): name = models.CharField(max_length=40) city = models.CharField(max_length=50) phone = models.CharField(max_length=12) email = models.EmailField() def __unicode__(self): return self.name On Jul 31, 4:31 am, Daniel Roseman wrote: > On Jul 31, 10:07 am, strayhand wrote: > > > I want to grab a single column in a model and use it to populate a > > multi-select form field. Here's the code that I'm currently using: > > > areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), > > label='Preferred Areas', help_text='Select the areas that you\'d like > > to serve.') > > > This code returns the entire Model. I tried using > > queryset=Area.values('name') and it didn't work. How am I suppose to > > grab a single column out of a model? My model and form code have been > > provided below. Thanks. > > I don't know what you mean by 'returns the entire Model'. Model choice > fields use as their display values the __unicode__ value of the items > in the queryset. If that isn't defined, you'll get something like > "Area object". The solution is simply to define a __unicode__ method, > which is good practice anyway. > -- > 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: Get request path without having a request object
I think perhaps I'll also put this problem another way. I need to cache data against the current web request without having the Django built request object. On Jul 31, 4:56 pm, cootetom wrote: > Hi all, > > Is there any way of getting the request.path value without having the > request object that Django pass's around. Is there something similar > to os.environ for the web request where I can get the path? > > I'm developing an app that needs to cache data on a page basis but the > data may come from any Python code that is run for the request or it > may come from the template layer via custom template tags. I don't > want to have to pass the request path around in order to eventually > pass it to my caching code for use in the cache key. I just want to be > able to find the request path from my caching code. > > Possible? -- 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: Get request path without having a request object
Just add django.core.context_processors.request to your TEMPLATE_CONTEXT_PROCESSORS, this way you can access the current request object in your template, you will have to use however RequestContext class with render_to_response, >From docs: django.core.context_processors.request If TEMPLATE_CONTEXT_PROCESSORS contains this processor, every RequestContext will contain a variable request, which is the current HttpRequest. Note that this processor is not enabled by default; you'll have to activate it. Regards, Carlos Daniel Ruvalcaba Valenzuela -- 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: how to get parent of related m2m model instance from within a template?
http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects On Jul 30, 12:29 pm, J wrote: > I have a model, which has a related model, which then has a related > m2m field (See defs below). > > I want to add a method to the m2m model (ie: "Button") which, when > called in a template, will get me the original record that called the > relation. Is this possible? See method attempt below in the "Button" > model, called "get_duid". The point in this attempt is to be able to > return the original id within the template when iterating through the > buttons of a particular "DocumentUnit". > > class DocumentUnit(models.Model): > parent = models.ForeignKey('self', null=True, blank=True, > related_name='children') > unittype = models.ForeignKey(DocumentUnitType, > related_name='du') > content = models.TextField() > > class DocumentUnitType(models.Model): > name = models.CharField(max_length=40) > description = models.CharField(max_length=255, blank=True) > buttons = models.ManyToManyField('Button', null=True, > blank=True, related_name='button_du_types') > > class Button(models.Model): > btn_code = models.CharField(max_length=20) > title = models.CharField(max_length=50, blank=True) > href = models.CharField(max_length=150, blank=True) > viewname = models.CharField(max_length=50, blank=True) > css_class = models.CharField(max_length=70, blank=True) > text = models.CharField(max_length=50, blank=True) > prefix_id = models.CharField(max_length=20) > order = models.IntegerField(blank=True, null=True) > > def get_duid(self): > return self.button_du_types.pk > > Thanks for any help you can give me with this. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: Get request path without having a request object
Thanks Carlos but I'm trying to achieve getting the path without having to pass the request object. On Jul 31, 7:11 pm, Carlos Daniel Ruvalcaba Valenzuela wrote: > Just add django.core.context_processors.request to your > TEMPLATE_CONTEXT_PROCESSORS, this way you can access the current > request object in your template, you will have to use however > RequestContext class with render_to_response, > > From docs: > > django.core.context_processors.request > > If TEMPLATE_CONTEXT_PROCESSORS contains this processor, every > RequestContext will contain a variable request, which is the current > HttpRequest. Note that this processor is not enabled by default; > you'll have to activate it. > > Regards, > Carlos Daniel Ruvalcaba Valenzuela -- 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.
Which program will run when we execute "djano-admin.py startproject mysite" command?
Hi everybody I installed python and django in my Windows 7 home premium operating system. But when I tried to execute "django-admin.py startproject mysite" command in it, the Operating system is asking me to choose the program to run this application. But this is not happened when I tried this in Windows XP. Please guide me to solve this. Is Windows 7 is incompatible with this command ?? Looking forward for answer thank you -- 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: Which program will run when we execute "djano-admin.py startproject mysite" command?
Hi, I'm not a windows user but I'm guessing that you want to use the python executable (see if you can find something called "python". Alternatively, what if you run it with: python django-admin.py startproject mysite Hope this helps, -- Casey On 07/31/2010 03:12 PM, balu wrote: Hi everybody I installed python and django in my Windows 7 home premium operating system. But when I tried to execute "django-admin.py startproject mysite" command in it, the Operating system is asking me to choose the program to run this application. But this is not happened when I tried this in Windows XP. Please guide me to solve this. Is Windows 7 is incompatible with this command ?? Looking forward for answer thank you -- 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: Which program will run when we execute "djano-admin.py startproject mysite" command?
Yah... I tried it by adding python in the command line. But I couldn't get the actual result. Could you people can give a gist of what happens when we type "django-admin.py startproject mysite" i.e., which program will run when we type that and press return key. On Aug 1, 12:41 am, "Casey S. Greene" wrote: > Hi, > > I'm not a windows user but I'm guessing that you want to use the python > executable (see if you can find something called "python". > Alternatively, what if you run it with: > > python django-admin.py startproject mysite > > Hope this helps, > -- Casey > > On 07/31/2010 03:12 PM, balu wrote: > > > Hi everybody > > > I installed python and django in my Windows 7 home premium operating > > system. But when I tried to execute "django-admin.py startproject > > mysite" command in it, the Operating system is asking me to choose the > > program to run this application. But this is not happened when I tried > > this in Windows XP. > > > Please guide me to solve this. Is Windows 7 is incompatible with this > > command ?? > > > Looking forward for answer > > > thank you -- 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: Which program will run when we execute "djano-admin.py startproject mysite" command?
It runs django-admin.py using the python interpreter. Maybe this webpage, or a windows user on this list, will have the answer: http://docs.python.org/faq/windows.html Hope this helps, -- Casey On 07/31/2010 03:57 PM, balu wrote: Yah... I tried it by adding python in the command line. But I couldn't get the actual result. Could you people can give a gist of what happens when we type "django-admin.py startproject mysite" i.e., which program will run when we type that and press return key. On Aug 1, 12:41 am, "Casey S. Greene" wrote: Hi, I'm not a windows user but I'm guessing that you want to use the python executable (see if you can find something called "python". Alternatively, what if you run it with: python django-admin.py startproject mysite Hope this helps, -- Casey On 07/31/2010 03:12 PM, balu wrote: Hi everybody I installed python and django in my Windows 7 home premium operating system. But when I tried to execute "django-admin.py startproject mysite" command in it, the Operating system is asking me to choose the program to run this application. But this is not happened when I tried this in Windows XP. Please guide me to solve this. Is Windows 7 is incompatible with this command ?? Looking forward for answer thank you -- 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: How do I populate a multi-select field with a single column from a model?
Area.objects.values('name','city') On Jul 31, 5:07 pm, strayhand wrote: > I want to grab a single column in a model and use it to populate a > multi-select form field. Here's the code that I'm currently using: > > areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), > label='Preferred Areas', help_text='Select the areas that you\'d like > to serve.') > > This code returns the entire Model. I tried using > queryset=Area.values('name') and it didn't work. How am I suppose to > grab a single column out of a model? My model and form code have been > provided below. Thanks. > > #register.forms > > from django import forms > from django.db import models > from django.forms import ModelForm > from ylbbq.areas.models import Area > > STATES = ( > ('AK', 'Alaska'), > ... > ('YT', 'Yukon'), > ) > > COUNTRIES = ( > ('USA', 'United States'), > ('Canada', 'Canada') > ) > > class RegisterForm(forms.Form): > username = forms.CharField(max_length=30) > first_name = forms.CharField(max_length=30) > last_name = forms.CharField(max_length=30) > password1 = forms.CharField(max_length=60) > password2 = forms.CharField(max_length=60) > email = forms.EmailField(help_text='Enter a valid e-mail address.') > phone = forms.CharField(max_length=12) > address = forms.CharField(max_length=70) > city = forms.CharField(max_length=50) > state_province = forms.ChoiceField(choices=STATES, label='State or > Province') > country = forms.ChoiceField(choices=COUNTRIES) > zip_code = forms.CharField(max_length=5) > birth_date = forms.DateField() > areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), > label='Preferred Areas', help_text='Select the areas that you\'d like > to serve.') > > # areas.model > > from django.db import models > > class Area(models.Model): > name = models.CharField(max_length=40) > city = models.CharField(max_length=50) > phone = models.CharField(max_length=12) > email = models.EmailField() -- 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-admin.py not working
Im using ubuntu I managed to get through the poll project working on the django tut. then tried another project At the prompt i get g...@gino-laptop:~/djangoDEV$ django-admin The program 'django-admin' is currently not installed. You can install it by typing: sudo apt-get install python-django what is the matter? I verified that django is installed: g...@gino-laptop:~/djangoDEV$ python Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> -- 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.
Unable to add model in admin (but can list them)
I've been scratching my head over this for awhile now -- I have an app called "main" that has two models defined "entity" "story" -- I am able to see a list of each via the following urls: http://127.0.0.1:8000/admin/main/entity/ http://127.0.0.1:8000/admin/main/story/ However, I'm only able to add new entities without issue... but when I attempt to add a new story I get a 404 error, with no other information (I have Debug = True) set. I'm revisiting this project after a few months, so I'm not sure what I might've done to get my project in this state... wondering if anyone else has ideas? (I was previously able to add stories, so clearly I messed something up somewhere.. and didn't realize it). This is an abridged version of my main/models.py : class Entity(models.Model): name= models.CharField(max_length=64) sketch = models.TextField() class Meta: verbose_name_plural = 'entities' def __unicode__(self): return self.name class Story(models.Model): link = models.URLField(max_length=384) title = models.CharField(max_length=256) slug = models.SlugField(max_length=256) summary= models.TextField() timestamp = models.DateTimeField(auto_now_add=True) submitter = models.ForeignKey(User) entity = models.ForeignKey(Entity) class Meta: verbose_name_plural = 'stories' def __unicode__(self): return self.title #def save(self, *args, **kwargs): #if not self.id: #self.slug = slugify(self.title) # #super(Story, self).save(*args, **kwargs) --- and here is my admin.py class StoryAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('title',)} admin.site.register(Entity) admin.site.register(Story, StoryAdmin) -- Incidentally, I've tried it with and without the overloaded save method, and with and without the StoryAdmin customization... to no avail. Thanks for any help! Fell -- 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 error can't adapt
Hi, I just migrated from Linux to Mac OS, and I'm getting an error message when I try register a new user of my django site, (at my page) I get the error: can't adapt type 'US/Eastern' I'm using Postgresql and psycopg2, I tried to change the TIME_ZONE to 'America/Sao_Paulo'(I'm in Brazil), but the error still happens. I tried anothers possibilities of TIME_ZONE but no success. Anyone know how to solve that? Best Regards, Daniel França -- 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.
ANN: django-forms-builder 0.2.0 released
Hi Djangonauts, I've released a new version of django-forms-builder. It's a small Django reusable app that allows admin users to build their own forms. This release is a complete rewrite that addresses the fact that previously the fields available for forms created by admin users were restricted to a fixed set of fields defined by the developer. Admin users can now create forms with any number of fields specifying their names and field types making it a much more thorough solution. I've also added some basic tests as well as the ability for admin users to export form submissions via CSV. Grab it from pypi: http://pypi.python.org/pypi/django-forms-builder/ or github: http://github.com/stephenmcd/django-forms-builder/ or bitbucket: http://bitbucket.org/stephenmcd/django-forms-builder/ Cheers, Steve -- Stephen McDonald Twitter: http://twitter.com/stephen_mcd Linkedin: http://www.linkedin.com/in/stephenmcd -- 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: Get request path without having a request object
On Sat, Jul 31, 2010 at 12:37 PM, cootetom wrote: > Thanks Carlos but I'm trying to achieve getting the path without > having to pass the request object. In a word: don't. Instead, design your system to pass the information you need where and when you need it. This doesn't mean everything always has to sling around a request object, just that you need to think carefully about separation of concerns and which code needs to get at the request. Do this, and in 6-12 months when you have to start making changes to update your application, you'll be incredibly thankful that you did it right the first time around. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.