Search Results

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

Page 41/165 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • Django ForeignKey _set on an inherited model

    - by neolaser
    I have two models Category and Entry. There is another model ExtEntry that inherits from Entry class Category(models.Model): title = models.CharField('title', max_length=255) description = models.TextField('description', blank=True) ... class Entry(models.Model): title = models.CharField('title', max_length=255) categories = models.ManyToManyField(Category) ... class ExtEntry(Entry): groups= models.CharField('title', max_length=255) value= models.CharField('title', max_length=255) ... I am able to use the Category.entry_set but I want to be able to do Category.blogentry_set but it is not available. If this is not available,then I need another method to get all ExtEntryrelated to one particular Category Thanks

    Read the article

  • Django Custom Admin

    - by Harry
    Hello there Currently I have an app with a save method in its models.py . So I would like to change this so the models does not do the save() method, but rather have a separate view that will do this in die admin site. Can you please direct me in the correct direction? Thank you

    Read the article

  • Django - Add rows to MySQL database

    - by yeenow123
    So I already have a database setup with a few columns and a few rows already inserted in. I'm trying to create a view that you would just input information into a form and press Submit, then a row would be added to the MySQL database with the information you just typed in. I believe you can do this with admin, but I would like to try without admin and I'm not sure if this is possible? I've been using the MySQL commandline to add rows as of now..

    Read the article

  • Aggregation over a few models - Django

    - by RadiantHex
    Hi folks, I'm trying to compute the average of a field over various subsets of a queryset. Player.objects.order_by('-score').filter(sex='male').aggregate(Avg('level')) This works perfectly! But... if I try to compute it for the top 50 players it does not work. Player.objects.order_by('-score').filter(sex='male')[:50].aggregate(Avg('level')) This last one returns the exact same result as the query above it, which is wrong. What am I doing wrong? Help would be very much appreciated!

    Read the article

  • Django limit access by group only

    - by Mike
    I only you can limit what a user can do via the user permissions in admin.. But is there a way to limit them in admin via what group you add them to? I want to allow a certain group to do everything in that model if they belong to a certain group thanks!

    Read the article

  • How to save links in Django

    - by xRobot
    I have a simple Blog model with a TextFields. What is the best way to save link ? 1) Saving link in the database in this form: http://www.example.com and then using some filter in the template to trasform it in form: <a rel="nofollow" href="http://www.example.com>http://www.example.com</a> 2) Saving link in the database directly in this form: <a rel="nofollow" href="http://www.example.com>http://www.example.com</a>

    Read the article

  • Get Url Parameters In Django

    - by picomon
    I want to get current transaction id in url. it should be like this www.example.com/final_result/53432e1dd34b3 . I wrote the below codes, but after successful payment, I'm redirected to Page 404. (www.example.com/final_result//) Views.py @csrf_exempt def pay_notif(request, v_transaction_id): if request.method=='POST': v_transaction_id=request.POST.get('transaction_id') endpoint='https://testpay.com/?v_transaction_id={0}&type=json' req=endpoint.format(v_transaction_id) last_result=urlopen(req).read() if 'Approved' in last_result: session=Pay.objects.filter(session=request.session.session_key).latest('id') else: return HttpResponse(status=204) return render_to_response('final.html',{'session':session},context_instance=RequestContext(request)) Urls.py url(r'^final_result/(?P<v_transaction_id>[-A-Za-z0-9_]+)/$', 'digiapp.views.pay_notif', name="pay_notif"), Template: <input type='hidden' name='v_merchant_id' value='{{newpayy.v_merchant_id}}' /> <input type='hidden' name='item_1' value='{{ newpayy.esell.up_name }}' /> <input type='hidden' name='description_1' value='{{ newpayy.esell.up_description }}' /> <input type='hidden' name='price_1' value='{{ newpayy.esell.up_price }}' /> #page to be redirected to after successful payment <input type='hidden' name='success_url' value='http://127.0.0.1:8000/final_result/{{newpayy.v_transaction_id}}/' /> How can I go about this?

    Read the article

  • Django modelform ForeignKey List

    - by Harry
    How do you get each item in the ForeignKey field in a list, for example: class Delegate(models.Model): excursion = models.ForeignKey(Excursion, limit_choices_to = {'is_activity': False}, related_name='excursion', null=True, blank=True) Template: {% for object in formset.excursion_set.all %} {{ object.lable }} etc {% endfor %} My reason is that I don't want the options to display as a dropdown, but in a custom way that I will style etc.

    Read the article

  • How to retrieve items from a django queryset?

    - by sharataka
    I'm trying to get the video element in a queryset but am having trouble retrieving it. user_channel = Everything.objects.filter(profile = request.user, playlist = 'Channel') print user_channel[0] #returns the first result without error print user_channel[0]['video'] #returns error Models.py: class Everything(models.Model): profile = models.ForeignKey(User) playlist = models.CharField('Playlist', max_length = 2000, null=True, blank=True) platform = models.CharField('Platform', max_length = 2000, null=True, blank=True) video = models.CharField('VideoID', max_length = 2000, null=True, blank=True) video_title = models.CharField('Title of Video', max_length = 2000, null=True, blank=True) def __unicode__(self): return u'%s %s %s %s %s' % (self.profile, self.playlist, self.platform, self.video, self.video_title)

    Read the article

  • Django menu item sorting

    - by doktorno
    Hi i've got MenuItem model : MenuItem(models.Model) name=models.CharField(max_length=50) url = models.URLField() position = models.IntegerField() Class Meta: ordering =['position'] then i'm retriving it by MenuItem.objects.all() My question is how can i make any user friendly interface in admin panel to allow sorting MenuItems - for example list with + and - buttons to move MenuItem up and down ....

    Read the article

  • Django: common template subsections

    - by Parand
    What's a good way to handle commonly occurring subsections of templates? For example, there is a sub-header section that's used across 4 different pages. The pages are different enough to not work well with template inheritance (ie. "extends" doesn't fit well). Is "include" the recommended method here? It feels a bit heavyweight, requiring each subsection or snippet to be in its own file. Are there any performance issues in using include or is it smart about forming template from the subsections (ie. if I make extensive use of it, do I pay any penalties)? I think what I'm looking for is something like template tags, but without the programming - a simple way to create a library of html template tags I can sprinkle in other templates.

    Read the article

  • Default FileField names for Django files

    - by Adam Nelson
    I have a model: class Example(models.Model): unique_hash = models.CharField(max_length=32,unique=True) content = models.FileField(upload_to='source',blank=True,verbose_name="HTML Content File") I would like to be able to set the content filename to default to a callable, but I don't see any way to have the callable reference unique_hash (or vice versa). Is this possible?

    Read the article

  • Django Find Out if User is Authenticated in Custom Tag

    - by greggory.hz
    I'm trying to create a custom tag. Inside this custom tag, I want to be able to have some logic that checks if the user is logged in, and then have the tag rendered accordingly. This is what I have: def user_actions(context): request = template.Variable('request').resolve(context) return { 'auth': request['user'].is_athenticated() } register.inclusion_tag('layout_elements/user_actions.html', takes_context=True)(user_actions) When I run this, I get this error: Caught VariableDoesNotExist while rendering: Failed lookup for key [request] in u'[{}]' The view that renders this ends like this: return render_to_response('start/home.html', {}, context_instance=RequestContext(request)) Why doesn't the tag get a RequestContext object instead of the Context object? How can I get the tag to receive the RequestContext instead of the Context? EDIT: Whether or not it's possible to get a RequestContext inside a custom tag, I'd still be interested to know the "correct" or best way to determine a user's authentication state from within the custom tag. If that's not possible, then perhaps that kind of logic belongs elsewhere? Where?

    Read the article

  • django overwrite form clean method

    - by John
    Hi, When overwriting a form clean method how do you know if its failed validation on any of the fields? e.g. in the form below if I overwrite the clean method how do I know if the form has failed validation on any of the fields? class PersonForm(forms.Form): title = Forms.CharField(max_length=100) first_name = Forms.CharField(max_length=100) surname = Forms.CharField(max_length=100) password = Forms.CharField(max_length=100) def clean(self, value): cleaned_data = self.cleaned_data IF THE FORM HAS FAILED VALIDATION: self.data['password'] = 'abc' raise forms.ValidationError("You have failed validation!") ELSE: return cleaned_data Thanks

    Read the article

  • I want to select the distict value from models field and then update them (django)

    - by qulzam
    I have models... class Item(models.Model): name = models.CharField('Item Name', max_length = 30) item_code = models.CharField(max_length = 10) color = models.CharField(max_length = 150, null = True, blank = True) size = models.CharField(max_length = 30, null = True, blank = True) fabric_code = models.CharField(max_length = 30, null = True, blank = True) I have values in Item. in Item model name field has the similar values..(but the other values of record are change). I want to select the name field values distinctly(ie similar values select only ones). in one box(like combo box). What kind of form or views i use??

    Read the article

  • How do I set prifix to django contrib tables names?

    - by Software Enthusiastic
    HI One of my requirement is to have prefix on all the tables of the django based project (Because db is hosted on shared server). I have used db_table Meta option to set the prefix for the tables which I have created. Now my query is how do I set the prefix for tables provided by django.contrib. Instead of auth_group django should create prefix_auth_group.... How do I do that? Thank you very much...

    Read the article

  • reverse many to many fields in Django + count them

    - by cleliodpaula
    I'm trying to figure out how to solve this class Item(models.Model): type = models.ForeignKey(Type) name = models.CharField(max_lenght = 10) ... class List(models.Model): items = models.ManyToManyField(Item) ... I want to count how many an Item appears in another Lists, and show on template. view def items_by_list(request, id_): list = List.objects.get(id = id_) qr = list.items.all() #NOT TESTED num = [] i = 0 for item in qr: num[i] = List.objects.filter(items__id = item__id ).count() #FINISH NOT TESTED c = {} c.update(csrf(request)) c = {'request':request, 'list' : qr, 'num' : num} return render_to_response('items_by_list.html', c, context_instance=RequestContext(request)) template {% for dia in list %} <div class="span4" > <div> <h6 style="color: #9937d8">{{item.type.description}}</h6> <small style="color: #b2e300">{{ item.name }}</small> <small style="color: #b2e300">{{COUNT HOW MANY TIMES THE ITEM APPEAR ON OTHER LISTS}}</small> </div> {% endfor %} This seems to be easy, but I could not implement yet. If anyone has some glue to me, please help me. Thanks in advance.

    Read the article

  • Django template CSS/IMG is "off" in the URL

    - by erimar77
    I have /path/to/my/theme/static/css/frontend.css which is called by base.html <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/frontend.css" media="all" /> In which I've got a background for the header: #header-wrapper min-width: 960px; height: 150px; background: transparent url(img/header-bg.png) repeat-x center bottom; } The file is /path/to/my/theme/static/img I've run manage.py collectstatic to gather the files and almost everything looks correct except the link generated looks like: http://example.com/static/css/img/header-bg.png In which the image does not show, because the correct URL is: http://example.com/static/img/header-bg.png Where am I going wrong??

    Read the article

  • django flatpage redirects

    - by Joe
    I want to make sure all of my flatpages have the "www" subdomain and redirect to it if they don't. I've looked at some middlewares that redirect to www, but 1. they usually redirect all urls to www and 2. the ones I've found don't work with flatpages. I don't want all of my site urls to redirect to include the www subdomian, just the flatpages. Anyone know how I should go about doing this? Thanks

    Read the article

  • Django forms: prepopulate form with request.user and url parameter

    - by Malyo
    I'm building simple Course Management App. I want Users to sign up for Course. Here's sign up model: class CourseMembers(models.Model): student = models.ForeignKey(Student) course = models.ForeignKey(Course) def __unicode__(self): return unicode(self.student) Student model is extended User model - I'd like to fill the form with request.user. In Course model most important is course_id, which i'm passing into view throught URL parameter (for example http://127.0.0.1:8000/courses/course/1/). What i want to achieve, is to generate 'invisible' (so user can't change the inserted data) form with just input, but containing request.user and course_id parameter.

    Read the article

  • Permission to view, but not to change! - Django

    - by RadiantHex
    Hi folks, is it possible to give users the permission to view, but not to change or delete. currently in the only permissions I see are "add", "change" and "delete"... but there is no "read/view" in there. I really need this as some users will only be able to consult the admin panel, in order to see what has been added in. Help would be amazing!

    Read the article

  • How to loop X times in Django?

    - by Mark
    I have user reviews on my site. Each review has a rating of 1-5 stars. I want to print that many stars. How do I do it? I only see {% for X in Y %} which lets you iterate over a list, but not a certain number of times.

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >