Search Results

Search found 15813 results on 633 pages for 'django settings'.

Page 79/633 | < Previous Page | 75 76 77 78 79 80 81 82 83 84 85 86  | Next Page >

  • Django - User account with multiple identities

    - by Scott Willman
    Synopsis: Each User account has a UserProfile to hold extended info like phone numbers, addresses, etc. Then, a User account can have multiple Identities. There are multiple types of identities that hold different types of information. The structure would be like so: User |<-FK- UserProfile | |<-FK- IdentityType1 |<-FK- IdentityType1 |<-FK- IdentityType2 |<-FK- IdentityType3 (current) |<-FK- IdentityType3 |<-FK- IdentityType3 The User account can be connected to n number of Identities of different types but can only use one Identity at a time. Seemingly, the Django way would be to collect all of the connected identities (user.IdentityType1_set.select_related()) into a QuerySet and then check each one for some kind of 'current' field. Question: Can anyone think of a better way to select the 'current' marked Identity than doing three DB queries (one for each IdentityType)?

    Read the article

  • Additional information with widgets in django

    - by fromclouds
    I am displaying a django widget, with which I need to display additional information (something like a tool tip) that is attendant to the widget. I essentially have a widget that asks a random question, which is self contained. {{ form.fieldname }} displays the full widget which looks something like (à la the widget's render method): <label for="id_answer">Question:</label> <input type="hidden" name="question_id" value="n" /> <span class="prompt">What is the air-speed velocity of an unladen swallow?</span> <input type="text" name="answer" /> What I'm essentially asking is, is there a way to break out the prompt, so that I can lay the widget out piecemeal? I would like to lay it out not with a call to {{ form.fieldname }} as above, but like: {{ form.fieldname.label }} {{ form.fieldname.prompt }} {{ form.fieldname }} Does anyone know how to do this?

    Read the article

  • Django Inline Admin elements do not allow editing

    - by nickcartwright
    Hiya, In the Django admin I'd like the ability to edit my models referenced by foreign keys In-Line. I've read all the instructions, added a TabularInline object and my models are displayed there. All looks great, however, I only have the option to add new models and not an option to edit existing. Is there something I've been missing? All the documentation suggests the In-Line models are there to allow you to edit referenced models In-Line, however - all I can see is Add. Any help would be much appreciated!

    Read the article

  • Django Forms: TimeField Validation

    - by Tom
    I feel like I'm missing something obvious here. I have a Django form with a TimeField on it. I want to be able to allow times like "10:30AM", but I cannot get it to accept that input format or to use the "%P" format (which has a note attached saying it's a "Proprietary extension", but doesn't say where it comes from). Here's the gist of my form code: calendar_widget = forms.widgets.DateInput(attrs={'class': 'date-pick'}, format='%m/%d/%Y') time_widget = forms.widgets.TimeInput(attrs={'class': 'time-pick'}) valid_time_formats = ['%P', '%H:%M%A', '%H:%M %A', '%H:%M%a', '%H:%M %a'] class EventForm(forms.ModelForm): start_date = forms.DateField(widget=calendar_widget) start_time = forms.TimeField(required=False, widget=time_widget, help_text='ex: 10:30AM', input_formats=valid_time_formats) end_date = forms.DateField(required=False, widget=calendar_widget) end_time = forms.TimeField(required=False, widget=time_widget, help_text='ex: 10:30AM', input_formats=valid_time_formats) description = forms.CharField(widget=forms.Textarea) Any time I submit "10:30AM", I get a validation error. The underlying model has two fields, event_start and event_end, no time fields, so I don't think the problem is in there. What stupid thing am I missing?

    Read the article

  • Django template context not working with imported class

    - by Andy Hume
    I'm using Django's templating on appengine, and am having a problem whereby a class I'm importing from another package is not correctly being made available to the template context. Broadly speaking, this is the code. The prop1 is not available in the template in the first example below, but is in the second. MyClass is identical in both cases. This does not work: from module import MyClass context = MyClass() self.response.out.write(template.render(path, context)) This does: class MyClass(object): def __init__(self): self.prop1 = "prop1" context = MyClass() self.response.out.write(template.render(path, context)) If I log the context in the above code I get: <module.MyClass object at 0x107b1e450> when it's imported, and: <__main__.MyClass object at 0x103759390> when it's defined in the same file. Any clues as to what might cause this kind of behaviour?

    Read the article

  • Django: Staff Decorator

    - by Mark
    I'm trying to write a "staff only" decorator for Django, but I can't seem to get it to work: def staff_only(error='Only staff may view this page.'): def _dec(view_func): def _view(request, *args, **kwargs): u = request.user if u.is_authenticated() and u.is_staff: return view_func(request, *args, **kwargs) messages.error(request, error) return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('home'))) _view.__name__ = view_func.__name__ _view.__dict__ = view_func.__dict__ _view.__doc__ = view_func.__doc__ return _view return _dec Trying to follow lead from here. I'm getting: 'WSGIRequest' object has no attribute '__name__' But if I take those 3 lines out, I just get a useless "Internal Server Error". What am I doing wrong here?

    Read the article

  • django - change content inside a iframe

    - by fabriciols
    Hello guys, I have a site running in django, and want to make available this content on third party site. In these sites they make my content in a tag. When my site is required from within that iframe I would like to modify the content (remove header, filter data, etc.). What better way to do this? Is there any way of knowing that the request is being made from an iframe? Multiples sites will request the same url, can i change the content, based on the source site? thanks! ps.: sorry for my bad english :/

    Read the article

  • AppEngine and Django: including a template file

    - by PythonPower
    As the title suggests, I'm using Google App Engine and Django. I have quite a bit of identical code across my templates and would like to reduce this by including template files. So, in my main application directory I have the python handler file, the main template, and the template I want to include in my main template. I would have thought that including {% include "fileToInclude.html" %} would work on its own but that simply doesn't include anything. I assume I have to set something up, maybe using TEMPLATE_DIRS, but can't figure it out on my own. EDIT: I've tried: TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'), ) But to no avail. I'll try some other possibilities too.

    Read the article

  • version control + continuous integration with Flex + Ruby or Django

    - by user306584
    trying to pick version control, continuous integration, and host for Flex + Ruby or Django smallish project. Question: version control: I've used SVN and CVS in the past. I hear great things about git. Not sure what to pick. continuous integration: I've heard good things about hudson and cruiseControl. Not sure what to pick hosting: is my own server the only way to go? Are the decent cloud options that are not too expensive? or should I look for some free hosting service? thank you for your help! f

    Read the article

  • django - change content inside an iframe

    - by fabriciols
    Hello guys, I have a site running in django and want to make it available on third party sites. In these sites they make my content available through an tag. When my site is requested from within that iframe I would like to modify the content (remove header, filter data, etc.). What would be the best way to do this? Is there any way of knowing that the request is being made from an iframe? Multiples sites will request the same url, can I change the content, based on the requesting site? Thanks! PS: Sorry for my bad english :/

    Read the article

  • How do I reference the other object in django models

    - by UserZero
    Hi, first post here.In Django, I want to have many files be associated with a particular model, so I'm doing a seperate model called files and have model 'A' 'have many' files. But I want my files to be saved in director named by model 'A'. So For example I want something like this: class Show(models.Model): name = models.CharField() showfolder = models.FilePathField() class Episode(models.Model): show = models.ForeignKey(Show) name = models.CharField() files = models.ManyToManyField(mp3) class Mp3(models.Model): file = FileField(upload_to=Episode.show.showfolder) So hopefully that last line expresses what I WANT it to do(get the folder name from Show object associated with the episode). The question is how would I really write that?(besides jumping through hoops in the controller.) Thanks.

    Read the article

  • Show a django relationship in a template

    - by kevin_82
    I have a django model as follows: class Person(models.Model): name = models.CharField(max_length=255) class Relationship(models.Model): parent = models.ForeignKey(Person) child = models.ForeignKey(Person) description = models.TextField(blank=True) In my view, I pass a certain person, and the relationships in which he/she is parent: person = Person.objects.filter(name ='some name') descendant_relationships = Relationship.objects.filter(parent = person) An I want to show this person's descendants in a list in a template: <ul> {% for item in descendant_relationships%} <li> {{item.child.name}} - {{item.description}} </li> {% endfor %} </ul> But this template code will not show the children of children (i.e. grandchildren, great-grandchildren etc.). How can I get these lower level descendants to show up? I imagine recursion is necessary somewhere, but where?

    Read the article

  • django image managment

    - by Andrey
    I'am new in django. In my project I'am working with images. I don't know how to organize the management of images. I need to dynamically upload the pictures and resize them. First question - what is the best way to dynamically upload images with progress bar and without flash? I found this and this, but I believe there is a better way. Second question. I have to save one image in different sizes. I won't use these thumbnails on my pages, but another application will. Many clients could upload images at the same time. This means that I can not resize all the images at the same time. How should I organize this process? Is there are a better ready-to-use solution for image management issue?

    Read the article

  • How do I delete in Django? (mysql transactions)

    - by alex
    If you are familiar with Django, you know that they have a Authentication system with User model. Of course, I have many other tables that have a Foreign Key to this User model. If I want to delete this user, how do I architect a script (or through mysql itself) to delete every table that is related to this user? My only worry is that I can do this manually...but if I add a table , but I forget to add that table to my DELETE operation...then I have a row that links to a deleted, non-existing User.

    Read the article

  • Django - Expression based model constraints

    - by rtmie
    Is it possible to set an expression based constraint on a django model object, e.g. If I want to impose a constraint where an owner can have only one widget of a given type that is not in an expired state, but can have as many others as long as they are expired. Obviously I can do this by overriding the save method, but I am wondering if it can be done by setting constraints, e.g. some derivative of the unique_together constraint WIDGET_STATE_CHOICES = ( ('NEW', 'NEW'), ('ACTIVE', 'ACTIVE'), ('EXPIRED', 'EXPIRED') ) class MyWidget(models.Model): owner = models.CharField(max_length=64) widget_type = models.CharField(max_length = 10) widget_state = models.CharField(max_length = 10, choices = WIDGET_STATE_CHOICES) #I'd like to be able to do something like class Meta: unique_together = (("owner","widget_type","widget_state" != 'EXPIRED')

    Read the article

  • Adding custom fields to users in django

    - by Gaurav
    I am the create_user() function that Django provides to create my users. Also I want to store additional information about the users. So I tried following the instructions given at http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users but I cannot get it to work for me. Is there a step-by-step guide that I can follow to get this to work for me? Also, once I have added these custom fields, I would obviously need to add / edit / delete data from them. I cannot seem to find any instructions on how to do this.

    Read the article

  • Resizing uploaded images based on a maximum width in django (PIL)

    - by AndrewE
    I'm working on a simple message board app in Django that lets people upload images to be displayed in their posts. Since the div containing the posts is only 700px, I want to resize the uploaded images to a max width of something like 680px to save space rather than using css to display an image that's too large within the space constraints. I've been searching this site, google and the PIL docs for a while and haven't found any way of resizing an image on one dimension while maintaining the original aspect ratio. Given my inexperience, it's possible that I'm just not recognizing a solution that's plain to someone who knows what to look for.

    Read the article

  • Django m2m adding field in the secondary table

    - by dana
    I have a model in wich i'm using m2m Django ORM feature, in order to create an aditional table to hold my 'classrom members'. My problem is: the membership to a classroom must be accepted by the invited one, so i need a boolean field :1=accepted, 0=refused/unseen yet. How can i include this boolean variable in the aditionally generated classroom_membership (and NOT in the primary created Classroom table)? class Classroom(models.Model): user = models.ForeignKey(User, related_name = 'classroom_creator') classname = models.CharField(max_length=140, unique = True) date = models.DateTimeField(auto_now=True) open_class = models.BooleanField(default=True) #domain = models.EnumField() members = models.ManyToManyField(User,related_name="list of invited members") Thanks in advance!!

    Read the article

  • Class views in Django

    - by Sebastjan Trepca
    Django view points to a function, which can be a problem if you want to change only a bit of functionality. Yes, I could have million keyword arguments and even more if statements in the function, but I was thinking more of an object oriented approach. For example, I have a page that displays a user. This page is very similar to page that displays a group, but it's still not so similar to just use another data model. Group also has members etc... One way would be to point views to class methods and then extend that class. Has anyone tried this approach or has any other idea?

    Read the article

  • Building a financial app with Django

    - by mfalcon
    Hi guys, I'm building an app for a small business so I've to work with currencies, decimal numbers, etc... My goal is to create something like pulseapp.com. I've searched for opensource projects to look and the only thing I had found was django-cashflow. This app uses python-money. I've read some of the code and the ways it's coded seems a bit weird to me and it's not fully complete. Is the app worth to take a deep look? Does anyone know about another similar app? Is the task difficult or a begginer like me could find a way to code it himself?

    Read the article

  • How to save enum settings in Visual Studio project properties?

    - by zaidwaqi
    Hi, In the Settings tab in Visual Studio, I can see Name, Type, Scope, Value table. Define settings is intuitive if the data type is already within the Type drop-down list i.e. integer, string, long etc. But I can't find enum anywhere. How do I save enum settings then? For now, I have the following which clutter my code too much. public enum Action { LOCK = 9, FORCED_LOGOFF = 12, SHUTDOWN = 14, REBOOT, LOGOFF = FORCED_LOGOFF }; and I define Action as int in the setting. Then I have to do, switch (Properties.Settings.Default.Action) { case 9: SetAction(Action.LOCK); break; case 12: SetAction(Action.FORCED_LOGOFF); break; case 14: SetAction(Action.SHUTDOWN); break; case 15: SetAction(Action.REBOOT); break; default: SetAction(Action.LOCK); break; } Would be nice if I could simply do something like SetAction(Properties.Settings.Default.Action); to replace all above but I dont know how to save enum in setting. Hope my question is clear. Thanks.

    Read the article

  • creating events in my classes, and allowing others to hook into them in my django app

    - by Blankman
    I want to create events for my classes. Say I create a CMS application that has a Article object. I create events like: OnEdit OnCreate OnDelete PreCreate PreDelete Now I want someone to be able to hook into these events, and add their custom functionality at each event they wish. I don't want them touching the core source code, so they would have to wire these custom methods to fire somewhere else. I'm new to both python and django so please be as detailed as possible if you can.

    Read the article

  • Sending emails from Django App

    - by Will M.
    We are a growing Django app that is currently using Google Apps to send email. We are hitting the maximum limits of email sending and need a better solution. We prefer not to have to manage our own email servers and the easier the better. What is the best, easiest, and cheapest way to send a large amount of email? We have looked at Postageapp but they require you to use your own SMTP server. We are considering App Engine to send email but it will require a lot of configuration to get it to work correctly. What can we use to quickly fix this problem?

    Read the article

  • Django store regular expression in DB which then gets evaluated on page

    - by John
    Hi, I want to store a number of url patterns in my django model which a user can provide parameters to which will create a url. For example I might store these 3 urls in my db where %s is the variable parameter provided by the user: www.thisissomewebsite.com?param=%s www.anotherurl/%s/ www.lastexample.co.uk?param1=%s&fixedparam=2 As you can see from these examples the parameter can appear anywhere in the string and not in a fixed position. I have 2 models, one holds the urls and one holds the variables: class URLPatterns(models.Model): pattern = models.CharField(max_length=255) class URLVariables(models.Model): pattern = models.ForeignKey(URLPatterns) param = models.CharField(max_length=255) What would be the best way to generate these urls by replacing the %s with the variable in the database. would it just be a simple replace on the string e.g: urlvariable = URLVariable.objects.get(pk=1) pattern = url.pattern url = pattern.replace("%s", urlvariable.param) or is there a better way? Thanks

    Read the article

  • php vs python django or something else for CMS module

    - by Michael
    We're looking to develop a CMS module for our website and I need some help in choosing the language/framework for this project. Basically we need to develop a "help' module like this one from ebay http://pages.ebay.com/help/index.html which will contain a lot of static pages with nice URLs for SEO. The application must run fast using low computer resources. We have been looking to use php on a custom made mvc framework but we received advice from other sources that py/django is the exactly language/framework that we need in terms of maintainability and development speed because it was developed for exactly this kind of projects so I need an expert advice on this matter with pro and cons for each choice.

    Read the article

< Previous Page | 75 76 77 78 79 80 81 82 83 84 85 86  | Next Page >