Search Results

Search found 8279 results on 332 pages for 'django permissions'.

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

  • Django: Sum on an date attribute grouped by month/year

    - by Sébastien Piquemal
    Hello, I'd like to put this query from SQL to Django: "select date_format(date, '%Y-%m') as month, sum(quantity) as hours from hourentries group by date_format(date, '%Y-%m') order by date;" The part that causes problem is to group by month when aggregating. I tried this (which seemed logical), but it didn't work : HourEntries.objects.order_by("date").values("date__month").aggregate(Sum("quantity"))

    Read the article

  • Image upload and Manipulation in Django

    - by Saransh Mohapatra
    I am trying upload images and than create an thumbnail of it and than store both in S3. After the file has been uploaded i am first uploading it to S3 and than trying to create thumbnail but it doesn't work as than PIL is not able to recognise the image. And secondly if I create the thumbnail first than while uploading original image I get EOF. I think Django allows just once for the uploaded files to be used only once....Please kindly tell me a way to do so....Thanks in advance

    Read the article

  • Django Include Aggregate Sums of Zero

    - by tomas
    I'm working on a Django timesheet application and am having trouble figuring out how to include aggregate sums that equal zero. If I do something like: entries = TimeEntry.objects.all().values("user__username").annotate(Sum("hours")) I get all users that have time entries and their sums. [{'username': u'bob' 'hours__sum':49}, {'username': u'jane' 'hours__sum':10}] When I filter that by a given day: filtered_entries = entries.filter(date="2010-05-17") Anyone who didn't enter time for that day is excluded. Is there a way to include those users who's sums are 0? Thanks

    Read the article

  • Muliple Models in a single django ModelForm?

    - by BigJason
    Is it possible to have multiple models included in a single ModelForm in django? I am trying to create a profile edit form. So I need to include some fields from the User model and the UserProfile model. Currently I am using 2 forms like this class UserEditForm(ModelForm): class Meta: model = User fields = ("first_name", "last_name") class UserProfileForm(ModelForm): class Meta: model = UserProfile fields = ("middle_name", "home_phone", "work_phone", "cell_phone") Is there a way to consolidate these into one form or do I just need to create a form and handle the db loading and saving myself?

    Read the article

  • Django - 2 fields unique together

    - by webvulture
    Suppose, I want to record say poll choices by users everyday. In this case, i have a table named vote which has columns poll , choice and user-id . So how can i out the constraint (maybe in the django models or wherever possible) that poll and user-id both should not be the same for any entry but like the same user can vote for various different polls once and obviously various users can vote for the same poll. I hope I am clear.

    Read the article

  • Django form and User data

    - by Dean
    I have a model that looks like this: class Client(models.Model): name = models.CharField(max_length=100, primary_key=True) user = models.ForeignKey(User) class Contract(models.Model): title = models.CharField(max_length=100, primary_key=True) start_date = models.DateField() end_date = models.DateField() description = models.TextField() client = models.ForeignKey(Client) user = models.ForeignKey(User) How can i configure a django form so that only clients associated with that user show in the field in the form? My initial thought was this in my forms.py: client = forms.ModelChoiceField(queryset=Client.objects.filter(user__username = User.username)) But it didn't work. So how else would I go about it?

    Read the article

  • Saving a Django form to a csv file

    - by Oli
    I have a Django form that is working fine. I'd like to save the data it submits to a CSV file. Is there a "best practice" way to do this? I need to include blank fields in the CSV file where the user has not filled in a "required=False" field

    Read the article

  • Django admin, filter objects by ManyToMany reference

    - by Nick Z
    Hello! There's photologue application, simple photo gallery for django, implementing Photo and Gallery objects. Gallery object has ManyToMany field, which references Photo objects. I need to be able to get list of all Photos for a given Gallery. Is it possible to add Gallery filter to Photo's admin page? If it's possible, how to do it best?

    Read the article

  • Django: select_related and GenericRelation

    - by Parand
    Does select_related work for GenericRelation relations, or is there a reasonable alternative? At the moment Django's doing individual sql calls for each item in my queryset, and I'd like to avoid that using something like select_related. class Claim(models.Model): proof = generic.GenericRelation(Proof) class Proof(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') I'm selecting a bunch of Claims, and I'd like the related Proofs to be pulled in instead of queried individually.

    Read the article

  • Django admin - remove field if editing an object

    - by John McCollum
    I have a model which is accessible through the Django admin area, something like the following: # model class Foo(models.Model): field_a = models.CharField(max_length=100) field_b = models.CharField(max_length=100) # admin.py class FooAdmin(admin.ModelAdmin): pass Let's say that I want to show field_a and field_b if the user is adding an object, but only field_a if the user is editing an object. Is there a simple way to do this, perhaps using the fields attribute? If if comes to it, I could hack a JavaScript solution, but it doesn't feel right to do that at all!

    Read the article

  • Strange (atleast for me) behavior in Django template

    - by lud0h
    The following code snippet in a Django template (v 1.1) doesn't work. {{ item.vendors.all.0 }} == returns "Test" but the following code snippet, doesn't hide the paragraph! {% ifnotequal item.vendors.all.0 "Test" %} <p class="view_vendor">Vendor(s): {{item.vendors.all.0}} </p><br /> {% endifnotequal %} Any tips on what's wrong? Thanks.

    Read the article

  • Is content from AJAX call added to Django context variable

    - by John
    Hi, I am using the JQuery load function to load part of my page. Can I access the variables from that page in the page that loads it. e.g. Page A uses JQuery load function to load B Page B loads and sets a variable in context called pageB_var which holds a django object Page A can then access this variable by doing {{pageB_var}} since it was added to the context If not what is the best way of doing this? Thanks

    Read the article

  • SQL commands generated in Django by running sqlall

    - by k-g-f
    In my Django app, I just ran $ python manage.py sqlall and I see a lot of SQL statements that look like this, when describing FK relationships: ALTER TABLE `app1_model1` ADD CONSTRAINT model2_id_refs_id_728de91f FOREIGN KEY (`model2_id`) REFERENCES `app1_model2` (`id`); Where does "7218de91f" come from? I would like to know because I'd like to manually write SQL statements to accompany models changes in the app so that my db's can be kept up to date.

    Read the article

  • Can Django be used for non web apps?

    - by Leeks and Leaks
    I noticed in the main Django introductin they show a feature that maps python objects to the database. This doesn't strike me as being mutually exclusive with with development, is there any reason why this can't be used for non web apps? Is it easy to separate out?

    Read the article

  • reset file permissions?

    - by acidzombie24
    In my /var/www folder i have permission 2750 with the owner being root (unless i change it by hand) and the group being www-data. I mv a folder into /var/www and i'd like to reset the permissions so everything is 2750 and for the group to be www-data, is it possible to do it in one command? or do i need to do multiple cmds? (its two commands, 3 if i want the same owner but it be nice to do it with one for this folder)

    Read the article

  • Linux Unable to Write to Directory Despite Permissions

    - by Nick Q.
    I'm trying to give myself permissions to /var/www/ however for some reason I am unable to do so. Currently what I'm facing is this: nick@server1:/var$ ls -l drwxrwxr-x 5 root wwwusers 232 Mar 15 19:31 www nick@server1:/var$ groups nick wwwusers nick@server1:/var$ mkdir www/trying mkdir: cannot create directory `www/trying': Permission denied I am running Ubuntu 10.04 LTS on a VPS and am used to running unix on my own machine so I may be doing something absolutely stupid, but I would like to be able to have the group wwwusers be able to write to www.

    Read the article

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