Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: unorderable types: str() >= int() #5

Closed
yadynesh opened this issue Mar 20, 2017 · 5 comments
Closed

TypeError: unorderable types: str() >= int() #5

yadynesh opened this issue Mar 20, 2017 · 5 comments

Comments

@yadynesh
Copy link

yadynesh commented Mar 20, 2017

When I start typing it shows nothing found and the server gives the above error.

@yadynesh
Copy link
Author

models.py

class Customer(models.Model):
	first_name = models.CharField(max_length = 100,null = False, blank=False, verbose_name = 'First Name')
	last_name = models.CharField(max_length = 100,null = False, blank=False, verbose_name = 'Last Name')
	email_id = models.EmailField(max_length = 100,null = False, blank=False, verbose_name = 'Email address')
	join_date = models.DateTimeField(default = timezone.now, editable = False)
	last_modified = models.DateTimeField(auto_now = True)
	subscribe = models.BooleanField(default = False, verbose_name = 'Subscribed')

	def __str__(self):
		return self.first_name + " " + self.last_name + "----" + self.email_id + "----" + str(self.join_date) + "----" \
		+ str(self.last_modified) + "----" + str(self.subscribe)

	def get_absolute_url(self):
		return reverse('adminpanel:list-customers')


class Item(models.Model):
	item_name = models.CharField(max_length = 50, verbose_name = 'Item Name')
	stocks = models.IntegerField()

	def __str__(self):
		return str(self.pk) + "-"+ self.item_name

	def get_absolute_url(self):
		return reverse('adminpanel:list-items')


class Transaction(models.Model):
	trans_id = models.IntegerField(verbose_name = 'Transaction ID')
	cust_id = models.ForeignKey('Customer', on_delete=models.CASCADE, verbose_name = 'Customer ID')
	item_id = models.ForeignKey('Item', on_delete=models.CASCADE, verbose_name = 'Item ID')

	def __str__(self):
		return str(self.trans_id) + "-" + str(self.cust_id) + "-" + str(self.id)

@yadynesh
Copy link
Author

admin.py

from django.contrib import admin
from .models import Customer,Item,Transaction
# from .forms import TransactionForm
from django import forms
from searchableselect.widgets import SearchableSelect
# Register your models here.


class TransactionForm(forms.ModelForm):
	items = forms.ModelMultipleChoiceField(queryset = Item.objects.all(),
			widget = forms.CheckboxSelectMultiple(
				attrs = {
					"class": "btn btn-primary"
				}
			)
		)

	class Meta:
		model = Transaction
		fields = ['trans_id','cust_id']
		exclude = ()
		widgets = {
            'cust_id': SearchableSelect(model='AdminPanel.Customer', search_field='first_name', many = False)
        }

class TransactionAdmin(admin.ModelAdmin):
    form = TransactionForm


class ItemAdmin(admin.ModelAdmin):
    pass


class CustomerAdmin(admin.ModelAdmin):
    pass


admin.site.register(Item,ItemAdmin)
admin.site.register(Customer,CustomerAdmin)
admin.site.register(Transaction,TransactionAdmin)

@yadynesh yadynesh reopened this Mar 29, 2017
shalakhin added a commit to shalakhin/django-searchable-select that referenced this issue Apr 8, 2017
and3rson added a commit that referenced this issue Apr 12, 2017
issue #5 fix unorderable types: str() >= int() with limit
@shalakhin
Copy link
Collaborator

@yadynesh fix was pushed for that. @and3rson maybe that issue can be closed if the bug was fixed

@and3rson
Copy link
Owner

That's right. I'll close this issue once I re-upload the fresh release to pypi.

@shalakhin
Copy link
Collaborator

@and3rson I think you can mark it as done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants