Search Results

Search found 4109 results on 165 pages for 'django paypal'.

Page 86/165 | < Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >

  • add text to the choice_label of ChoiceField in Django

    - by pablo
    The ChoiceField creates a select html element and the options show the choice_label which is the _unicode_ of each model object. How can I change the text of the choice_label without modifying _unicode_ ? I have a Product model and I want to show in the options text the product name + price + link to edit. I've searched in fields.py and widgets.py but couldn't find what needed to be changed. Thanks

    Read the article

  • ForeignKey django 1.1.1 model

    - by Spikie
    i have class staff_name(models.Model): firstname = models.CharField(max_length=150) surname = models.CharField(max_length=150) class inventory_transaction(models.Model): staffs = models.ForeignKey(staff_name) i want to get or create staff surname and first name through inventory_transaction i used these code below inventory_transaction.objects.get_or_create(staffs_surname_contains=sname,staffs_firstname_contains=fname) i got this error "staffs_surname_contains can not be defined" what have i done wrong ? thanks

    Read the article

  • Django microblog showing a logged in user only his posts

    - by dana
    i have a miniblog application, with a class named New(refering to a new post), having a foreign key to an user(who has posted the entry). above i have a method that displays all the posts from all the users. I'd like to show to the logged in user, only his posts How can i do it? Thanks in advance! def paginate(request): paginator = New.objects.all() return render_to_response('news/newform.html', { 'object_list': paginator, }, context_instance=RequestContext(request))

    Read the article

  • django url user id versus userprofile id problem

    - by dana
    hello there, i have a mini comunity where each user can search and find another user profile. Userprofile is a class model, indexed differently compared to user model class (user id is not equal to userprofile id) But i cannot see a user profile by typing in the url the corresponding id. I only see the profile of the currently logged in user. Why is that? I'd also want to have in my url the username (a primary key of the user table also) and NOT the id (a number). The guilty part of the code is: what can i replace that request.user with so that it wil actually display the user i searched for, and not the currently logged in? def profile_view(request, id): u = UserProfile.objects.get(pk=id) cv = UserProfile.objects.filter(created_by = request.user) blog = New.objects.filter(created_by = request.user) return render_to_response('profile/publicProfile.html', { 'u':u, 'cv':cv, 'blog':blog, }, context_instance=RequestContext(request)) in urls (of the accounts app): url(r'^profile_view/(?P<id>\d+)/$', profile_view, name='profile_view'), and in template: <h3>Recent Entries:</h3> {% load pagination_tags %} {% autopaginate list 10 %} {% paginate %} {% for object in list %} <li>{{ object.post }} <br /> Voted: {{ vote.count }} times.<br /> {% for reply in object.reply_set.all %} {{ reply.reply }} <br /> {% endfor %} <a href=''> {{ object.created_by }}</a> <br /> {{object.date}} <br /> <a href = "/vote/save_vote/{{object.id}}/">Vote this</a> <a href="/replies/save_reply/{{object.id}}/">Comment</a> </li> {% endfor %} thanks in advance!

    Read the article

  • arbitrary typed data in django model

    - by Dmitry Shevchenko
    I have a model, say, Item. I want to store arbitrary amount of attributes on it, like title, description, release_date. And i want them to be not just strings but have python type, so string, boolean, datetime etc. What are my options here? EAV pattern with separate name-value table won't work because of the same DB type across all values. JSONField can probably help, but it doesn't know about datetime, for example. Also i was looking at PickeField, it fits perfectly, but i'm a bit concerned about performance.

    Read the article

  • Django stupid mark_safe?

    - by Mark
    I wrote this little function for writing out HTML tags: def html_tag(tag, content=None, close=True, attrs={}): lst = ['<',tag] for key, val in attrs.iteritems(): lst.append(' %s="%s"' % (key, escape_html(val))) if close: if content is None: lst.append(' />') else: lst.extend(['>', content, '</', tag, '>']) else: lst.append('>') return mark_safe(''.join(lst)) Which worked great, but then I read this article on efficient string concatenation (I know it doesn't really matter for this, but I wanted consistency) and decided to update my script: def html_tag(tag, body=None, close=True, attrs={}): s = StringIO() s.write('<%s'%tag) for key, val in attrs.iteritems(): s.write(' %s="%s"' % (key, escape_html(val))) if close: if body is None: s.write(' />') else: s.write('>%s</%s>' % (body, tag)) else: s.write('>') return mark_safe(s.getvalue()) But now my HTML get escaped when I try to render it from my template. Everything else is exactly the same. It works properly if I replace the last line with return mark_safe(unicode(s.getvalue())). I checked the return type of s.getvalue(). It should be a str, just like the first function, so why is this failing?? Also fails with SafeString(s.getvalue()) but succeeds with SafeUnicode(s.getvalue()). I'd also like to point out that I used return mark_safe(s.getvalue()) in a different function with no odd behavior.

    Read the article

  • Django template not loading javascript and css properly due to urlpatterns

    - by fmsf
    Hey, When this one runs everything goes fine: (r"^newobject$", "views.myobjects.newobject"), All the CSS + JS files are properly fetched from: static/css/... static/js/... When this one runs: (r"^mybjects/(([a-z]|[A-Z]|[0-9])+)$","views.myobjects.loadobject"), All the css and JS files that are being fetched, are run trough the urlpatterns and are returning my defailt page: (r"", 'views.main.index'), This makes all my CSS and JS code to actualy be HTML. My guess is that i'm giving some noob mistake. Is there any common reason why this should happen? And how to fix it?

    Read the article

  • django accepting GET parameters

    - by tipu
    I want the index page to accept parameters, whether it be mysite.com/search/param_here or mysite.com/?search=param_here I have this in my URL patterns but I can't get it to work.. any suggestions? urlpatterns = patterns('', (r'^$/(?P<tag>\w+)', 'twingle.search.views.index'), )

    Read the article

  • Cannot use "image.save" on django

    - by zjm1126
    My error is: IOError at /mytest/photo/upload/ [Errno 2] No such file or directory: u'/mytest/photo/upload/2.png' And my view is: UPLOAD_URL = '/mytest/photo/upload/' def upload(request): buf = request.FILES.get('photo', None) print buf if buf: #data = buf.read() #f = StringIO.StringIO(data) image = Image.open(buf) #image = image.convert('RGB') name = '%s%s' % (UPLOAD_URL, buf.name) image.save(file(name, 'wb'), 'PNG') return HttpResponse('ok') return HttpResponse('no') And my urls.py is: urlpatterns = patterns('mytest.views', url(r'^photo/upload/$','upload',name="") ) How can I fix this?

    Read the article

  • Django m2m form appearing fields

    - by dana
    I have a classroom application,and a follow relation. Users can follow each other and can create classrooms.When a user creates a classroom, he can invite only the people that are following him. The Classroom model is a m2m to User table. i have in models. py: class Classroom(models.Model): creator = models.ForeignKey(User) classname = models.CharField(max_length=140, unique = True) date = models.DateTimeField(auto_now=True) open_class = models.BooleanField(default=True) members = models.ManyToManyField(User,related_name="list of invited members") and in models.py of the follow application: class Relations(models.Model): initiated_by = models.ForeignKey(User, editable=False) date_initiated = models.DateTimeField(auto_now=True, editable = False) follow = models.ForeignKey(User, editable = False, related_name = "follow") date_follow = models.DateTimeField(auto_now=True, editable = False) and in views.py of the classroom app: def save_classroom(request, username): if request.method == 'POST': u = User.objects.get(username=username) form = ClassroomForm(request.POST, request.FILES) if form.is_valid(): new_obj = form.save(commit=False) new_obj.creator = request.user r = Relations.objects.filter(initiated_by = request.user) # new_obj.members = new_obj.save() return HttpResponseRedirect('.') else: form = ClassroomForm() return render_to_response('classroom/classroom_form.html', { 'form': form, }, context_instance=RequestContext(request)) i'm using a ModelForm for the classroom form, and the default view, taking in consideration my many to many relation with User table, in the field Members, is a list of all Users in my database. But i only want in that list the users that are in a follow relationship with the logged in user - the one who creates the classroom. How can i do that? Thanks!

    Read the article

  • Dynamic choices for Django SelectMultiple Widget

    - by PhilGo20
    I'm building a form (not modelForm) where i'd like to use the SelectMultiple Widget to display choices based on a query done during the init of the form. I can think of a few way to do this but I am not exactly clear on the right way to do it. I see different options. I get the "choices" I should pass to the widget in the form init but I am not sure how I should pass them. class NavigatorExportForm(forms.Form): def __init__(self,user, app_id, *args,**kwargs): super (NavigatorExportForm,self ).__init__(*args,**kwargs) # populates the form language_choices = Navigator.admin_objects.get(id=app_id).languages.all().values_list('language', flat=True) languages = forms.CharField(max_length=2, widget=forms.SelectMultiple(choices=???language_choices))

    Read the article

  • django link to any user profile in social comunity

    - by dana
    i am trying to build a virtual comunity, and i have a profile page, and a personal page. In the profile page, one can see only the posts of one user(the user whos profile is checked), in the personal page one can see his posts, plus all the posts he has subscribed to (just like in Facebook) it's a little confusing for me how i can link to the profile of one user, i mean when anybody clicks on a username, it should link to his personal profile page. for example, if someone searches name "abc", the rsult would be "abc",and link to his profile. How can i pass to one function the username or id of a linked user? i mean, showing the profile of the logged in user who is checking his profile is quite easy.But how about another user profile, if one wants to access it? thanks a lot!

    Read the article

  • Django dislaying upload file content

    - by dana
    hello, i have an application that loads different documents to the server, and allows users to read documents' content. i am uploading the documents to the server, and then i try to read the courses by id, like: def view_course(request,id): u = Courses.objects.get(pk=id) etc But i don't find anywhere : how can i actually read the content of a /.doc/.pdf/.txt and display it on a web page? thanks in advance!

    Read the article

  • Django save, column specified twice

    - by realshadow
    Hey, I would like to save a modified model, but I get Programming error - that a field is specified twice. class ProductInfo(models.Model): product_info_id = models.AutoField(primary_key=True) language_id = models.IntegerField() product_id = models.IntegerField() description = models.TextField(blank=True) status = models.IntegerField() model = models.CharField(max_length=255, blank=True) label = models.ForeignKey(Category_info, verbose_name = 'Category_info', db_column = 'language_id', to_field = 'node_id', null = True) I get this error because the foreign key uses as db_column language_id. If I will delete it, my object will be saved properly. I dont quite understand whats going on and since I have defined almost all of my models this way, I fear its totally wrong or maybe I just missunderstood it... Any ideas? Regards

    Read the article

  • django file upload in 2 steps

    - by alexarsh
    Hi, I want to upload a file in 2 steps. First I want to upload it and show the errors and on the second step I want actually to save the file data in the database. So I made a simple form and my problem is how to pass the same file to the form on the second step? I mean how to insert request.FILES data in the same form again. Or maybe there is a better way? Thanks, Arshavski Alexander.

    Read the article

  • Django: tinyMCE and cross site javascript

    - by pistacchio
    Hi, follow this question, I was able to set some textareas in my admin page as richtext inputs. The most voted answer suggests to follow an example and is what i did. Also, it talks about a problem concerning "blank pages". I'm having the same problem and I'm not able to solve it. I have my media files served by a different server, so MEDIA_URL points to a different host with a different port. To simulate this in my dev environment, I also serve media files from a different port. Debugging the failing javascript, Chrome yelds: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/admin/blog/post/add/ from frame with URL http://localhost:88/s3mangerie/js/tiny_mce/themes/advanced/image.htm. Domains, protocols and ports must match. How to solve this problem? Thanks

    Read the article

  • Django: Group by?

    - by Mark
    I'm looking for something like the following: previous_invoices = Invoice.objects.filter(is_open=False).order_by('-created').group_by('user') (group_by() doesn't exist) This would find the most recently closed invoice for each user. This aggregation API seems to let you do stuff like this for counts and sums, but I don't need a count or sum or anything, I actually want the invoice objects!

    Read the article

  • Django: url tag reverse

    - by Alexander A.Sosnovskiy
    Can you help me to get url in my template: url(r'^page/(?P[-\d]+)$', 'show_port', {"template_name": "port.html"}, name="port",), href="{% url port page_num=1 %}" I want to get /page/1 as a result , but don't know how :( Caught an exception while rendering: Reverse for 'port' with arguments '()' and keyword arguments '{'page_num': 1}' not found. The same thing if href="{% url port 1 %}"

    Read the article

  • Django FormWizard with dynamic forms

    - by krys
    I want to implement a simple 2 part FormWizard. Form 1 will by dynamically generated something like this: class BuyAppleForm(forms.Form): creditcard = forms.ChoiceField(widget = forms.RadioSelect) type = forms.ChoiceField(widget = forms.RadioSelect) def __init__(self,*args, **kwargs): user = kwargs['user'] del kwargs['user'] super(BuyAppleForm, self).__init__(*args, **kwargs) credit_cards = get_credit_cards(user) self.fields['creditcard'].choices = [(card.id,str(card)) for card in credit_cards] apple_types= get_types_packages() self.fields['type'].choices = [(type.id,str(type)) for type in apple_types] This will dynamically create a form with lists of available choices. My second form, I actually want no input. I just want to display a confirmation screen containing the credit card info, apple info, and money amounts (total, tax, shipping). Once user clicks OK, I want the apple purchase to commence. I was able to implement the single form way by passing in the request.user object in the kwargs. However, with the FormWizard, I cannot figure this out. Am I approaching the problem wrong and is the FormWizard not the proper way to do this? If it is, how can the Form __init__ method access the user object from the HTTP request?

    Read the article

  • django hidden field error

    - by dana
    hi, there, i'm building a message system for a virtual community, but i can't take the userprofile id i have in views.py def save_message(request): if request.method == 'POST': form = MessageForm(request.POST) if form.is_valid(): new_obj = form.save(commit=False) new_obj.sender = request.user u = UserProfile.objects.get(request.POST['userprofile_id']) new_obj.owner = u new_obj.save() return HttpResponseRedirect('.') else: form = MessageForm() return render_to_response('messages/messages.html', { 'form': form, }, context_instance=RequestContext(request)) and the template: {% block primary %} <form action="." method="post"> {{ form.as_p }} <p><input type="hidden" value="{{ userprofile.id }}" name = "owner" /></p> <p><input type="submit" value="Send Message!" /></p> </form> {% endblock %} forms.py: class MessageForm(ModelForm): class Meta: model = Messages fields = ['message'] models.py: class Messages(models.Model): message = models.CharField(max_length = 300) read = models.BooleanField(default=False) owner = models.ForeignKey(UserProfile) sender = models.ForeignKey(User) I don't figure out why i get this error,since i'm just trying to get the profileId of a user, using a hiddeen field. the error is: Key 'UserProfile_id' not found in <QueryDict: {u'owner': [u''], u'message': [u'fdghjkl']}> and i'm getting it after i fill out the message text field. Thanks!

    Read the article

  • Bypass django form validation on new form instance

    - by Thomas Schultz
    Hello! I have a situation where we are trying to autofill some form data on the second page of a signup and I was wondering if there's a way to bypass the entire form validation when we pass in only a couple of fields? so we have something like form = NewForm(request.POST) Where request.POST only contains some of the fields in NewForm(). So the page loads and there is feedback about how some fields are not filled in yet. This all happens from the GET request of the second page. Is there a way to do something like... form = NewForm(request.POST, validate=False)

    Read the article

  • django class with an array of "parent" foreignkeys issue

    - by user298032
    Let's say I have a class called Fruit with child classes of the different kinds of Fruit with their own specific attributes, and I want to collect them in a FruitBasket: class Fruit(models.Model):     type = models.CharField(max_length=120,default='banana',choices=FRUIT_TYPES)     ... class Banana(Fruit):     """banana (fruit type)"""     length = models.IntegerField(blank=True, null=True)     ... class Orange(Fruit):     """orange (fruit type)"""     diameter = models.IntegerField(blank=True, null=True)     ... class FruitBasket(models.Model):     fruits = models.ManyToManyField(Fruit)     ... The problem I seem to be having is when I retrieve and inspect the Fruits in a FruitBasket, I only retrieve the Fruit base class and can't get at the Fruit child class attributes. I think I understand what is happening--when the array is retrieved from the database, the only fields that are retrieved are the Fruit base class fields. But is there some way to get the child class attributes as well without multiple expensive database transactions? (For example, I could get the array, then retrieve the child Fruit classes by the id of each array element). thanks in advance, Chuck

    Read the article

  • How to develop modular web UIs with Django?

    - by nh2
    When doing larger sites in "big business", you most probalbly work in a team with several developers. Let's say dev A makes a form to insert new user data, B creates a user list, C makes some privilege administration and D does crazy statistic graphs work with image generation and so on. Each dev begins to develop his own component, creates a view and a template and tests that independently, until each component works. Now, the client wants to have all those components on one bit HTML page. How to achieve this? How to assemble different views/templates in a form of composition so that they remain modular and can be developed and tested independently? It seems inheritance is not the way to go because all of those UI components are equal and there is no hierarchy. The idea of the assembling template is something like <html> <head> // include the css for the components and their assembly </head> <body> // include user data form here <some containers, images, and so on> // show user list // show privilege administration in this part // and finally, the nice statistic graphs // perhaps, we want to display some other components here in future </body> </html> I have not found an answer on the net yet. Most people come up with one big template which just implements all of the UI functionality, removing all modularity. Each component shall have its own template and view dealing only with that component developed by one person each, and they then shall be sticked together just like bricks. I would highly appreciate any hints!

    Read the article

< Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >