Search Results

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

Page 42/633 | < Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >

  • Rails - handling global site settings

    - by egarcia
    I'm developing a new rails application which is supposed to be installed several times in order to implement several sites. There are some things, like the "Site Title" or the "Default Number of Items per Page" that clearly belong to a "global settings" table / config file. I've made a list of the things I think I'll need: ActiveRecord model that is capable of: Storing different kinds of data. I suppose this would be accomplished encoding the values on a string on the db, probably with a "type" field. Indexing settings by name Validations based on a "type" attribute (i.e. don't accept invalid dates on "date" settings) Validations based on a allows_nil property. A controller that allows me to change settings via views. I'm pretty sure I could implement this myself, but I'm not willing to reinvent the wheel. I've done some searching, but I could only find rails-settings, which doesn't really serve me: I need a proper model & controller so I can use declarative-authorization, and it does not provide any controller or view facilities. Is there a gem or plugin out there that implements what I want, or any library I should look at? Thanks a lot.

    Read the article

  • Changing settings in multiple VS project

    - by Danra
    Hey, Is there any way to change settings for multiple projects in a Visual Studio 2008 C++ solution? For example, adding a library dependancy for all the projects, or ignoring a specific warning. I am aware being able to change some global settings in the IDE itself, but I'm looking for settings which will be stored in the solution/project files. Thanks, Dan

    Read the article

  • Dajano admin site foreign key fields

    - by user292652
    hi i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100) Nick = models.CharField(max_length=100, blank=True) Jersy_Number = models.IntegerField() Team_id = models.ForeignKey('Team') Postion_Choices = ( ('M', 'Manager'), ('P', 'Player'), ) Poistion = models.CharField(max_length=1, blank=True, choices =Postion_Choices) Red_card = models.IntegerField( blank=True, null=True) Yellow_card = models.IntegerField(blank=True, null=True) Points = models.IntegerField(blank=True, null=True) #Pic = models.ImageField(upload_to=path/for/upload, height_field=height, width_field=width, max_length=100) class PlayerAdmin(admin.ModelAdmin): list_display = ('Player_Name',) search_fields = ['Player_Name',] admin.site.register(Player, PlayerAdmin) class Team(models.Model): """Model docstring""" #slug = models.slugField(max_length=200) Team_Name = models.CharField(max_length=100,) College = models.CharField(max_length=100,) Win = models.IntegerField(blank=True, null=True) Loss = models.IntegerField(blank=True, null=True) Draw = models.IntegerField(blank=True, null=True) #logo = models.ImageField(upload_to=path/for/upload, height_field=height, width_field=width, max_length=100) class Meta: pass #def __unicode__(self): # return Team_Name #def save(self, force_insert=False, force_update=False): # pass @models.permalink def get_absolute_url(self): return ('view_or_url_name') class TeamAdmin(admin.ModelAdmin): list_display = ('Team_Name',) search_fields = ['Team_Name',] admin.site.register(Team, TeamAdmin) my question is how do i get to the admin site to show Team_name in the add player form Team_ID field currently it is only showing up as Team object in the combo box

    Read the article

  • Is it possible to replace values ina queryset before sending it to your template?

    - by Issy
    Hi Guys, Wondering if it's possible to change a value returned from a queryset before sending it off to the template. Say for example you have a bunch of records Date | Time | Description 10/05/2010 | 13:30 | Testing... etc... However, based on the day of the week the time may change. However this is static. For example on a monday the time is ALWAYS 15:00. Now you could add another table to configure special cases but to me it seems overkill, as this is a rule. How would you replace that value before sending it to the template? I thought about using the new if tags (if day=1), but this is more of business logic rather then presentation. Tested this in a custom template tag def render(self, context): result = self.model._default_manager.filter(from_date__lte=self.now).filter(to_date__gte=self.now) if self.day == 4: result = result.exclude(type__exact=2).order_by('time') else: result = result.order_by('type') result[0].time = '23:23:23' context[self.varname] = result return '' However it still displays the results from the DB, is this some how related to 'lazy' evaluation of templates? Thanks! Update Responding to comments below: It's not stored wrong in the DB, its stored Correctly However there is a small side case where the value needs to change. So for example I have a From Date & To date, my query checks if todays date is between those. Now with this they could setup a from date - to date for an entire year, and the special cases (like mondays as an example) is taken care off. However if you want to store in the DB you would have to capture several more records to cater for the side case. I.e you would be capturing the same information just to cater for that 1 day when the time changes. (And the time always changes on the same day, and is always the same)

    Read the article

  • verbose_name for a model's method

    - by mawimawi
    How can I set a verbose_name for a model's method, so that it might be displayed in the admin's change_view form? example: class Article(models.Model): title = models.CharField(max_length=64) created_date = models.DateTimeField(....) def created_weekday(self): return self.created_date.strftime("%A") in admin.py: class ArticleAdmin(admin.ModelAdmin): readonly_fields = ('created_weekday',) fields = ('title', 'created_weekday') Now the label for created_weekday is "Created Weekday", but I'd like it to have a different label which should be i18nable using ugettext_lazy as well. I've tried created_weekday.verbose_name=... after the method, but that did not show any result. Is there a decorator or something I can use, so I could make my own "verbose_name" / "label" / whateverthename is?

    Read the article

  • How to filter Many2Many / Generic Relations properly with Q?

    - by HWM-Rocker
    Hi, I have 3 Models, the TaggedObject has a GenericRelation with the ObjectTagBridge. And the ObjectTagBridge has a ForeignKey to the Tag Model. class TaggedObject(models.Model): """ class that represent a tagged object """ tags = generic.GenericRelation('ObjectTagBridge', blank=True, null=True) class ObjectTagBridge(models.Model): """ Help to connect a generic object to a Tag. """ # pylint: disable-msg=W0232,R0903 content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') tag = models.ForeignKey('Tag') class Tag(models.Model): ... when I am attaching a Tag to an Object, I am creating a new ObjectTagBridge and set its ForeignKey tag to the Tag I want to attach. That is working fine, and I can get all Tags that I attached to my Object very easy. But when I want to get (filter) all Objects that have Tag1 and Tag2 I tried to something like this: query = Q(tags__tag=Tag1) & Q(tags__tag=Tag2) object_list = TaggedObjects.filter(query) but now my object_list is empty, because it is looking for TaggedObjects that have one ObjectTagBridge with 2 tag objects, the first with Tag1 and the second with Tag2. I my application will be more complex Q queries than this one, so I think I need a solution with this Q object. In fact any combination of binary conjunctions, like: (...) and ( (...) or not(...)) How can I filter this correctly? Every answer is welcome, maybe there is also a different way do achieve this. thx for your help!!!

    Read the article

  • How to return number of rows in the template

    - by xRobot
    In my view I return all posts of one blog: posts = Post.objects.filter(blog=blog) and pass it to context. But.. How can I get the number of posts in the template ? This is my template: <h1>Number of posts: {{ ??? }} </h1> {% for post in posts %} {{ post.title }} {{ post.body }} {% endfor %}

    Read the article

  • Djangoo Foreign key queries

    - by Hulk
    In the following model: class header(models.Model): title = models.CharField(max_length = 255) created_by = models.CharField(max_length = 255) def __unicode__(self): return self.id() class criteria(models.Model): details = models.CharField(max_length = 255) headerid = models.ForeignKey(header) def __unicode__(self): return self.id() class options(models.Model): opt_details = models.CharField(max_length = 255) headerid = models.ForeignKey(header) def __unicode__(self): return self.id() If there is a row in the database for table header as Id=1, title=value-mart , createdby=CEO How do i query criteria and options tables to get all the values related to header table id=1 Also can some one please suggest a good link for queries examples, Thanks..

    Read the article

  • Is it possible to replace values in a queryset before sending it to your template?

    - by Issy
    Hi Guys, Wondering if it's possible to change a value returned from a queryset before sending it off to the template. Say for example you have a bunch of records Date | Time | Description 10/05/2010 | 13:30 | Testing... etc... However, based on the day of the week the time may change. However this is static. For example on a monday the time is ALWAYS 15:00. Now you could add another table to configure special cases but to me it seems overkill, as this is a rule. How would you replace that value before sending it to the template? I thought about using the new if tags (if day=1), but this is more of business logic rather then presentation. Tested this in a custom template tag def render(self, context): result = self.model._default_manager.filter(from_date__lte=self.now).filter(to_date__gte=self.now) if self.day == 4: result = result.exclude(type__exact=2).order_by('time') else: result = result.order_by('type') result[0].time = '23:23:23' context[self.varname] = result return '' However it still displays the results from the DB, is this some how related to 'lazy' evaluation of templates? Thanks! Update Responding to comments below: It's not stored wrong in the DB, its stored Correctly However there is a small side case where the value needs to change. So for example I have a From Date & To date, my query checks if todays date is between those. Now with this they could setup a from date - to date for an entire year, and the special cases (like mondays as an example) is taken care off. However if you want to store in the DB you would have to capture several more records to cater for the side case. I.e you would be capturing the same information just to cater for that 1 day when the time changes. (And the time always changes on the same day, and is always the same)

    Read the article

  • access settings from whole jquery component

    - by Pacuraru Daniel
    I am trying to develop a jquery component for dialog modals and i dont know how to access the settings from all component functions. I need to access settings,zIndex from open function and it seems to not work. (function($) { var methods = { init: function(options) { var defaults = { bgClass: "fancy-dialog-bg", bgShow: null, zIndex: 100, show: null }; var settings = $.extend(defaults, options); return this.each(function() { var obj = $(this).hide().css("position", "fixed").css("z-index", settings.zIndex).css("left", "300px").css("top", "200px"); }); }, open: function() { // alert(settings.zIndex); not working var tes = $("<div></div>").css("backgroundColor", "#f00").css("position", "fixed").css("z-index", "99").css("width", "50%").css("height", "100%").css("left", "0").css("top", "0"); $('body').append(tes); var obj = $(this); obj.show(); }, close: function() { var obj = $(this); $("#fancy-dialog-bg-" + obj.attr('id')).remove(); obj.hide(); } }; $.fn.fancyDialog = function(method) { if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method) { return methods.init.apply(this, arguments); } else { $.error('Method ' + method + ' does not exist.'); } }; })(jQuery);

    Read the article

  • Returning modified data to a template

    - by Duncan
    I need to amend QuerySet data when i return it to a template. for example, model.objects.all() returns a date (with other fields), but i also want to return the number of days since that date has passed. This is so that in the template, i can say "you last logged in 4 days ago". What is the best way to do this?

    Read the article

  • How to disable Middleware and Request Context in some views.

    - by xRobot
    I am creating a chat like facebook chat... so in views.py of my Chat Application, I need to retrieve only the last messages every 3-4 seconds with ajax poll ( the latency is not a problem for me ). If I can disable some Middlewares and some Request Context in this view, the response will be faster... no ? My question is: Is there a way to disable some Middlewares and some Request Context in some views ?

    Read the article

  • Formset Messages

    - by Dave
    I want to be able to send a message using the new messages framework. Something along the lines of : ... if formset.is_valid return HttpResponseRedirect( some page ) messages.add_message(request,messages.INFO, '%i objects added') %formset.number_of_forms But two questions: Im not sure if i should put the messages before or after the render to response Is there a method akin to number_of_forms

    Read the article

  • How to save link with tag e parameters in TextField

    - by xRobot
    I have this simple Post model: class Post(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True) body = models.TextField(_('body')) blog = models.ForeignKey(Blog, related_name="posts") user = models.ForeignKey(User) I want that when I insert in the form the links, the these links are saved in the body from this form: http://www.example.com or www.example.com to this form ( with tag and rel="nofollow" parameter ): <a href="http://www.example.com" rel="nofollow">www.example.com</a> How can I do this ? Thanks ^_^

    Read the article

  • Rails: Best practice to store user settings?

    - by ole_berlin
    Hi, I'm wondering what the best way is to store user settings? For a web 2.0 app I want users to be able to select certain settings. At the moment is it only when to receive email notifications. The easiest way would be to just create a Model "Settings" and have a column for every setting and then have a 1-1 relationship with users. But is there a pattern to solve this better? Is it maybe better to store the info in the user table itself? Or should I use a table with "settings_name" and "settings_value" to be completely open about the type of settings stored there (without having to run any migrations when adding options)? What is your opinion? Thanks

    Read the article

  • Change list link to foreign key change page

    - by Adam
    When viewing the admin change list for a model, is it possible to make the columns that correspond to foreign keys links to their respective pages? A simple example is I have a Foo object which contains Bar as a foreign key. If I'm viewing the admin change list for Foo (and have it set to include Bar in the display_list columns), the main column would link to the Foo instance's edit page while the Bar column would link to the Boo instance's edit page. I understand I can override the template that's used, but I was curious if there was a solution that didn't require that.

    Read the article

  • How to save links with tags and parameters in TextField

    - by xRobot
    I have this simple Post model: class Post(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True) body = models.TextField(_('body')) blog = models.ForeignKey(Blog, related_name="posts") user = models.ForeignKey(User) I want that when I insert in the form the links, then these links are saved in the body from this form: http://www.example.com or www.example.com to this form ( with tag and rel="nofollow" parameter ): <a href="http://www.example.com" rel="nofollow">www.example.com</a> How can I do this ? Thanks ^_^

    Read the article

  • Replacing text with variables

    - by Steve
    I have to send out letters to certain clients and I have a standard letter that I need to use. I want to replace some of the text inside the body of the message with variables. Here is my maturity_letter models.py class MaturityLetter(models.Model): default = models.BooleanField(default=False, blank=True) body = models.TextField(blank=True) footer = models.TextField(blank=True) Now the body has a value of this: Dear [primary-firstname], AN IMPORTANT REMINDER… You have a [product] that is maturing on [maturity_date] with [financial institution]. etc Now I would like to replace everything in brackets with my template variables. This is what I have in my views.py so far: context = {} if request.POST: start_form = MaturityLetterSetupForm(request.POST) if start_form.is_valid(): agent = request.session['agent'] start_date = start_form.cleaned_data['start_date'] end_date = start_form.cleaned_data['end_date'] investments = Investment.objects.all().filter(maturity_date__range=(start_date, end_date), plan__profile__agent=agent).order_by('maturity_date') inv_form = MaturityLetterInvestments(investments, request.POST) if inv_form.is_valid(): sel_inv = inv_form.cleaned_data['investments'] context['sel_inv'] = sel_inv maturity_letter = MaturityLetter.objects.get(id=1) context['mat_letter'] = maturity_letter context['inv_form'] = inv_form context['agent'] = agent context['show_report'] = True Now if I loop through the sel_inv I get access to sel_inv.maturity_date, etc but I am lost in how to replace the text. On my template, all I have so far is: {% if show_letter %} {{ mat_letter.body }} <br/> {{ mat_letter.footer }} {% endif %} Much appreciated.

    Read the article

  • IntegrityError with Booleand Fields and Postgresql

    - by xRobot
    I have this simple Blog model: class Blog(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True) body = models.TextField(_('body')) user = models.ForeignKey(User) is_public = models.BooleanField(_('is public'), default = True) When I insert a blog in admin interface, I get this error: IntegrityError at /admin/blogs/blog/add/ null value in column "is_public" violates not-null constraint Why ???

    Read the article

< Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >