Search Results

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

Page 127/633 | < Previous Page | 123 124 125 126 127 128 129 130 131 132 133 134  | Next Page >

  • Is there a better way to format this Python/Django code as valid PEP8?

    - by Ryan Detzel
    I have code written both ways and I see flaws in both of them. Is there another way to write this or is one approach more "correct" than the other? def functionOne(subscriber): try: results = MyModelObject.objects.filter( project__id=1, status=MyModelObject.STATUS.accepted, subscriber=subscriber).values_list( 'project_id', flat=True).order_by('-created_on') except: pass def functionOne(subscriber): try: results = MyModelObject.objects.filter( project__id=1, status=MyModelObject.STATUS.accepted, subscriber=subscriber) results = results.values_list('project_id', flat=True) results = results.order_by('-created_on') except: pass

    Read the article

  • How can I traverse a reverse generic relation in a Django template?

    - by user569139
    I have the following class that I am using to bookmark items: class BookmarkedItem(models.Model): is_bookmarked = models.BooleanField(default=False) user = models.ForeignKey(User) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey() And I am defining a reverse generic relationship as follows: class Link(models.Model): url = models.URLField() bookmarks = generic.GenericRelation(BookmarkedItem) In one of my views I generate a queryset of all links and add this to a context: links = Link.objects.all() context = { 'links': links } return render_to_response('links.html', context) The problem I am having is how to traverse the generic relationship in my template. For each link I want to be able to check the is_bookmarked attribute and change the add/remove bookmark button according to whether the user already has it bookmarked or not. Is this possible to do in the template? Or do I have to do some additional filtering in the view and pass another queryset?

    Read the article

  • [Django] How do I filter the choices in a ModelForm that has a CharField with the choices attribute

    - by nubela
    I understand I am able to filter queryset of Foreignkey or Many2ManyFields, however, how do I do that for a simple CharField that is a Select Widget (Select Tag). For example: PRODUCT_STATUS = ( ("unapproved", "Unapproved"), ("approved", "Listed"), #("Backorder","Backorder"), #("oos","Out of Stock"), #("preorder","Preorder"), ("userdisabled", "User Disabled"), ("disapproved", "Disapproved by admin"), ) and the Field: o_status = models.CharField(max_length=100, choices=PRODUCT_STATUS, verbose_name="Product Status", default="approved") Suppose I wish to limit it to just "approved" and "userdisabled" instead showing the full array (which is what I want to show in the admin), how do I do it? Thanks!

    Read the article

  • Best practice: How to persist simple data without a database in django?

    - by Infinity
    I'm building a website that doesn't require a database because a REST API "is the database". (Except you don't want to be putting site-specific things in there, since the API is used by mostly mobile clients) However there's a few things that normally would be put in a database, for example the "jobs" page. You have master list view, and the detail views for each job, and it should be easy to add new job entries. (not necessarily via a CMS, but that would be awesome) e.g. example.com/careers/ and example.com/careers/77/ I could just hardcode this stuff in templates, but that's no DRY- you have to update the master template and the detail template every time. What do you guys think? Maybe a YAML file? Or any better ideas? Thx

    Read the article

  • what is the 'extra' mean in this django code..

    - by zjm1126
    TOPIC_COUNT_SQL = """ SELECT COUNT(*) FROM topics_topic WHERE topics_topic.object_id = maps_map.id AND topics_topic.content_type_id = %s """ MEMBER_COUNT_SQL = """ SELECT COUNT(*) FROM maps_map_members WHERE maps_map_members.map_id = maps_map.id """ maps = maps.extra(select=SortedDict([ ('member_count', MEMBER_COUNT_SQL), ('topic_count', TOPIC_COUNT_SQL), ]), select_params=(content_type.id,)) i don't know this mean, thanks

    Read the article

  • Django database - how to add this column in raw SQL.

    - by alex
    Suppose I have my models set up already. class books(models.Model): title = models.CharField... ISBN = models.Integer... What if I want to add this column to my table? user = models.ForeignKey(User, unique=True) How would I write the raw SQL in my database so that this column works?

    Read the article

  • Django. Invalid keyword argument for this function. ManyToMany

    - by sagem_tetra
    I have this error: 'people' is an invalid keyword argument for this function class Passage(models.Model): name= models.CharField(max_length = 255) who = models.ForeignKey(UserProfil) class UserPassage(models.Model): passage = models.ForeignKey(Passage) people = models.ManyToManyField(UserProfil, null=True) class UserProfil(models.Model): user = models.OneToOneField(User) name = models.CharField(max_length=50) I try: def join(request): user = request.user user_profil = UserProfil.objects.get(user=user) passage = Passage.objects.get(id=2) #line with error up = UserPassage.objects.create(people= user_profil, passage=passage) return render_to_response('thanks.html') How to do correctly? Thanks!

    Read the article

  • how can i introspect properties and model fields in django?

    - by shreddd
    I am trying to get a list of all existing model fields and properties for a given object. Is there a clean way to instrospect an object so that I can get a dict of fields and properties. class MyModel(Model) url = models.TextField() def _get_location(self): return "%s/jobs/%d"%(url, self.id) location = property(_get_location) What I want is something that returns a dict that looks like this: { 'id' : 1, 'url':'http://foo', 'location' : 'http://foo/jobs/1' } I can use model._meta.fields to get the model fields, but this doesn't give me things that are properties but not real DB fields.

    Read the article

  • Empty nvidia-settings after install v. 331.67 driver on Ubuntu 14.04?

    - by Victoralm
    I've followed this tutorial (with the following adjustments below) to install v. 331.67 nVidia driver. But get nvidia-settings (NVIDIA X Server Settings) empty... Then, before restart the PC, I make a xorg.conf in the nvidia-settings. The driver make Unity don't start right. So I installed nvidia-331-updates via apt-get and restarted the PC again. After that, the Unity works fine. But the nvidia-settings gets almost empty... Can someone help !?

    Read the article

  • Is there going to be a friendly Unity settings window?

    - by Valorin
    Currently, as far as I am aware, you need to use the CompizConfig Settings Manager application to play with the Unity configuration settings. While this makes sense, from a technical point of view, it requires the user to know about the settings manager, install it, and then find the Unity options within it. Not very user friendly. Is there a user friendly configuration application planned that will offer all the configuration options in an easy-to-use for new people fashion?

    Read the article

  • After Java un installation my system settings were vanished.

    - by Paul
    After my Java un installation, my system settings were gone. When I click on my system settings, I am not getting anything. For a long back I re-install my Java, so i don't remember which command I used to un-install my Java. Now I am not able to see my date and time settings and my shared folders are also not in sharing. Can anybody tell to me what gone wrong in my Java un-installation and how can I get back them.

    Read the article

< Previous Page | 123 124 125 126 127 128 129 130 131 132 133 134  | Next Page >