Search Results

Search found 3558 results on 143 pages for 'django templatetags'.

Page 26/143 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • django __search - trying to do x+y__search

    - by ckohrman
    I'm trying to do something like this with django: Q(x+y__search = z) I'm using __search to boolean search for a list of words within two separate lists (requiredTags, preferredTags). Line 10 is the one I have questions about. I want to see if the list of words (requTags) is found among requiredTags or preferredTags. requTags="" prefeTags="" for i in reqTags: if(i!=""): requTags+="+"+i+" " for i in prefTags: if(i!=""): prefeTags+=i+" " if(requTags!=""): query=query &( Q(requiredTags__search + preferredTags__search = requTags)) if(prefeTags!=""): query=query &( Q(requiredTags__search = prefeTags) | Q(preferredTags__search = prefeTags)) For instance: requTags might be: +beans +rice +cheese. requiredTags might be: beans,rice,tortilla preferredTags might be: cheese I didn't see any way to combine requiredTags and preferredTags in the documentation. Any help would be appreciated as I'm a beginner...

    Read the article

  • Django-pyodbc SQL Server/freetds server connection problems on linux

    - by wizard
    Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnectW)') I'm migrating from developing on a windows development machine to Linux machine in production and I'm having issues with the freetds driver. As far as I can tell that error message means it can't find the driver. I can connect via the cli via sqsh and tsql. I've setup my settings.py as such. 'bc2db': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'DataTEST', 'USER': 'appuser', 'PASSWORD': 'PASS', 'HOST': 'bc2.domain.com', 'options': { 'driver': 'FreeTDS', } }, Does anyone have any SQL Server experience with django? do I have to use a dns? (how would I format that?)

    Read the article

  • Python's Django or Delphi's IntraWeb?

    - by Azad Salahli
    Well, forgive me if it is an off-topic question. I have no knowledge about web programming, so I apologize in advance, if it is a stupid question. I will start to build a web based application. To be more specific, I will make a webpage which will have components like buttons, textboxes and etc. It will use a database to store information. My question is, which one is better to learn for that purpose? Python's Django or Delphi's IntraWeb? I know both Delphi and Python(although I know Delphi better).

    Read the article

  • Automatically create an admin user when running Django's ./manage.py syncdb

    - by a paid nerd
    My project is in early development. I frequently delete the database and run manage.py syncdb to set up my app from scratch. Unfortunately, this always pops up: You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): Then you have supply a username, valid email adress and password. This is tedious. I'm getting tired of typing test\[email protected]\ntest\ntest\n. How can I automatically skip this step and create a user programatically when running manage.py syncdb ?

    Read the article

  • Displaying Django Messages Framework Messages

    - by Arif
    I have been using the Django Messaging Framework to display messages to a user in the template. I am outputting them to the template like this: <ul> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> {% endfor %} </ul> This outputs all the messages, errors, warning, success etc. I was just wondering if anyone had any ideas how to display only the error messages something like: <ul> {% for message in messages.errors %} <li>{{ message }}</li> {% endfor %} </ul> Any ideas? Thanks in advance.

    Read the article

  • Tips/Process for web-development using Django in a small team

    - by Mridang Agarwalla
    We're developing a web app uing Django and we're a small team of 3-4 programmers — some doing the UI stuff and some doing the Backend stuff. I'd love some tips and suggestions from the people here. This is out current setup: We're using Git as as our SCM tool and following this branching model. We're following the PEP8 for your style guide. Agile is our software development methodology and we're using Jira for that. We're using the Confluence plugin for Jira for documentation and I'm going to be writing a script that also dumps the PyDocs into Confluence. We're using virtualenv for sandboxing We're using zc.buildout for building This is whatever I can think of off the top of my head. Any other suggestions/tips would be welcome. I feel that we have a pretty good set up but I'm also confident that we could do more. Thanks.

    Read the article

  • Not able to add html tags through jquery in django [closed]

    - by user1665581
    I am trying to add html tags dynamically through jquery in django. $("#div1").append("<h3> Hey !! </h3>"); $("#div1").append("<br/>"); But they are not working. However normal text is getting appended properly like $("#div1").append("Hey i am here"); I even noticed that some of the tags wern't working outside script like <br> so i had to replace it with <br/> also had to apply closing tag for input and also &nbsp is not working. what is wrong???

    Read the article

  • Using multilingual and localeurl in django

    - by Dmitry A. Erokhin
    Using dajngo-multilingual and localeurl. Small sample of my main page view: def main(request): #View for http://www.mysite.com/ name = Dog.objects.all()[0].full_name #this is a translated field return render_to_response("home.html", {"name" : name}) Entering http://www.mysite.com/ redirects me to http://www.mysite.com/ru/ and "name" variable gets russian localization. For now it's ok... But... Entering http://www.mysite.com/en/ shows me same russian loclized variable. During my experiments with debuger I've discovered: request.LANGUAGE_CODE is changing properly according to /en/ or /ru/ url suffix (thanx to localeurl) invoking multilingual.languages.set_default_language() makes "name" variable change loclization The question is: should I change language of django-multilingual to request.LANGUAGE_CODE in each of my view myself, or it must be solved automaticly and I've done something wrong?

    Read the article

  • django model Form. Include fields from related models

    - by Tom
    Hi. I have a model, called Student, which has some fields, and a OneToOne relationship with user (django.contrib.auth.User). class Student(models.Model): phone = models.CharField(max_length = 25 ) birthdate = models.DateField(null=True) gender = models.CharField(max_length=1,choices = GENDER_CHOICES) city = models.CharField(max_length = 50) personalInfo = models.TextField() user = models.OneToOneField(User,unique=True) Then, I have a ModelForm for that model class StudentForm (forms.ModelForm): class Meta: model = Student Using the fields attribute in class Meta, i've managed to show only some fields in a template. However, can I indicate which user fields to show? Something as: fields =('personalInfo','user.username') is currently not showing anything. Works with only StudentFields though/ Thanks in advance.

    Read the article

  • django internationlisation

    - by ha22109
    Hello I need to have multiple language support of my django admin application.I can create the messege files.But how can i change the text of my models.The heading ,fields etc .I m only able to change the static elements which are there in my template. here is example of my class class Mymodel(model.Models): id=models.IntegerField(primary_key=true) name=models.CharField(max_length=200) group=models.CharField(max_length=200) class Meta: managed=False verbose_name_plural='My admin' db_table='my_admin' one more question.In my home page it is showing my verbose name 'My admin' which i mentioned.But when i go to list page it shows me the class name 'mymodel'.Why so.Can i changed that to

    Read the article

  • Django comparing model instances for equality

    - by orokusaki
    I understand that, with a singleton situation, you can perform such an operation as: spam == eggs and if spam and eggs are instances of the same class with all the same attribute values, it will return True. In a Django model, this is natural because two separate instances of a model won't ever be the same unless they have the same .pk value. The problem with this is that if a reference to an instance has attributes that have been updated by middleware somewhere along the way and it hasn't been saved, and you're trying to it to another variable holding a reference to an instance of the same model, it will return False of course because they have different values for some of the attributes. Obviously I don't need something like a singleton , but I'm wondering if there some official Djangonic (ha, a new word) method for checking this, or if I should simply check that the .pk value is the same with: spam.pk == eggs.pk I'm sorry if this was a huge waste of time, but it just seems like there might be a method for doing this, and something I'm missing that I'll regret down the road if I don't find it.

    Read the article

  • Use variable as dictionary key in Django template

    - by CaptainThrowup
    I'd like to use a variable as an key in a dictionary in a Django template. I can't for the life of me figure out how to do it. If I have a product with a name or ID field, and ratings dictionary with indices of the product IDs, I'd like to be able to say: {% for product in product_list %} <h1>{{ ratings.product.id }}</h1> {% endfor %} In python this would be accomplished with a simple ratings[product.id] But I can't make it work in the templates. I've tried using with... no dice. Ideas?

    Read the article

  • Django view function design

    - by dragoon
    Hi, I have the view function in django that written like a dispatcher calling other functions depending on the variable in request.GET, like this: action = '' for act in ('view1', 'view2', 'view3', 'view4', ... ): if act in request.GET: action = act break ... if action == '': response = view0(request, ...) elif action == 'view1': response = view1(request, ...) elif action == 'view2': response = view2(request, ...) ... The global dispatcher function contains many variable initialization routines and these variables are then used in viewXX functions. So I feed that this is bad view design but I don't know how I can rewrite it?

    Read the article

  • Django Passing Custom Form Parameters to Formset

    - by Paolo Bergantino
    I have a Django Form that looks like this: class ServiceForm(forms.Form): option = forms.ModelChoiceField(queryset=ServiceOption.objects.none()) rate = forms.DecimalField(widget=custom_widgets.SmallField()) units = forms.IntegerField(min_value=1, widget=custom_widgets.SmallField()) def __init__(self, *args, **kwargs): affiliate = kwargs.pop('affiliate') super(ServiceForm, self).__init__(*args, **kwargs) self.fields["option"].queryset = ServiceOption.objects.filter(affiliate=affiliate) I call this form with something like this: form = ServiceForm(affiliate=request.affiliate) Where request.affiliate is the logged in user. This works as intended. My problem is that I now want to turn this single form into a formset. What I can't figure out is how I can pass the affiliate information to the individual forms when creating the formset. According to the docs to make a formset out of this I need to do something like this: ServiceFormSet = forms.formsets.formset_factory(ServiceForm, extra=3) And then I need to create it like this: formset = ServiceFormSet() Now how can I pass affiliate=request.affiliate to the individual forms this way?

    Read the article

  • django admin gives warning "Field 'X' doesn't have a default value"

    - by noam
    I have created two models out of an existing legacy DB , one for articles and one for tags that one can associate with articles: class Article(models.Model): article_id = models.AutoField(primary_key=True) text = models.CharField(max_length=400) class Meta: db_table = u'articles' class Tag(models.Model): tag_id = models.AutoField(primary_key=True) tag = models.CharField(max_length=20) article=models.ForeignKey(Article) class Meta: db_table = u'article_tags' I want to enable adding tags for an article from the admin interface, so my admin.py file looks like this: from models import Article,Tag from django.contrib import admin class TagInline(admin.StackedInline): model = Tag class ArticleAdmin(admin.ModelAdmin): inlines = [TagInline] admin.site.register(Article,ArticleAdmin) The interface looks fine, but when I try to save, I get: Warning at /admin/webserver/article/382/ Field 'tag_id' doesn't have a default value

    Read the article

  • Django file uploads - Just can't work it out

    - by phoebebright
    OK I give up - after 5 solid hours trying to get a django form to upload a file, I've checked out all the links in stackoverflow and googled and googled. Why is it so hard, I just want it to work like the admin file upload? So I get that I need code like: if submitForm.is_valid(): handle_uploaded_file(request.FILES['attachment']) obj = submitForm.save() and I can see my file in request.FILES['attachment'] (yes I have enctype set) but what am I supposed to do in handle_uploaded_file? The examples all have a fixed file name but obviously I want to upload the file to the directory I defined in the model, but I can't see where I can find that. def handle_uploaded_file(f): destination = open('fyi.xml', 'wb+') for chunk in f.chunks(): destination.write(chunk) destination.close() Bet I'm going to feel really stupid when someone points out the obvious!

    Read the article

  • Popularity Algorithm - SQL / Django

    - by RadiantHex
    Hi folks, I've been looking into popularity algorithms used on sites such as Reddit, Digg and even Stackoverflow. Reddit algorithm: t = (time of entry post) - (Dec 8, 2005) x = upvotes - downvotes y = {1 if x > 0, 0 if x = 0, -1 if x < 0) z = {1 if x < 0, otherwise x} log(z) + (y * t)/45000 I have always performed simple ordering within SQL, I'm wondering how I should deal with such ordering. Should it be used to define a table, or could I build an SQL with the ordering within the formula (without hindering performance)? I am also wondering, if it is possible to use multiple ordering algorithms in different occasions, without incurring into performance problems. I'm using Django and PostgreSQL. Help would be much appreciated! ^^

    Read the article

  • Tips/Process for web-development using Django in a small team

    - by Mridang Agarwalla
    We're developing a web app uing Django and we're a small team of 3-4 programmers — some doing the UI stuff and some doing the Backend stuff. I'd love some tips and suggestions from the people here. This is out current setup: We're using Git as as our SCM tool and following this branching model. We're following the PEP8 for your style guide. Agile is our software development methodology and we're using Jira for that. We're using the Confluence plugin for Jira for documentation and I'm going to be writing a script that also dumps the PyDocs into Confluence. We're using virtualenv for sandboxing We're using zc.buildout for building This is whatever I can think of off the top of my head. Any other suggestions/tips would be welcome. I feel that we have a pretty good set up but I'm also confident that we could do more. Thanks.

    Read the article

  • Django: How to create a model dynamically just for testing

    - by muhuk
    I have a Django app that requires a settings attribute in the form of: RELATED_MODELS = ('appname1.modelname1.attribute1', 'appname1.modelname2.attribute2', 'appname2.modelname3.attribute3', ...) Then hooks their post_save signal to update some other fixed model depending on the attributeN defined. I would like to test this behaviour and tests should work even if this app is the only one in the project (except for its own dependencies, no other wrapper app need to be installed). How can I create and attach/register/activate mock models just for the test database? (or is it possible at all?) Solutions that allow me to use test fixtures would be great.

    Read the article

  • django-haystack ordering - How do I handle this?

    - by Bartek
    Hi there, I'm using django-haystack for a search page on my site. I'm basically done, but not quite happy with the ordering and not quite sure how haystack decides how to order everything. I know I can over-ride the SearchQuerySet by using order_by but that over-rides it entirely. Let's say I want to force the search to order by in stock (BooleanField), so that the products that are in stock show up on top, but then do everything else as it normally would. How do I do that? I tried doing order_by('-in_stock', 'content') figure content was what it used by default but it produces very different results from if I just leave it to do its own ordering. Thanks for any input on this matter!

    Read the article

  • Django queries Especial Caracters

    - by Jorge Machado
    Hi, I Working on location from google maps and using django to. My question is: I have a String in request.GET['descricao'] lets say it contains "Via rapida". In my database i have store = "Via Rápida" i'm doing : local = Local.objects.filter(name__icontains=request.GET['descricao']) with that i can get everthing fine like "Via Rapida" but the result that have "Via rápida" never get match in the query (ASCI caracter may be ?) what must i do given a string "Via rapida" match "via rápida" and "via rapida" ? Regular Expressions ? how ? Thanks

    Read the article

  • user model password field default password field in django

    - by imran-glt
    Hi, I've created a custom user model in my application. This user model is working fine, but there are a couple of problems I have with it. 1) The change password link in the my register.html page doesn't work? 2) The default password box on the add/edit page for a user is a little unfriendly. Ideally, what I'd like is the two password fields from the change password form on the add/edit user form in the admin, which will automatically turn convert the entered password into a valid encrypted password in Django. This would make the admin system MUCH friendlier and much more suited to my needs, as a fair number of user accounts will be created and maintained manually in this app, and the person responsible for doing so will likely be scared off at the sight of that admin field, or just type a clear text password and wonder why it doesn't work. Is this possible / How do I do this?

    Read the article

  • Can this be done with the ORM? - Django

    - by RadiantHex
    Hi folks, I have a few item listed in a database, ordered through Reddit's algorithm. This is it: def reddit_ranking(post): t = time.mktime(post.created_on.timetuple()) - 1134000000 x = post.score if x>0: y=1 elif x==0: y=-0 else: y=-1 if x<0: z=1 else: z=x return (log(z) + y * t/45000) I'm wondering if there is any clever way of using Django's ORM, in order to UPDATE the models in bulk. Without doing this: items = Item.objects.filter(created_on__gte=datetime.now()-timedelta(days=7)) for item in items: item.reddit_rank = reddit_rank(item) item.save() I know about the F() object, but I can't figure out if this function can be performed inside the ORM. Any ideas? Help would be very much appreciated!

    Read the article

  • Porting Django's templates engine to C

    - by sandra
    Hi folks, I recently wrote a simple and tiny embedded HTTP server for my C++ app (QT) and I played a little bit with Ry's http-parser and loved it. This guy is crazy. So I told to myself: "Hey! Why not port the django template engine to C?" That'd be awesome! I know, it won't be an easy task (not at all, I know) but I'd really love to implement this. So I came here for inspiration, ideas, opinions... I'd really love to have some pointers on the subject, ideas, what is already done, which major problems I'll encounter (and how to solve them) - How not to reinvent the wheel... anyway, you got the idea :) Thanks a million times! P.S. Simple code snippets, and links to tools and libs are very welcome! P.P.S. I'm already aware of grantlee, I took a look into its sources. Well... that's C++ and its specific to Qt.

    Read the article

  • How to limit choice field options based on another choice field in django admin

    - by umnik700
    I have the following models: class Category(models.Model): name = models.CharField(max_length=40) class Item(models.Model): name = models.CharField(max_length=40) category = models.ForeignKey(Category) class Demo(models.Model): name = models.CharField(max_length=40) category = models.ForeignKey(Category) item = models.ForeignKey(Item) In the admin interface when creating a new Demo, after user picks category from the dropdown, I would like to limit the number of choices in the "items" drop-down. If user selects another category then the item choices should update accordingly. I would like to limit item choices right on the client, before it even hits the form validation on the server. This is for usability, because the list of items could be 1000+ being able to narrow it down by category would help to make it more manageable. Is there a "django-way" of doing it or is custom JavaScript the only option here?

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >