ValueError when uploading image
Hi, I'm new to Django and programming in general. I've been trying to create a form that simply uploads images and saves them to a app folder. I'm using MySql with Django svn. Here's my model: class Images(models.Model): prim = models.AutoField(primary_key=True, db_column='PRIM') # Field name made lowercase. photos = models.ImageField(db_column='PHOTOS', upload_to='img', blank=True) # Field name made lowercase. items = models.CharField(max_length=255, db_column='ITEMS', blank=True) # Field name made lowercase. date = models.DateField(null=True, db_column='DATE', blank=True) # Field name made lowercase. class Meta: db_table = u'IMAGES' Here's my view: class PictureForm(ModelForm): class Meta: model=Images exclude = ('prim',) def image_loads(request): form=PictureForm() if request.method=='POST': form=PictureForm(request.POST, request.FILES) if form.is_multipart(): form.save() form=PictureForm() return render_to_response('photos.html', {'form':form, }, context_instance = RequestContext(request)) return render_to_response('photos.html', {'form':form, }, context_instance = RequestContext(request)) Here's photo.html: {%extends "base.html" %} {%block head%} {%endblock%} {%block content%} {{ form.as_p }} {% if comment %} {{comment}} {%endif%} {%endblock%} Here's the error message: Environment: Request Method: POST Request URL: http://localhost:8000/photos/ Django Version: 1.1 beta 1 SVN-10891 Python Version: 2.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'orders1.onhand', 'registration'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.csrf.middleware.CsrfMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/home/malcolm/data1/orders1/../orders1/onhand/views.py" in image_loads 49. form.save() File "/usr/lib/python2.5/site-packages/django/forms/models.py" in save 407. fail_message, commit, exclude=self._meta.exclude) File "/usr/lib/python2.5/site-packages/django/forms/models.py" in save_instance 42. " validate." % (opts.object_name, fail_message)) Exception Type: ValueError at /photos/ Exception Value: The Images could not be created because the data didn't validate. Any help or suggestions would be greatly appreciated. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 -~--~~~~--~~--~--~---
Apache2 permission denied problem
Hi, I'm new to Django, and am trying to write a csv file and attach it to an email that is sent upon completion of a sales order. All works fine in the developement server, but when I switch to Apache2 I get an error message that either says' No such file or directory, ../orders1/ csv_files/ or Permissions denied etc. All works fine when I use the developement server. Here's my Apache2 sites-available script: ServerAdmin malc...@sporthill.com ServerName localhost ServerAlias localhost/media/ DocumentRoot /home/malcolm/data1/orders1/media WSGIScriptAlias / /home/malcolm/data1/orders1/apache/django.wsgi Order allow,deny Allow from all Order allow,deny Allow from all Apache2 is located in /etc/apache2/ My app is in /home/malcolm/data1/orders1/ Here's some of the relevant code in my views: for n in new_m: so_order=n.so_number so_order=str(so_order) custo=n.custno/csv_files/"+custo+so_order+".csv", "wb")) Any ideas about what might fix this problem. Any thoughts are appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to widen the text fields in the admin pages for editing records
Any pointers to the documentation for getting the text fields larger for CharField data? They're kinda puny for columns that are defined to have up to 255 characters. 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: How to widen the text fields in the admin pages for editing records
On Apr 7, 6:56 pm, Brian Neal wrote: > On Apr 7, 3:04 pm, Mac wrote: > > > Any pointers to the documentation for getting the text fields larger > > for CharField data? They're kinda puny for columns that are defined > > to have up to 255 characters. Thanks! > > You do it by supplying your own widget to the form field. See: > > http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms Thanks. I can see how that works if I'm creating my own forms, but how would I go about modifying the widgets for the forms that ship with the built-in admin application? --~--~-~--~~~---~--~~ 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: How to widen the text fields in the admin pages for editing records
On Apr 7, 8:15 pm, TiNo wrote: > You can override the ModelAdmin.form attribute to provide your own > customized form. > See:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form Excellent, 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 -~--~~~~--~~--~--~---
problem rendering html images in browser
I've had trouble rendering images in my browser. I just get a broken link. Any thoughts on how to fix this? I'm working with the development server, and I've check my code carefully to insure the to the image file is correct. If I open the html template file with my browser, it does render the image, but in a view, it does not. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
jquery ajax form problem--Can't render template variables
I'm new to programming and can't figure out how to properly render the {{comment}} and {{username}} variables in the element below using jquery and the ajax form plugin. Everything posts to the database just as it should. However, I want to show what gets posted in the template after submission. What happens is the entire html page gets inserted in the element. The images, everything, gets duplicated as the response_text is inserted. Note that the following code has a lot of simple test scripts I'm attempting to use. My template looks like this: (I'm referencing a javascript file, global.js in the template, which is included below it): {% extends "base.html" %} {%block content %} Welcome to Site {% include "form.html" %} This will fade out Here is the camo image Users and comments: {{comment}} {{username}} {% if error %} Errors: {{error}} {% endif %} {% endblock%} Here is global.js $(document).ready(function(){ $("div.htm").text("The DOM is now loaded and can be manipulated."); $(":header").css({ background:'#CCC', color:'green' }); $("img").css({ width:'25%' }); $("p").bind("click", function(e){ var str = "( " + e.pageX + ", " + e.pageY + " )"; $("div.htm").text("Click happened! " + str); }); $("form.theform").ajaxForm({ clearform: true, target:"#new", success: function(response_text, status_text) { var $inp=$("input.com").val(); var $inpa=$("textarea.comms").val(); $("input.news").val($inp); $("Hello" + " " + $inp + " " + $inpa + "").appendTo("div.htm"); $("p.hide").hide(); $("input.com").val(""); $("textarea.comms").val(""); alert("ajx working"); alert(response_text); $("Thanks for your sporthill order!").appendTo("p.inp"); $("div.shw").show("slow"); $('p.inp').fadeOut("slow"); $('#hide').hide(); } }); }); view is: def ajx_form(request): if form.is_valid: if request.is_ajax: name = request.POST.get('name', '') password = request.POST.get('password', '') comments=request.POST.get('comment', '') u=Users.objects.create(user=name, comment=comments) return render_to_response('my_ajx.html', {'username':name, 'comment': comments, 'request':request, }, context_instance=RequestContext(request)) return render_to_response('my_ajx.html', {'error':'You"ve got errors', }, context_instance=RequestContext(request)) return render_to_response('my_ajx.html', {'error':'You"ve got errors', }, context_instance=RequestContext(request)) Please let me know if you have a solution or any ideas. 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 -~--~~~~--~~--~--~---
Problems deserializing json object
I'm having difficulty deserializing a json object. I'm using django appengine patch, so the models aren't the same as django's, but they are very similar: class Cust(db.Model): custno = db.StringProperty(required=True) company = db.StringProperty(required=True) contact = db.StringProperty(required=False) address1 = db.StringProperty(required=False) address2 = db.StringProperty(required=False) city = db.StringProperty(required=True) state = db.StringProperty(required=False) zipc = db.StringProperty(required=False) country = db.StringProperty(required=False) phone = db.StringProperty(required=False) salesmn = db.StringProperty(required=True) email = db.StringProperty() def __unicode__(self): return self.custno + " : " + str(self.company)+" : "+str (self.city)+" : "+str(self.state) class Cust_List(db.Model): custno = db.StringProperty(required=True) companies = db.TextProperty(required=True) #customer list as json object Note that the json object is stored in the db.TextProperty companies, and is composed of more than a 1000 customers, all of which are also individually stored in the model, Cust . I query the json object for a customer list, since it saves CPU time on the appengine. Here's what happens when I try to decode the json string object: >>> from sport.models import Cust_List >>> from django.core import serializers >>> a=Cust_List.all() >>> b=a.get() #returns the only and only data item in this model, which is a >>> json object previously stored in the datastore. >>> c=serializers.deserialize('json', b.companies) >>> d=list(c) >>> e=len(d) >>> e 1057 >>> b etc... cy...@global.net", "phone": "269/552-", "state": "MN", "contact": "Rick L ee", "salesmn": "O1", "country": "", "address2": ""}}, {"pk": "XBwTAxc hELEgpzcG9ydGNUYDA", "model": "sport.cust", "fields": {"city": "GOLD RIVE R", "zipc": "95670", "address1": "11282 PYRITES WAY", "company": "ZSPORTS", "cus tno": "ZSP001", "email": "ra...@zsports.com", "phone": "916/638-0033", "sta te": "CA", "contact": "Randy Mintz", "salesmn": "H1", "country": "", "address2": ""}}]') >>> d etc... , , , , , , , , , , , , , , , , , , , , , , , , , ] etc. Note that I just get returned a unicode representation of my model, Cust. But the contact information, address information, and so on disappears in the deserialized object. Any thoughts on why or what I'm doing wrong? Thanks for any help or 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-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.
Problems with HttpResponseRedirect(reverse()) No match found
Hi, I've read the django docs here: http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse and am still having trouble with redirecting my views. Here is my view: def skipant_sale(request, notes=''): notes=notes if request.method == 'POST': # If the form has been submitted... form = ContactForm_Sale(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass name = form.cleaned_data['name'] message = form.cleaned_data['message'] phone = form.cleaned_data['phone'] your_email = form.cleaned_data['your_email'] retype_email = form.cleaned_data['retype_email'] subject=form.cleaned_data['subject'] if your_email==retype_email: message=message+': Phone '+phone +': Name '+name from django.core.mail import send_mail send_mail(subject, message, your_email, ['malc...@sporthill.com']) else: notes='Sorry, there was a problem with your submission. Please try again or contact us at the phone number below. Thanks!' return HttpResponseRedirect(reverse ('onhand.views.email_sale', kwargs={'notes':notes})) form = ContactForm_Sale() notes="We have received your email, and will contact you soon to answer any questions you may have. Thank you!" return HttpResponseRedirect(reverse ('onhand.views.email_sale', kwargs={'notes':notes})) else: form = ContactForm_Sale() # An unbound form return render_to_response('yui_temp.html', {'form' : form,}, context_instance = RequestContext(request)) def email_sale(request, notes=''): #redirect back to skipant_sale view. return HttpResponseRedirect(reverse('onhand.views.skipant_sale', kwargs={'notes':notes,})) Here is my url: (r'^skipant_sale/$', 'onhand.views.skipant_sale'), Whenever I've tried this, I keep getting the error message no match found. Any help would be very much appreciated. Thanks! Environment: Request Method: POST Request URL: http://baglux.sporthill.com/skipant_sale/ Django Version: 1.2 pre-alpha SVN-11616 Python Version: 2.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'orders1.onhand', 'registration', 'pagination', 'django.contrib.flatpages', 'tinymce', 'sorl.thumbnail', 'django.contrib.sitemaps'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.csrf.middleware.CsrfMiddleware', 'django.middleware.ssll.SSLRedirect', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'pagination.middleware.PaginationMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware') Traceback: File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/home/malcolm/data1/orders1/onhand/views.py" in skipant_sale 2089. return HttpResponseRedirect(reverse ('onhand.views.email_sale', kwargs={'notes':notes})) File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py" in reverse 350. *args, **kwargs))) File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py" in reverse 300. "arguments '%s' not found." % (lookup_view_s, args, kwargs)) Exception Type: NoReverseMatch at /skipant_sale/ Exception Value: Reverse for 'onhand.views.email_sale' with arguments '()' and keyword arguments '{'notes': 'We have received your email, and will contact you soon to answer any questions you may have. Thank you!'}' not found. -- 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.
admin error, cannot edit fields or delete records, url refers to incorrect primary key
I've set up a 'Reps' model in the admin. I can add records successfully, but if I try to change a record or field, I get a 404 error. When I try to delete a record, I get this traceback here: http://dpaste.com/750121/ My primary keys are integers, but it appears that the urls return them as floats. Please see the example below. The model in whl.models is as follows: class Reps(models.Model): prim = models.AutoField(primary_key=True, db_column='PRIM') custno = models.CharField(max_length=50, db_column='CUSTNO', blank=True) # Field name made . company = models.CharField(max_length=50, db_column='COMPANY', blank=True)# Field name made #etc, etc. class Meta: db_table = u'whl_reps' def __unicode__(self): return self.custno + " : " + str(self.company)+" : "+str(self.city)+" : "+str(self.state) def get_absolute_url(self): return "/%i/" % self.prim My admin.py is: from whl.models import Reps class RepAdmin(admin.ModelAdmin): fields = ('company', 'email', 'salesmn', 'city', 'state') And for example when I click on a record to change it, I get a 404 error with a message "reps object with primary key u'39.0' does not exist". In this case, when i click on a record, it returns this url localhost/admin/whl/reps/39.0/ As you can see, the last primary key above is not an integer as it should be. When I manually change the url to /admin/whl/reps/39/ I can edit the record. I'm using Django 1.4, mysql db on Ubuntu. Any thoughts on why this is happening? Any help would be appreciated very much. 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: Billing and invoicing app?
I'm not sure if there's anything that is django-specific. There are a lot of payment processing apps out there, including stripe <http://stripe.com>. I hear they provide a very good api libraries (including python), which would allow your to hook it up with Django. I don't know if this is what you are looking for, but I hope this helps. Mac On Tuesday, October 23, 2012 7:27:20 PM UTC-7, Jesramz wrote: > > Thanks Mike! > > I tried djangopackages and didn't find anything. I was wondering if > anyone had a package that they found useful that might be of some help in > this area. > > On Tue, Oct 23, 2012 at 9:18 PM, Mike Dewhirst > > > wrote: > >> On 24/10/2012 1:08pm, Jesramz wrote: >> >>> Quick question, is there a good billing and invoicing app, that anyone >>> can point me to? >>> >> >> http://www.djangopackages.com/ >> >> >> >>> Thanks all! >>> >>> -- >>> 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/-/**cg8sQsl98K0J<https://groups.google.com/d/msg/django-users/-/cg8sQsl98K0J> >>> . >>> To post to this group, send email to django...@googlegroups.com >>> . >>> To unsubscribe from this group, send email to >>> django-users...@**googlegroups.com . >>> For more options, visit this group at >>> http://groups.google.com/**group/django-users?hl=en<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...@googlegroups.com >> . >> To unsubscribe from this group, send email to django-users...@** >> googlegroups.com . >> For more options, visit this group at http://groups.google.com/** >> group/django-users?hl=en<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 view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/l-YTjHAwOUAJ. 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.
Python 2.7+Windows 7+Django1.4 + Apache2.2 +mod_wsgi
For what it's worth, on Windows I like to use Apache2.2 for development purposes instead of the built in server that you have to fire up using the shell command, manage.py runserver every time you need it. On a Windows 7 machine, I followed the instructions to set up my apache server with django here: https://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/ but I still had plenty of trouble getting it to work propertly. For example, I kept getting import errors in the log files such as, "no module name project.urls" in my wsgi script. Also, apache didn't serve my static files at all. I'm using django version (1, 4, 0, 'alpha', 0) In case anybody is having trouble with this setup, here is a blog that helped me get it working properly: http://pradyumnajoshi.wordpress.com/2009/06/09/setting-up-mod_wsgi-for-apache-and-django-on-windows/ This blog provides simple, detailed instructions on how to set up your apache httpd configuration file, where to download and copy your mod_wsgi file, etc. In addition, in my django.wsgi file, located in project/apache/ directory, I use the following: import os import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))) os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() I found the above at stackoverflow: http://stackoverflow.com/questions/5841531/django-mod-wsgi-apache-importerror-at-no-module-named-djproj-urls Note the above differs slightly from the official docs. Now it all seems to work properly. I got import errors when I simply used sys.path.append(path), where path was the absolute path to my project, instead of lines 4&5 above. Hope this helps someone who might be having trouble like I did. -- 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: Django Baseball Site Model
You could create another field under Stat called team, and rename the class stat to "Stint" or "Term" or "Session" ( I can't think of a better word ) to represent the stats of the player's "stint" at that team, that year. You may also want to and another field to represent how many times the player was traded that season, and in what order, most likely using an integer field. Ex: class Stint(models.Model): # some stuff here team = models.CharField() year = models.IntegerField() traded = models.IntegerField() #if 0, then he wasn't traded, if 1 this is his 2nd team, etc... Hope this helps, Mac On Wednesday, January 16, 2013 3:59:24 PM UTC-8, David Gomez wrote: > > Hi, I would like to make a website about baseball player from an specific > country, but I'm stock how to make the model for the player stat. > > My Current a sample model is like this (The Stat Class is going to be much > longer): > > class PLayer_Bios(models.Model): > my_id = models.SlugField(unique=True) > mlb_id = models.CharField(max_length=50) > name = models.CharField(max_length=50) > last = models.CharField(max_length=50) > middle = models.CharField(max_length=50, blank=True) > jersey = models.CharField(max_length=5) > weight = models.CharField(max_length=10) > height = models.CharField(max_length=10) > bod = models.CharField(max_length=50) > birth_city = models.CharField(max_length=50) > birth_country= models.CharField(max_length=50) > pro_debut_date = models.CharField(max_length=50) > primary_position = models.CharField(max_length=50) > team_name= models.CharField(max_length=50) > throws = models.CharField(max_length=50) > bats = models.CharField(max_length=50) > > > def __unicode__(self): > return self.name > > class Stat (models.Model): > player_id = models.ForeignKey('PLayer_Bios') > stat_id= models.CharField(max_length=50, unique=True) > year= models.IntegerField(max_length=50) > h= models.IntegerField(max_length=50) > 2h = models.IntegerField(max_length=50) > > > > def __unicode__(self): > return self.stat_id > Here is how I want the template to look like: > Each PLayer have this stat and if you see the year, the stat can have > repeat year in two different row if the player was move to another team. > Thanks in advance > BATTING Regular Season Career StatsYEAR▲TEAMLGLEVELGABRHTB2B3BHRRBIBBIBBSO > SBCSAVGOBPSLGOPSGO/AO1992[+] Minors582102344661004292605223.210.311.314 > .626-1993GBOSALA (Full)12851585152203141157158195189.295.376.394.770-1994 > [+] Minors138540103186250271156858361508.344.410.463.873-1995COLINTAAA123 > 48696154205279245611562012.317.394.422.816-1995NYY<http://mlb.mlb.com/stats/sortable.jsp?c_id=nyy#playerType=ALL&season=1995&statType=hitting> > ALMLB1548512184107301100.250.294.375.669-1996NYY<http://mlb.mlb.com/stats/sortable.jsp?c_id=nyy#playerType=ALL&season=1996&statType=hitting> > ALMLB1575821041832502561078481102147.314.370.430.800- > -- 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/-/vsI4NrrPA3cJ. 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: How To Populate A Dropdown List
Here's some sample code that works for me: in models.py class InventoryCloseouts(models.Model): prim = models.IntegerField(primary_key=True, db_column='PRIM') # Field name made lowercase. items = models.CharField(max_length=255, db_column='ITEMS', blank=True) # Field name made lowe gen = models.CharField(max_length=255, db_column='GEN', blank=True) # Field name made lowercase. descrip = models.CharField(max_length=255, db_column='DESCRIP', blank=True) # Field name made l .. etc. def __unicode__(self): return self.items + ":" + self.gen+":"+self.descrip in forms.py class InvtForm2(forms.Form): #used in closeout order view. invent=InventoryCloseouts.objects.all() items = forms.ModelMultipleChoiceField(queryset=invent, widget=forms.Select(attrs={'class':'colr', })) in views.py def order_closeouts(request): return render_to_response('order_closeouts.html', {'forms':forms}, context_instance = RequestContext(request)) On Feb 8, 8:03 am, hank23 wrote: > I have coded a form which will display some data in a dropdown > selection box. The data is being populated from a a queryset that I > have setup in the form's code. However the entries in the dropdown > only display as objects of the table from which they're being > retrieved, and don't display the actual field data that I was hoping > to have it display. So how do I specify in the form which of the table > fields is to be the display field and which is suppoed to be the > underying key value to be passed when and entry is selected? Thanks > for the help. -- 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.
Remote working job opportunity for Python/Django programmers
Hello Python/Django techies, One our client is in need of Python/Django programmer for developing web based casino gaming software using Python,Django,HTML5,Flash, mySQL. Job Requirements: Expert level experience in gathering casino games software requirements, normalization of data,design & implement in Python/Django Expert level experience in Python3.2.x and Django1.3.x ,HML5,MySQL5.5.x, Jboss,Jenkins CI Expert level knowledge in Web technologies and web development methodologies Expert level knowledge in OOA,OOP,Reviewing design,Reviewing code,Testing for bugs,test automation Experience with Casio software development such as Bingo,Slots is a requirement, Expert level experience researching for open source framework/tools to integrate into website Experience on Linux platform is a plus Candidate should be willing to work 100% remote on your own computer,be an individual solid contributor and be willing expand the team as project grows. This an excellent opportunity for Python/Django programmers. Interested technical person, please respond to this email with resume and contact information. Our HR will call you Thanks Gordon -- 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.
Toby McGuire
Im a newbie to this. Used to program on COBOl, Fortran and 370 assembler, plus many others -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3cb81086-f190-41d6-889d-cda899e86b34%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used
On Wed, Jan 21, 2009 at 2:35 AM, Keyton Weissinger wrote: > > Oh and just to re-state, this exact same code works like a champ on > import of School or Parent data (neither of which have a ManyToMany > field). > > Keyton I can't reproduce this exception. Try to print import_object_dict just before "new_object = model_import_info.model_for_import.objects.create(**import_object_dict)". > Note that I am NOT yet trying to SAVE the Student object, just instantiate it. Actually Model.objects.create() do try to save() object. If you don't want it, call Model(**import_object_dict) M. --~--~-~--~~~---~--~~ 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: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used
Again, i can't reproduce your problem. It's working using SVN HEAD with your model and this view: http://dpaste.com/111590/. Could you try to use that dict and Student(**mydict) instead of "model_import_info.model_for_import.objects.create" ? Regards, M On Wed, Jan 21, 2009 at 3:06 PM, Keyton Weissinger wrote: > > I'm on django 1.0.1 (NOT 1.0.2). Do you think that has any impact on > this problem? I will try upgrading tonight. > > Any other ideas? > > K --~--~-~--~~~---~--~~ 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: TypeError: 'tuple' object is not callable
On Fri, Jan 23, 2009 at 8:37 AM, joti chand wrote: > File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py", > line 205, in _get_url_patterns >patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) > > File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py", > line 200, in _get_urlconf_module >self._urlconf_module = __import__(self.urlconf_name, {}, {}, ['']) > > File "c:\projects\iFriends\..\iFriends\urls.py", line 17, in >(r'^admin/', include('django.contribute.admin.urls')), > > TypeError: 'tuple' object is not callable Although Malcolm is right about admin, this TypeError seems to me that you forgot a comma before that line. Something like: urlpatterns = patterns('', (r'^someurl/', 'someview') <-- *here* (r'^admin/', include('django.contribute.admin.urls')), ) M --~--~-~--~~~---~--~~ 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: Strange Model behavior
On 1/26/09, Mark Jones wrote: > class Fails(models.Model): > code = models.CharField(max_length=64) > quizid = models.IntegerField(null=False, blank=False) > published_on = models.DateTimeField(auto_now_add=True) > > def __init__(self, *args, **kwargs): > super(Fails, self).__init__(args, kwargs) > === > > python manage.py shell > >>> from Sample import Good,Fails > >>> g = Good() > >>> f = Fails() > >>> type(g.id) > > >>> type(f.id) > I'm not sure what are you trying to do but i do know that you forgot * before args and ** before kwargs M. --~--~-~--~~~---~--~~ 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: Using hashing for password checking in auth module
On Fri, Jan 30, 2009 at 5:36 PM, Guy Rutenberg wrote: > I've started using Django recently and when I've used the auth module > I noticed that it only verifies a plain text password. I'm not > comfortable with this behaviour as it means that passwords have to be > sent by login forms in plain text. > Actually in contrib.auth passwords are stored in SHA1. If you mean that passwords are sent in plain text "over the network" then you should use https. >>> from django.contrib.auth.models import User >>> User.objects.get(pk=1).password u'sha1$a0052$51520b2de8cf5aab6d8fc5bf5e7d09801376031a' Maybe you are confused because User has a method "check_password" that receives a parameter in plain text, but before the check your password is hashed. M. --~--~-~--~~~---~--~~ 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: Filter by ForeignKey reference??
On Mon, Feb 2, 2009 at 10:11 PM, Markus T. wrote: > > Hi, > > I have two simple models: > > class Country(models.Model): > name = models.CharField(_("Name"), max_length=50, > unique=True) > > class Profile(models.Model): > name = models.CharField(_("Name"), max_length=50, > unique=True) > country = models.ForeignKey(Country) > > > If I want to create a list of all countries that are actually > referenced (i.e. used by at least one Profile entry), how would I code > that in Django? If you need country_id/country_name: >>> Profile.objects.values('country__id', >>> 'country__name').select_related('country').distinct() [{'country__name': u'Country1', 'country__id': 1}, {'country__name': u'Country3', 'country__id': 3}] Which run this query: >>> Profile.objects.values('country__id', >>> 'country__name').select_related('country').distinct().query.as_sql() ('SELECT DISTINCT "b_profile"."country_id", "b_country"."name" FROM "b_profile" INNER JOIN "b_country" ON ("b_profile"."country_id" = "b_country"."id")', ()) M. --~--~-~--~~~---~--~~ 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: Filter by ForeignKey reference??
On Mon, Feb 2, 2009 at 11:59 PM, Martin Conte Mac Donell wrote: > If you need country_id/country_name: > >>>> Profile.objects.values('country__id', >>>> 'country__name').select_related('country').distinct() > [{'country__name': u'Country1', 'country__id': 1}, {'country__name': > u'Country3', 'country__id': 3}] > > Which run this query: > >>>> Profile.objects.values('country__id', >>>> 'country__name').select_related('country').distinct().query.as_sql() > ('SELECT DISTINCT "b_profile"."country_id", "b_country"."name" FROM > "b_profile" INNER JOIN "b_country" ON ("b_profile"."country_id" = > "b_country"."id")', ()) Also you can ommit select_related('country') which is implicit with "country__name" and "country__id". M. --~--~-~--~~~---~--~~ 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: forms not valid
On Mon, Feb 2, 2009 at 11:35 PM, vierda wrote: > > Hi all, I have three forms and none of these forms pass is_valid() > test when I test in intrepeter. kindly help for point out what's > problem with my forms. thank you. > > from django.contrib.auth.models import User > from django.contrib.auth.forms import UserCreationForm > from django import forms > from django.forms import ModelForm > > #1st > class RegistrationForm(UserCreationForm): > email = forms.EmailField(label=("e-mail")) > > class Meta: > model = User > fields = ('username', 'email','password2') > > def clean_email(self): >email = self.cleaned_data["email"] >try: >User.objects.get(email=email) >except User.DoesNotExist: >return email >raise forms.ValidationError(("e-mail already exist.")) > > #2nd > class UserProfileForm(ModelForm): > class Meta : > model = User > fields = ('email',) > > #3rd > class DeleteForm(ModelForm): > class Meta : > model = User > fields = ('username',) Wait. Do you know what "is_valid()" do, right?. :-) is_valid refers to data sent to the form (for example request.POST), not form itself. For instance: >>> f = UserProfileForm({'email':'a'}) >>> f.is_valid() False >>> f.errors {'email': [u'Enter a valid e-mail address.']} But: >>> f = UserProfileForm({'email':'a...@a.com'}) >>> f.is_valid() True M --~--~-~--~~~---~--~~ 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: how to check manytomany field in filter?
On Tue, Feb 3, 2009 at 12:21 AM, garagefan wrote: > > Trying to test a manytomany field in a model that will be user names. > Building that is simple enough in the model, and so is selecting the > users in the admin. > > the problem is filtering a query to test the current logged in user > with the manytomany field to ensure they are listed. > > ie: > filter(Q(is_private=False) | Q(approvedUsers = str(request.user)) > > where approvedUsers is the manytomany field Actually i don't understand fully what are you trying to do, but based on your call: Did you try filter(Q(is_private=False) | Q(approvedUsers=request.user)? M --~--~-~--~~~---~--~~ 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: Making fields conditionally required based on another field's state
On Mon, Feb 2, 2009 at 7:21 PM, wotaskd wrote: > > Hello everyone, a quick (and I guess easy) one: > > Is there any way, on the admin site, to make a field for a model > mandatory, if another one is blank and vice-versa? Yeap, you need to write your own form class, subclass clean() method do your checks and return cleaned_data or raise an exception. Take a look to: http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other Also (in advance to your next question) take a look to: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin M --~--~-~--~~~---~--~~ 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: [slightly offtopic] Which Python are people using on OSX?
On Thu, Feb 5, 2009 at 7:07 PM, cjl wrote: > Honestly, I'm leaning towards option number 5. I'm just wondering what > other Django folks are using. I'm using MacPorts. It's the practical way. (x11? really?. Which version are you trying?) I'm using those ports: # port installed | grep py py25-bz2 @2.5.4_0 (active) py25-dnspython @1.6.0_0 (active) py25-hashlib @2.5.4_0 (active) py25-pil @1.1.6_0 (active) py25-psycopg2 @2.0.5.1_1+postgresql83 (active) py25-readline @2.5.4_0 (active) py25-setuptools @0.6c9_0 (active) py25-socket-ssl @2.5.4_0 (active) py25-sqlite3 @2.5.4_0 (active) py25-yaml @3.06_0 (active) py25-zlib @2.5.4_0 (active) python25 @2.5.4_0+darwin_9+macosx (active) python_select @0.2.1_0+darwin_9 (active) M. --~--~-~--~~~---~--~~ 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: Using forloop.counter0 on a variable
You can do that with a very simple template tag register = template.Library() @register.simple_tag def get_element(list, index): # You should catch IndexError here. return list[index] Template side: {% get_element secondprice forloop.counter0 %} Regards, Martin Conte Mac Donell > > On Dec 17, 2007 3:06 PM, Greg < [EMAIL PROTECTED]> wrote: > > > > > Hello, > > I have the following in my template: > > > > {% for a in thespinfo %} > > {{ secondprice.forloop.counter0|floatformat:2 }} > > {% endfor %} > > > > However, nothing appears when I run this code > > > > /// > > > > My secondprice variable contians a list like ['25', '14', '56']. Each > > time that my for loop is run through then I want to display that > > current element in the secondprice element. So the first time my loop > > is run through then I want it to loop like: > > > > {{ secondprice.0|floatformat:2 }}...then next time like {{ secondprice. > > 1|floatformat:2 }}...etc > > > > > > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem trying to configure Django with FastCGI and Lighttpd
Which version of django are you using? What do you see on lighttpd logs? Is port 3303 open with fcgi process? Regards, Martin Conte Mac Donell On Dec 17, 2007 4:23 PM, Chris Moffitt <[EMAIL PROTECTED]> wrote: > Take a look in the lighttpd server logs to see if there are any errors > that might point you in the right direction. > > The other thing is that you're running this threaded but you're spawning > multiple processes. I suspect that could be causing problems too. Trying > running it prefork and see if that helps. > > -Chris > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using forloop.counter0 on a variable
What about $ {% filter floatformat:2 %} {% get_element secondprice forloop.counter0 %} {% endfilter %} Regards, -- Martín Conte Mac Donell On Dec 17, 2007 6:53 PM, Greg <[EMAIL PROTECTED]> wrote: > > Martin, > Yep...that worked. Thanks! > > However, now I'm not using the '|floatformat:2'. Is there anyway that > I can use that in my template with the new way: > > ${% get_element secondprice forloop.counter0 %} > > For an example...currently I'm getting back 124.1...I would like to > have it be 124.10 > > > On Dec 17, 1:54 pm, "Martin Conte Mac Donell" <[EMAIL PROTECTED]> > wrote: > > You can do that with a very simple template tag > > > > register = template.Library() > > > > @register.simple_tag > > def get_element(list, index): > > # You should catch IndexError here. > > return list[index] > > > > Template side: > > > > {% get_element secondprice forloop.counter0 %} > > > > Regards, > > Martin Conte Mac Donell > > > > > > > > > > > > > On Dec 17, 2007 3:06 PM, Greg < [EMAIL PROTECTED]> wrote: > > > > > > Hello, > > > > I have the following in my template: > > > > > > {% for a in thespinfo %} > > > > {{ secondprice.forloop.counter0|floatformat:2 }} > > > > {% endfor %} > > > > > > However, nothing appears when I run this code > > > > > > /// > > > > > > My secondprice variable contians a list like ['25', '14', '56']. > Each > > > > time that my for loop is run through then I want to display that > > > > current element in the secondprice element. So the first time my > loop > > > > is run through then I want it to loop like: > > > > > > {{ secondprice.0|floatformat:2 }}...then next time like {{ > secondprice. > > > > 1|floatformat:2 }}...etc- Hide quoted text - > > > > - Show quoted text - > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---