Search Results

Search found 3554 results on 143 pages for 'django modelformsets'.

Page 68/143 | < Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >

  • django authentication .htaccess static

    - by Uszy Wieloryba
    In my app users can upload files for other users. To make the uploaded files accesible only for the addresse I need some kind of static files authentication system. My idea, is to create the apache hosted directory for each user and to limit access to this derectory using .htaccess. This means that each time new django user is created, I need to create a directory and the appropriate .htaccess file in it. I know I should do it using post_save signals on User model but I don't know how to create the .htaccess in the user's directory from python level. Can you help me with that? Or perhaps you have better solution to my problem?

    Read the article

  • Unit testing with django-celery?

    - by Jason Webb
    I am trying to come up with a testing methodology for our django-celery project. I have read the notes in the documentation, but it didn't give me a good idea of what to actually do. I am not worried about testing the tasks in the actual daemons, just the functionality of my code. Mainly I am wondering: How can we bypass task.delay() during the test (I tried setting CELERY_ALWAYS_EAGER = True but it made no difference)? How do we use the test settings that are recommended (if that is the best way) without actually changing our settings.py? Can we still use manage.py test or do we have to use a custom runner? Overall any hints or tips for testing with celery would be very helpful.

    Read the article

  • Extending Django-tagging, adding extra field to each tag?

    - by victorhooi
    heya, We're coding together a Django app to handle reviews of newspaper articles. Each newspaper article model will an arbitrary number of tags associated with it. Also, each tag will have an optional ranking (0 to 10). I was thinking of using django-tagging to do this (http://code.google.com/p/django-tagging/), but I'm not sure of the best way to add the ranking to the system. Should I extend django-tagging somehow? (Not sure if this is possible, without changing django-tagging's actual code?). Or is there a better way of achieving this? Cheers, Victor

    Read the article

  • Display user name in reference to user id in django template

    - by Ed
    I expect this is an easy question. For some reason, I don't have a solution yet. I have an object set from django reversion: version_list. Each object in the set has a user id attached to it. How do I grab the user names that correspond to the user ID's? To try to be clearer, if each object in version_list has a name, date, and user id, how can I join the version_list set with the user table to figure out what user id goes with which name? This is done in the view, or the template?

    Read the article

  • CeleryCAM not working... - Django/Celery

    - by RadiantHex
    Hi folks, celery works wonderfully! :) e.g. results are returned with no problems! Unfortunately celerycam does not: This is what my panel looks like, celeryev looks the same. NB: all those tasks have been completed succesfully, they are just not showing as completed, and the names are not showing either. I'm usingthe following commands: python manage.py celeryd -l info -E python manage.py celerycam My BROKER is RabbitMQ My DATABASE is MongoDB Django, Celery and RabbitMQ are running on a clean Ubuntu 10 install. Any ideas folks? Would be amazing if someone could help me on this one :|

    Read the article

  • Convert data retrieved from MySQL database into JSON object using Python/Django

    - by rohanbk
    I have a MySQL database called People which contains the following schema <id,name,foodchoice1,foodchoice2>. The database contains a list of people and the two choices of food they wish to have at a party (for example). I want to create some kind of Python web-service that will output a JSON object. An example of output should be like: { "guestlist": [ {"id":1,"name":"Bob","choice1":"chicken","choice2":"pasta"},{"id":2,"name":"Alice","choice1":"pasta","choice2":"chicken"} ], "partyname": "My awesome party", "day": "1", "month": "June", "2010": "null" } Basically every guest is stored into a dictionary 'guestlist' along with their choices of food. At the end of the JSON object is just some additional information that only needs to be mentioned once. The question that I have is regarding the method that I need to utilize to grab the data from my database, and create the JSON object. Do I need to use a standard Model/View structure of Django or can I get away with something that is much simpler since what I need to do is really simple?

    Read the article

  • Django | Save model's choice list values

    - by MMRUser
    I have a form that has a choice list: <select name="cellSerpro" id="idcellserpro" class="field text" > <option value="">---</option> <option value="option1">Verizon</option> <option value="option2">AT&T</option> <option value="option3">T-Mobile</option> <option value="option4">Sprint</option> </select> So how do I get the selected value of it from the Django's model class in order to save it in the database, I have search through the net but couldn't find any way of doing it.. Thanks..

    Read the article

  • Django: query with ManyToManyField count?

    - by AP257
    In Django, how do I construct a COUNT query for a ManyToManyField? My models are as follows, and I want to get all the people whose name starts with A and who are the lord or overlord of at least one Place, and order the results by name. class Manor(models.Model): lord = models.ManyToManyField(Person, null=True, related_name="lord") overlord = models.ManyToManyField(Person, null=True, related_name="overlord") class Person(models.Model): name = models.CharField(max_length=100) So my query should look something like this... but how do I construct the third line? people = Person.objects.filter( Q(name__istartswith='a'), Q(lord.count > 0) | Q(overlord.count > 0) # pseudocode ).order_by('name'))

    Read the article

  • How to use thread in Django

    - by zomboid
    I want to check users' subscribed dates for certain period. And send mail to users whose subscription is finishing (ex. reminds two days). I think the best way is using thread and timer to check dates. But I have no idea how to call this function. I don't want to make a separate program or shell. I want to combine this procedure to my django code. I tried to call this function in my settings.py file. But it seems it is not a good idea. It calls the fucntion and creates thread everytime i imported settings.

    Read the article

  • group inlines in django admin

    - by pablo
    Hi I have a two models, Model1 and Model2. Model2 has a FK to Model1 and FK to iteself. In the admin I show Model2 as inlines in Model1 change_form. I want to modify the way the inlines are shown in the admin. I need to group all the instances that have the same parent_model2 and display them as a readonly field with a string of 'childs' in the parent Model2 instance. I know how to use itertools.groupby (or the django version) but don't know how to do it in the admin. What should I override to be able to iterate over all the Model2 instances, group them by parent, add children to the parent and remove children from the inlines? class Model1(models.Model): name = models.CharField() class Model2(models.Model): name = models.CharField() fk_model1 = models.ForeignKey('self', blank=True, null=True) parent_model2 = models.ForeignKey('self', blank=True, null=True) Thanks

    Read the article

  • Django Social Registration - Twitter Callback going to example.com

    - by user578888
    I have been working through installing django social registration on my webfaction account. So far I have the facebook login working. When I attempt to log in to to twitter I get the correct login page but after choosing "Allow" I am forwarded to the following URL: http://example.com/social/twitter/callback/.... where "example.com" is the actual URL it is forwarding to. I have setup the twitter app and have entered a valid oauth callback URL. I have searched the code on my developer machine for references to "example.com" but have not found any. Any help nailing this down will be greatly appreciated.

    Read the article

  • serving files using django - is this a security vulnerability

    - by Tom Tom
    I'm using the following code to serve uploaded files from a login secured view in a django app. Do you think that there is a security vulnerability in this code? I'm a bit concerned about that the user could place arbitrary strings in the url after the upload/ and this is directly mapped to the local filesystem. Actually I don't think that it is a vulnerability issue, since the access to the filesystem is restricted to the files in the folder defined with the UPLOAD_LOCATION setting. UPLOAD_LOCATION = is set to a not publicly available folder on the webserver url(r'^upload/(?P<file_url>[/,.,\s,_,\-,\w]+)', 'aeon_infrastructure.views.serve_upload_files', name='project_detail'), @login_required def serve_upload_files(request, file_url): import os.path import mimetypes mimetypes.init() try: file_path = settings.UPLOAD_LOCATION + '/' + file_url fsock = open(file_path,"r") file_name = os.path.basename(file_path) file_size = os.path.getsize(file_path) print "file size is: " + str(file_size) mime_type_guess = mimetypes.guess_type(file_name) if mime_type_guess is not None: response = HttpResponse(fsock, mimetype=mime_type_guess[0]) response['Content-Disposition'] = 'attachment; filename=' + file_name #response.write(file) except IOError: response = HttpResponseNotFound() return response

    Read the article

  • Elegant setup of Python logging in Django

    - by Parand
    I have yet to find a way of setting up Python logging with Django that I'm happy with. My requirements are fairly simple: Different log handlers for different events - that is, I want to be able to log to different files Easy access to loggers in my modules. The module should be able to find its logger with little effort. Should be easily applicable to command-line modules. Parts of the system are stand-alone command line or daemon processes. Logging should be easily usable with these modules. My current setup is to use a logging.conf file and setup logging in each module I log from. It doesn't feel right. Do you have a logging setup that you like? Please detail it: how do you setup the configuration (do you use logging.conf or set it up in code), where/when do you initiate the loggers, and how do you get access to them in your modules, etc.

    Read the article

  • Intersection of two querysets in django

    - by unagimiyagi
    Hello, I can't do an AND on two querysets. As in, q1 & q2. I get the empty set and I do not know why. I have tested this with the simplest cases. I am using django 1.1.1 I have basically objects like this: item1 name="Joe" color = "blue" item2 name="Jim" color = "blue" color = "white" item3 name="John" color = "red" color = "white" Is there something weird about having a many-to-many relationship or what am I missing? queryset1 = Item.objects.filter(color="blue") this gives (item1, item2) queryset2 = Item.objects.filter(color="white") this gives (item2, item3) queryset1 & queryset2 gives me the empty set [] The OR operator works fine (I'm using "|" ) Why is this so?

    Read the article

  • In Django, how to create tables from an SQL file when syncdb is run

    - by Sidney
    Hi, How do I make syncdb execute SQL queries (for table creation) defined by me, rather then generating tables automatically. I'm looking for this solution as some particular models in my app represent SQL-table-views for a legacy-database table. So, I've created their SQL-views in my django-DB like this: CREATE VIEW legacy_series AS SELECT * FROM legacy.series; I have a reverse engineered model that represents the above view/legacytable. But whenever I run syncdb, I have to create all the views first by running sql scripts, otherwise syncdb simply creates tables for them (if a view is not found). How do I make syncdb run the above mentioned SQL?

    Read the article

  • Representing geographical points/polygons in Python/Django

    - by Cornflake
    I'm building a website in Django, and I want one of my datatypes to be a geographical polygon. I want to mark points on a map (say, in Google Maps) and then store the resulting polygon in the database. Is there any way to do it that will save me the work of typing all the longitudes and latitudes manually? I guess I'm looking both for a geographical library for Python, and for a special website that will let me mark points on the map and save them in a standard format. Thanks!

    Read the article

  • django templating system inheritance issue

    - by Suhail
    hi, i am having issues with my django templating system, i have a base.html file, which contains the content which will be common on all the web pages of the web site, the base.html file fetches some dynamic content, like the categories and the archives, which are passed to it by a python file, which fetches the categories and the archives data from a mysql database. the issue when i inherit this base.html file in other html files like index.html: {% extends "base.html" %} and when when i call the main index URL for ex: http://mywebsite.com/index/ the index page gets loaded, but the categories and the archives data that should get loaded from the base.html file does not. what am i doing wrong, please help.

    Read the article

  • Django: accessing session variables from within a template?

    - by AP257
    Hi all If I set a session variable in Django, like: request.session["name"] = "name" Is there a way I can access it from within a template, or do I have to retrieve it from within a view, and then pass it to a template? Asking because I have around 10 little session variables that I'd like to access within a template, and passing all 10 from the view to the template could get a bit messy. (I have to use session variables because it's a HttpResponseRedirect, but storing the variables in a database is overkill for my purposes.) So - any way to grab session variables directly within a template?

    Read the article

  • Prepopulate drop-box according to another drop-box choice in Django Admin

    - by onorua
    I have models like this: class User(models.Model): Switch = models.ForeignKey(Switch, related_name='SwitchUsers') Port = models.ForeignKey(Port) class Switch(models.Model): Name = models.CharField(max_length=50) class Port(models.Model): PortNum = models.PositiveIntegerField() Switch = models.ForeignKey(Switch, related_name = "Ports") When I'm in Admin interface and choose Switch from Switches available, I would like to have Port prepopulated accordingly with Ports from the related Switch. As far as I understand I need to create some JS script to prepopulate it. Unfortunately I don't have this experience, and I would like to keep things simple as it possible and don't rewrite all Django admin interface. Just add this functionality for one Field. Could you please help me with my problem? Thank you.

    Read the article

  • Datastore query outputting for Django form instance

    - by Jelle
    Hello! I'm using google appengine and Django. I'm using de djangoforms module and wanted to specify the form instance with the information that comes from the query below. userquery = db.GqlQuery("SELECT * FROM User WHERE googleaccount = :1", users.get_current_user()) form = forms.AccountForm(data=request.POST or None,instance=?????) I've found a snippet in a sample app that does this trick, but I can't modify it to work with the query I need. gift = User.get(db.Key.from_path(User.kind(), int(gift_id))) if gift is None: return http.HttpResponseNotFound('No gift exists with that key (%r)' % gift_id) form = RegisterForm(data=request.POST or None, instance=gift) Could anyone help me?

    Read the article

  • Django: Determining if a user has voted or not

    - by TheLizardKing
    I have a long list of links that I spit out using the below code, total votes, submitted by, the usual stuff but I am not 100% on how to determine if the currently logged in user has voted on a link or not. I know how to do this from within my view but do I need to alter my below view code or can I make use of the way templates work to determine it? I have read http://stackoverflow.com/questions/1528583/django-vote-up-down-method but I don't quite understand what's going on ( and don't need any ofjavascriptery). Models (snippet): class Link(models.Model): category = models.ForeignKey(Category, blank=False, default=1) user = models.ForeignKey(User) created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) url = models.URLField(max_length=1024, unique=True, verify_exists=True) name = models.CharField(max_length=512) def __unicode__(self): return u'%s (%s)' % (self.name, self.url) class Vote(models.Model): link = models.ForeignKey(Link) user = models.ForeignKey(User) created = models.DateTimeField(auto_now_add=True) def __unicode__(self): return u'%s vote for %s' % (self.user, self.link) Views (snippet): links = Link.objects.select_related().annotate(votes=Count('vote')).order_by('-created')

    Read the article

  • django: ajax view structure

    - by zack
    I want to know the correct way to structure ajax views in django. say i do something like : def foo_json(request): if is.ajax(): # return JSON here and make it available as a resource at something like '/foo/data/'.. all is fine.. but if I point the browser at '/foo/data/' .. obviously I get an error (debug) like: app.views.foo_json didn't return an HttpResponse object. so... my question is: Whats the best way structure this kind of view? ..should I return an HTTP response code ..maybe 404 / 405 ... or something else? - not sure of the best way to handle this, any advice appreciated :)

    Read the article

  • django 'urlize' strings form text just like twitter

    - by dana
    heyy there i want to parse a text,let's name it 'post', and 'urlize' some strings if they contain a particular character, in a particular position. my 'pseudocode' trial would look like that: def urlize(post) for string in post if string icontains ('#') url=(r'^searchn/$', searchn, name='news_searchn'), then apply url to the string return urlize(post) i want the function to return to me the post with the urlized strings, where necessary (just like twitter does). i don't understand: how can i parse a text, and search for certain strings? is there ok to make a function especially for 'urlizing' some strings? The function should return the entire post, no matter if it has such kind of strings. is there another way Django offers? Thank you

    Read the article

  • Limiting the maximum number of concurrent requests django/apache

    - by Johan
    Hi, I have a django site that demonstrates the usage of a tool. One of my views takes a file as input and runs some fairly heavy computation trough an external python script and returns some output to the user. The tool runs fast enough to return the output in the same request though. I would however want to limit how many concurrent requests to this URL/view to keep the server from getting congested. Any tips on how i would go about doing this? The page in itself is very simple and the usage will be low.

    Read the article

  • Project design / FS layout for large django projects

    - by rcreswick
    What is the best way to layout a large django project? The tutuorials provide simple instructions for setting up apps, models, and views, but there is less information about how apps and projects should be broken down, how much sharing is allowable/necessary between apps in a typical project (obviously that is largely dependent on the project) and how/where general templates should be kept. Does anyone have examples, suggestions, and explanations as to why a certain project layout is better than another? I am particularly interested in the incorporation of large numbers of unit tests (2-5x the size of the actual code base) and string externalization / templates.

    Read the article

< Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >