Search Results

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

Page 58/165 | < Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >

  • How to add default value on django save form?

    - by Ignacio
    I have an object Task and a form that saves it. I want to automatically asign created_by field to the currently logged in user. So, my view is this: def new_task(request, task_id=None): message = None if task_id is not None: task = Task.objects.get(pk=task_id) message = 'TaskOK' submit = 'Update' else: task = Task(created_by = GPUser(user=request.user)) submit = 'Create' if request.method == 'POST': # If the form has been submitted... form = TaskForm(request.POST, instance=task) if form.is_valid(): task = form.save(commit=False); task.created_by = GPUser(user=request.user) task.save() if message == None: message = 'taskOK' return tasks(request, message) else: form = TaskForm(instance=task) return custom_render('user/new_task.html', {'form': form, 'submit': submit, 'task_id':task.id}, request) The problem is, you guessed, the created_by field doesn't get saved. Any ideas? Thanks

    Read the article

  • Django admin: how do I add an unrelated model field to a model change/add page?

    - by NP
    I have the following models: class Foo(models.Model): field1 = models.IntegerField() ... class Bar(models.Model): field1 = models.IntegerField() ... class Foo_bar(models.Model): foo = models.ForeignKey(Foo) bar = models.ForeignKey(Bar) ... In the admin, I want it so that in the Foo change/add page, you can specify a Bar object, and on save I want to create a Foo_bar object to represent the relationship. How can I do this through customizing the Admin site/ModelAdmins? Thanks.

    Read the article

  • How to get all objects with their children using django orm?

    - by kender
    Hi, I got very simple hierarchical structure: every object can have 0 or 1 parent. There's no limit on how many children each object can have. So in my application I got such a model: class O(Model): name = CharField(max_length = 20) parent = ForeignKey('O', related_name = 'children') Now I would like to be able to fetch all objects who have a particular one Object1 in their parent-tree (as in their parent or parent of their parents, etc). Should I use mptt or is there a simpler approach?

    Read the article

  • Is there a way to simplify this Django query?

    - by Mark
    accepted_bids = Bid.objects.filter(shipment__user=u, status='acc').select_related('shipment') completed_shipments = [] for b in accepted_bids: completed_shipments.append(b.shipment) vehicles_shipped = [] for s in completed_shipments: vehicles_shipped.extend(s.items.all()) In the end, I want a list of shipped vehicles. A vehicle is shipped if it's part of a shipment that's completed. A shipment is completed if it has an accepted bid. I'd prefer not to iterate over the querysets thereby forcing a hit to the DB before its necessary... isn't there a way to get all the associated shipments from a list of bids, for example?

    Read the article

  • How do I create an empty Django formset using modelformset_factory?

    - by nbolton
    I'm creating a formset, but it seems to populate it with all of the existing data in the table for that object. I can't figure out how to start with a blank formset; the only way seems to be to delete all of the data from the table, but clearly this isn't an option. I will post code if necessary (but there's lots of it, so knowing what is relevant is tricky).

    Read the article

  • How to show raw_id value of a ManyToMany relation in the Django admin?

    - by luc
    Hello, I have an app using raw_id on both ForeignKeyField and ManyToManyField. The admin displays the value of the foreign key on the right of the edit box. Unfortunatey, it doesn't work with ManyToMany. I've checked the code and I think that it is the normal behavior. However I would like to know if someone has an easy tip to change this behavior? Thanks in advance Update: I've tried to subclass the ManyToManyRawIdWidget but I don't know how to say that the raw_id_fields should use my custom widget. formfield_overrides doesn't seem to work with raw_id fields

    Read the article

  • Django: How can I add weight/ordering to a many to many relationship?

    - by Klaas van Schelven
    I'm having Pages with TextBlocks on them. Text Blocks may appear on different pages, pages may have several text blocks on them. Every page may have these blocks in an ordering of it's own. This can be solved by using a separate through parameter. Like so: class TextBlock(models.Model): title = models.CharField(max_length=255) text = models.TextField() class Page(models.Model): textblocks = models.ManyToManyField(TextBlock, through=OrderedTextBlock) class OrderedTextBlock(models.Model): text_block = models.ForeignKey(TextBlock) product_page = models.ForeignKey(ProductPage) weight = models.IntegerField() class Meta: ordering = ('weight',) But I'm not very enthousiastic about the violations of DRY for my app. (There's a lot of ordered ManyToMany relations). Is there a recommended way to go about this?

    Read the article

  • How can I have multiple navigation paths with Django, like a simplifies wizard path and a full path?

    - by Zeta
    Lets say I have an application with a structure such as: System set date set name set something Other set death ray target calibrate and I want to have "back" and "next" buttons on a page. The catch is, if you're going in via the "wizard", I want the nav path to be something like "set name" - "set death ray target" - "set name". If you go via the Advanced options menu, I want to just iterate options... "set date" - "set name" - "set something" - "set death ray target" - calibrate. So far, I'm thinking I have to use different URIs, but that's that. Any ideia how this could be done? Thanks.

    Read the article

  • Is there a way to get direct_to_template to pass RequestContext in django?

    - by BigJason
    I have found myself writing the same view over and over. It is basically this: def home_index(request): return render_to_response('home/index.html', RequestContext(request)) To keep with the dry principal, I would like to utilize a generic view. I have seen direct_to_template, but it passes an empty context. So how can I use a generic view and still get the power of RequestContext?

    Read the article

  • In django, how can I include some default records in my models.py?

    - by kdt
    If I have a models.py like class WidgetType(models.Model): name = models.CharField(max_length=200) class Widget(models.Model): typeid = models.ForeignKey(WidgetType) data = models.CharField(max_length=200) How can I build in a set of built in constant values for WidgetType when I know I'm only going to have a certain few types of widget? Clearly I could fire up my admin interface and add them by hand, but I'd like to simplify configuration by having it built into the python.

    Read the article

  • How do I require a login for a user in Django?

    - by Di Zou
    In my urls.py I have this: (r'^myapp/$', 'myapp.views.views.index'), (r'^myapp/login/$', 'myapp.views.views.login_user'), In my settings.py I have this: LOGIN_URL = '/myapp/login' In my views.py I have this: @login_required((login_url='/myapp/login/') def index(request): return render_to_response('index.html') def login_user(request): #login stuff return render(request, 'registration/login.html', {'state':state, 'username': username}) I can go to mysite.com/myapp/login and the login page works. However, when I go to mysite.com/myapp/index I do not get redirected to the login page even though I am logged out. Why is that and how do I fix it?

    Read the article

  • How do I filter values in a Django form using ModelForm?

    - by malandro95
    I am trying to use the ModelForm to add my data. It is working well, except that the ForeignKey dropdown list is showing all values and I only want it to display the values that a pertinent for the logged in user. Here is my model for ExcludedDate, the record I want to add: class ExcludedDate(models.Model): date = models.DateTimeField() reason = models.CharField(max_length=50) user = models.ForeignKey(User) category = models.ForeignKey(Category) recurring = models.ForeignKey(RecurringExclusion) def __unicode__(self): return self.reason Here is the model for the category, which is the table containing the relationship that I'd like to limit by user: class Category(models.Model): name = models.CharField(max_length=50) user = models.ForeignKey(User, unique=False) def __unicode__(self): return self.name And finally, the form code: class ExcludedDateForm(ModelForm): class Meta: model = models.ExcludedDate exclude = ('user', 'recurring',) How do I get the form to display only the subset of categories where category.user equals the logged in user?

    Read the article

  • Django: Is it possible to attach media files (css, javascript etc) to a View-class?

    - by mrmclovin
    I can't fins any information on how to define css or javascript files in a view like: class MyView(View): .... class Media: css = { 'all' : 'mystyle.css' } If you have a form you can do like: class MyForm(ModelForm): .... class Media: css = { 'all' : 'mystyle.css' } And then in the template you can print the files like; {{ form.media.css }} I like that Syntax very much and I like to keep the View-specific css files in the app-directory. Does anyone know if it's possible? Thanks!

    Read the article

  • What open source ecommerce webshops offer #1: usability, #2: PayPal integration, and #3: ease of administration and use

    - by Jonathan Hayward
    I've spent several days trying to deploy Satchmo, in the process asking several questions about deployment (http://stackoverflow.com/questions/11277407/can-anyone-explain-this-error-message-deploying-a-satchmo-project-under-gunicorn, http://stackoverflow.com/questions/11277685/is-there-a-howto-to-fcgi-for-deploying-satchmo, and http://stackoverflow.com/questions/11278295/what-is-the-most-stable-release-of-satchmo). Django's tagline is "The web framework for perfectionists with deadlines," and Satchmo's tagline is equally forceful: "The webshop for perfectionists with deadlines." I'm looking more to set up, configure, design, etc., rather than code for this one, and I'm taking a bit of a hint that for me at least the "with deadlines" bit is something that I cannot manage. Deployment has been a time sink. So, taking a step back, I don't specifically need to edit and extend the source code; what I want are first, good usability and a clean experience for the end-user, then being easy to deploy/install/manage/maintain, and enough so that even if you're having a slow day it should at most be one day's work to install, one day's work to get running, and one day's work to rebrand as white label (for simple branding). What ecommerce webshops should I be looking at?

    Read the article

  • Playframework and Django

    - by n002213f
    I have worked with Django before and have recently seen the Play framework. Is this the Java community's answer to Django? Any experiences with it? Any performance comparisons with other Java web frameworks? Edit:Almost similar to http://stackoverflow.com/questions/1597086/any-experience-with-play-java-web-development-framework, the responses, unfortunately don't say much about the framework.

    Read the article

  • Convert and convert back datetime in Django

    - by Anshuma
    I am parsing feeds using feedparser and I am trying to store updated or updated_parsed attributes of feeds in Django db. But it shows an error as [u'Enter a valid date/time in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format.'] Please tell me how to convert updated and updated_parsed such that it can be stored in the Django db such that I can (convert and reuse) or just reuse the date stored in db while parsing in this way: feedparser.parse("url", modified = lastupdate)

    Read the article

  • Node.js as a custom (streaming) upload handler for Django

    - by Gijs
    I want to build an upload-centric app using Django. One way to do this is with nginx's upload module (nonblocking) but it has its problems. Node.js is supposed to be a good candidate for this type of application. But how can I make node.js act as an upload_handler() for Django (http://docs.djangoproject.com/en/1.1/topics/http/file-uploads/#modifying-upload-handlers-on-the-fly) I'm not sure where to look for examples?

    Read the article

< Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >