Search Results

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

Page 33/165 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • Problems using User model in django unit tests

    - by theycallmemorty
    I have the following django test case that is giving me errors: class MyTesting(unittest.TestCase): def setUp(self): self.u1 = User.objects.create(username='user1') self.up1 = UserProfile.objects.create(user=self.u1) def testA(self): ... def testB(self): ... When I run my tests, testA will pass sucessfully but before testB starts, I get the following error: IntegrityError: column username is not unique It's clear that it is trying to create self.u1 before each test case and finding that it already exists in the Database. How do I get it to properly clean up after each test case so that subsequent cases run correctly?

    Read the article

  • Django remove list_editable on a per row basis.

    - by Jason Leveille
    On the back of Django 1.2RC1, I have built a great administrator for my client! It's awesome. The client has one request that, if not satisfied, could bring this house of cards crashing down. I have a list of swim meet results. A meet result is added by a superuser. A team rep can edit a meet result (which they must be able to do inline, with list_editable), but after they edit the meet result inline and save, they should no longer be able to edit that result inline. They can only perform one edit. So, my question ... can I turn off list_editable on a per row basis?

    Read the article

  • Django - Passing arguments to models through ForeignKey attributes

    - by marshall
    I've got a class like this: class Image (models.Model): ... sizes = ((90,90), (300,250)) def resize_image(self): for size in sizes: ... and another class like this: class SomeClassWithAnImage (models.Model): ... an_image = models.ForeignKey(Image) what i'd like to do with that class is this: class SomeClassWithAnImage (models.Model): ... an_image = models.ForeignKey(Image, sizes=((90,90), (150, 120))) where i'm can specify the sizes that i want the Image class to use to resize itself as a argument rather than being hard coded on the class. I realise I could pass these in when calling resize_image if that was called directly but the idea is that the resize_image method is called automatically when the object is persisted to the db. if I try to pass arguments through the foreign key declaration like this i get an error straight away. is there an easy / better way to do this before I begin hacking down into django?

    Read the article

  • Access to field in extended flatpage in django

    - by Stanislav Feldman
    How to access field in extended flatpage in django? I wrote this: class ExtendedFlatPage(FlatPage): teaser = CharField(max_length=150) class ExtendedFlatPageForm(FlatpageForm): teaser = CharField(max_length=150) class Meta: model = ExtendedFlatPage class ExtendedFlatPageAdmin(FlatPageAdmin): form = ExtendedFlatPageForm fieldsets = ( (None, {'fields': ('url', 'title', 'teaser', 'content', 'sites',)}), ) admin.site.unregister(FlatPage) admin.site.register(ExtendedFlatPage, ExtendedFlatPageAdmin) And creation in admin is ok. But then in flatpages/default.html I tried this: <html> <body> <h1>{{ flatpage.title }}</h1> <strong>{{ flatpage.teaser }}</strong> <p>{{ flatpage.content }}</p> </body> </html> And there was no flatpage.teaser! What is wrong?

    Read the article

  • Passing domain name to PayPal

    - by ilhan
    I'm trying to sell something to domain owners. I need to know their domain names. Before the payment procedure I'll ask their domain names in my web site, I'll store the data in the cookies or the url, then I want to pass the data (domain name) to the PayPal so that I'll know who paid for what domain name. I know PHP and HTML in advanced level but I don't know how to pass the data to PayPal. How I'll do that? Thanks in advance!

    Read the article

  • (Django) Trim whitespaces from charField

    - by zardon
    How do I strip whitespaces (trim) from the end of a charField in Django? Here is my Model, as you can see I've tried putting in clean methods but these never get run. I've also tried doing name.strip(), models.charField().strip() but these do not work either. Is there a way to force the charField to trim automatically for me? Thanks. class Employee(models.Model): """(Workers, Staff, etc)""" name = models.CharField(blank=True, null=True, max_length=100) # This never gets run def clean_variable(self): data = self.cleaned_data['variable'].strip() return data def __unicode__(self): return self.name class Meta: verbose_name_plural = 'Employees' # This never gets run either class EmployeesForm(forms.ModelForm): class Meta: model = Employee def clean_description(self): #if not self.cleaned_data['description'].strip(): # raise forms.ValidationError('Your error message here') self.cleaned_data['name'].strip()

    Read the article

  • in django am facing url problem.....

    - by dpaksp
    am using django.0.97 version i have model called profile in that i have few fields eg like name ,email...ects and it's backend also ready..i.e database . and all users profile is created...i have given all permission to all users. when i login ,click on profile..i able to see list of all user name thr when i click on it ,it's goin to model page where i can edit the user profile..instead of that i want to navigate to a template when i can display the user details ,i have set the URl for it so that when url of that type request comes it should call a view from view it will call my template to display user details,.....the problem is it's not calling my view.... i think my problem is brief....if any information still required ?? pls ask me....and help me

    Read the article

  • Override Django inlineformset_factory has_changed() to always return True

    - by John
    Hi, I am using the django inlineformset_factory function. a = get_object_or_404(ModelA, pk=id) FormSet = inlineformset_factory(ModelA, ModelB) if request.method == 'POST': metaform = FormSet (instance=a, data=request.POST) if metaform.is_valid(): f = metaform.save(commit=False) for instance in f: instance.updated_by = request.user instance.save() else: metaform = FormSet(instance=a) return render_to_response('nodes/form.html', {'form':metaform}) What is happening is that if I change any of the data then everything works ok and all the data gets updated. However if I don't change any of the data then the data is not updated. i.e. only entries which are changed go through the for loop to be saved. I guess this makes sense as there is no point saving data if it has not changed. However I need to go through and save every object in the form regardless of whether it has any changes on not. So my question is how do I override this so that it goes through and saves every record whether it has any changes or not? Hope this makes sense Thanks

    Read the article

  • How do i integrate paypal in my website? Java

    - by Nitesh Panchal
    Hello, I want to integrate paypal in my java web application. I saw that they offer many methods to accomplish this. But i want my visitors to remain on my site only. My friend told me that Paypal offers webservice. But i can't seem to find any documentation on Paypal site. If anybody could help me with this, i would be really very grateful. Please offer me the relevant links on Paypal where i could read and get my things done. Secondly, my friend also told me that we need to give location to paypal where my visitors would be redirected once paypal payment is complete. But i am confused. I am working on localhost. How would Paypal know about my localhost? I have already created my sandbox testing account. What should be my next step. Please explain me in detail. I don't know anything about Paypal. Once i created a demo application of Express checkout where they give a simple button of Pay Now and on clicking on it shopping cart etc appears. But now i want my visitors to stay on same website. Thanks in advance :)

    Read the article

  • Django: query spanning multiple many-to-many relationships

    - by Brant
    I've got some models set up like this: class AppGroup(models.Model): users = models.ManyToManyField(User) class Notification(models.Model): groups_to_notify = models.ManyToManyField(AppGroup) The User objects come from django's authentication system. Now, I am trying to get all the notifications pertaining to the groups that the current user is a part of. I have tried.. notifications = Notification.objects.filter(groups_to_notify=AppGroup.objects.filter(users=request.user)) But that gives an error: more than one row returned by a subquery used as an expression Which I suppose is because the groups_to_notify is checking against several groups. How can I grab all the notifications meant for the user based on the groups he is a part of?

    Read the article

  • Django: where do I call settings.configure?

    - by RexE
    The Django docs say that I can call settings.configure instead of having a DJANGO_SETTINGS_MODULE. I would like my website's project to do this. In what file should I put the call to settings.configure so that my settings will get configured at the right time? Edit in response to Daniel Roseman's comment: The reason I want to do this is that settings.configure lets you pass in the settings variables as a kwargs dict, e.g. {'INSTALLED_APPS': ..., 'TEMPLATE_DIRS': ..., ...}. This would allow my app's users to specify their settings in a dict, then pass that dict to a function in my app that augments it with certain settings necessary to make my app work, e.g. adding entries to INSTALLED_APPS. What I envision looks like this. Let's call my app "rexe_app". In wsgi.py, my app's users would do: import rexe_app my_settings = {'INSTALLED_APPS': ('a','b'), ...} updated_settings = rexe_app.augment_settings(my_settings) # now updated_settings is {'INSTALLED_APPS': ('a','b','c'), 'SESSION_SAVE_EVERY_REQUEST': True, ...} settings.configure(**updated_settings)

    Read the article

  • Setting a preferred item of a many-to-one in Django

    - by Mike DeSimone
    I'm trying to create a Django model that handles the following: An Item can have several Names. One of the Names for an Item is its primary Name, i.e. the Name displayed given an Item. (The model names were changed to protect the innocent.) The models.py I've got looks like: class Item(models.Model): primaryName = models.OneToOneField("Name", verbose_name="Primary Name", related_name="_unused") def __unicode__(self): return self.primaryName.name class Name(models.Model): item = models.ForeignKey(Item) name = models.CharField(max_length=32, unique=True) def __unicode__(self): return self.name class Meta: ordering = [ 'name' ] The admin.py looks like: class NameInline(admin.TabularInline): model = Name class ItemAdmin(admin.ModelAdmin): inlines = [ NameInline ] admin.site.register(Item, ItemAdmin) It looks like the database schema is working fine, but I'm having trouble with the admin, so I'm not sure of anything at this point. My main questions are: How do I explain to the admin that primaryName needs to be one of the Names of the item being edited? Is there a way to automatically set primaryName to the first Name found, if primaryName is not set, since I'm using inline admin for the names?

    Read the article

  • Django test client gets 301 redirection when accessing url

    - by Michal Klich
    I am writing unittests for django views. I have observed that one of my views returns redirection code 301, which is not expected. Here is my views.py mentioned earlier. def index(request): return render(request, 'index.html', {'form': QueryForm()}) def query(request): if request.is_ajax(): form = QueryForm(request.POST) return HttpResponse('valid') Below is urls.py. urlpatterns = patterns('', url(r'^$', 'core.views.index'), url(r'^query/$', 'core.views.query') ) And unittest that will fail. def so_test(self): response = self.client.post('/') self.assertEquals(response.status_code, 200) response = self.client.post('/query', {}) self.assertEquals(response.status_code, 200) My question is: why there is status 301 returned?

    Read the article

  • ModelName(django.contrib.auth.models.User) vs ModelName(models.Model)

    - by amr.negm
    I am developing a django project. I created some apps, some of those are related to User model, for instance, I have a feeds app that handles user feeds, and another app that deals with extra user data like age, contacts, and friends. for each of these, I created a table that should be connected to the User model, which I using for storing and authenticating users. I found two ways to deal with this issue. One, is through extending User model to be like this: ModelName(User): friends = models.ManyToMany('self') ..... Two, is through adding a foreign key to the new table like this: ModelName(models.Model): user = models.ForeignKey(User, unique=True) friends = friends = models.ManyToMany('self') ...... I can't decide which to use in which case. in other words, what are the core differences between both?

    Read the article

  • Django admin proper urls inside listview

    - by hinnye
    Hi, My current target is to give users the chance to download CSV files from the admin site of my application. I successfully managed to create an additional column in the model's list view this way: def doc_link(self): return '<a href="files/%s">%s</a>' % (self.output, self.output) doc_link.allow_tags = True This shows the file name and creates the link, but sadly - because it's inside my 'searches' view - it has an URL: my_site/my_app/searches/files/13.csv. This is my problem, I would like to have my files stored in the admin media directory, like this: http://my_site/media/files/13.csv Does somebody know how to give url which points "outer" from the model's directory? Maybe somehow tell Django to use the ADMIN_MEDIA_PREFIX in the link? I'd really appreciate any help, thanks!

    Read the article

  • Saving data in a inherited django model

    - by aldeano
    I'm building an app to save data and some calculations made with those datas, the idea is keep the data in one model and the calculations in other. So, the models are like this: class FreshData(models.Model): name = models.CharField(max_length=20) one = models.IntegerField() two = models.IntegerField() def save(self, *args, **kwargs): Calculations() Calculations.three = self.one + self.two super(FreshData, self).save(*args, **kwargs) Calculations.save() class Calculations(FreshData): three = models.IntegerField() I've got a valueerror pointing out "self.one" and "self.two" as without value. I keep the idea in witch my design is wrong and django has a simpler way to store related data.

    Read the article

  • Django: Site-Wide URL Prefix

    - by Tom
    I've built a Django site that will live at the root when it's live. Right now it's functioning perfectly at the IP address. For testing purposes, the client has pointed a proxy url at it, but the url has /folder/path in it, so none of the URL patterns match. I put (/folder/path)? into all the url patterns so they now respond, but all of the links are broken because I'm using the {% url %} tag and while the url patterns will match the optional path, they don't include it in that tag. Clearly I can just hard-code /folder/path into all of my urls (well, into all of the url includes) until testing is complete, but is there a better way to do this?

    Read the article

  • Django model class and custom property

    - by dArignac
    Howdy - today a weird problem occured to me: I have a modle class in Django and added a custom property to it that shall not be saved into the database and therefore is not represent in the models structure: class Category(models.Model): groups = models.ManyToManyField(Group) title = defaultdict() Now, when I'm within the shell or writing a test and I do the following: c1 = Category.objects.create() c1.title['de'] = 'german title' print c1.title['de'] # prints "german title" c2 = Category.objects.create() print c2.title['de'] # prints "german title" <-- WTF? It seems that 'title' is kind of global. If I change title to a simple string it works as expected, so it has to do something with the dict? I also tried setting title as a property: title = property(_title) But that did not work, too. So, how can I solve this? Thank you in advance! enter code here

    Read the article

  • Django 1.2: Dates in admin forms don't work with Locales (I10N=True)

    - by equalium
    I have an application in Django 1.2. Language is selectable (I18N and Locale = True) When I select the english lang. in the site, the admin works OK. But when I change to any other language this is what happens with date inputs (spanish example): Correctly, the input accepts the spanish format %d/%m/%Y (Even selecting from the calendar, the date inserts as expected). But when I save the form and load it again, the date shows in the english form: %Y-%m-%d The real problem is that when I load the form to change any other text field and try to save it I get an error telling me to enter a valid date, so I have to write all dates again or change the language in the site to use the admin. I haven't specified anything for DATE_INPUT_FORMATS in settings nor have I overridden forms or models. Surely I am missing something but I can't find it. Can anybody give me a hint?

    Read the article

  • get foreign key objects in a single query - Django

    - by John
    Hi I have 2 models in my django code: class ModelA(models.Model): name = models.CharField(max_length=255) description = models.CharField(max_length=255) created_by = models.ForeignKey(User) class ModelB(models.Model): category = models.CharField(max_length=255) modela_link = models.ForeignKey(ModelA, 'modelb_link') functions = models.CharField(max_length=255) created_by = models.ForeignKey(User) Say ModelA has 100 records, all of which may or may not have links to ModelB Now say I want to get a list of every ModelA record along with the data from ModelB I would do: list_a = ModelA.objects.all() Then to get the data for ModelB I would have to do for i in list_a: i.additional_data = i.modelb_link.all() However this runs a query on every instance of i. Thus making 101 queries to run. Is there any way of running this all in just 1 query. Or at least less than the 101 queries. I've tried putting in ModelA.objects.select_related().all() but this didn't seem to have any effect. Thanks

    Read the article

  • Django Template - Convert python list into a javascript object

    - by amcashcow
    I am working on a django / python website I have a page where I want to display a table of search results The list of results is passed in to the template as normal I also want to make this list of objects accessible to the javascript code My first solution was just create another view that returned json format. But each page load required calling the query twice. So then I tried only downloading the data using the json view and printing the table using javascript. but this is also not desirable as now the presentation layer is mixed into the javascript code. is there a way to create a javascript object from the python list as the page is rendered?

    Read the article

  • Paypal payments verify

    - by user2800899
    (sorry for my english). I have implemented Paypal sdk for android, it works fine! But maybe for my english I don´t understand what i have to do here: @Override protected void onActivityResult (int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION); if (confirm != null) { try { Log.i("paymentExample", confirm.toJSONObject().toString(4)); // TODO: send 'confirm' to your server for verification. // see https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ // for more details. } catch (JSONException e) { Toast.makeText(this, "Ha ocurrido un error, inténtelo de nuevo en unos instantes", Toast.LENGTH_LONG).show(); IrActivityAnterior(); } } } I have read about it but I don´t know if I need to send a proof of payment to the person who has bought my app or if I only need to get this proof and save it. And the other question is how can I verify it? What steps I need to follow?? Thank you!!

    Read the article

  • Django: Converting an entire Model into a single dictionary

    - by LarrikJ
    Is there a good way in Django to convert an entire model to a dictionary? I mean, like this: class DictModel(models.Model): key = models.CharField(20) value = models.CharField(200) DictModel.objects.all().to_dict() ... with the result being a dictionary with the key/value pairs made up of records in the Model? Has anyone else seen this as being useful for them? Thanks. Update I just wanted to add is that my ultimate goal is to be able to do a simple variable lookup inside a Template. Something like: {{ DictModel.exampleKey }} With a result of DictModel.objects.get(key__exact=exampleKey).value Overall, though, you guys have really surprised me with how helpful allof your responses are, and how different the ways to approach it can be. Thanks a lot.

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >