Posts by Ricardo • 5,680 points
191 posts
-
1
votes1
answer82
viewsA: Error when using multiple Bds in Django
You need to remove the 'default': {},. He’s trying to find the configuration of "ENGINE" in that dictionary and can’t. I suggest you leave the default as your writing database and create one with…
-
1
votes1
answer509
viewsA: How to Serialize more data from more than one table in Django Rest-framework
First name for your relationship to make it easier to understand: class CartItem(models.Model): product = models.ForeignKey(Product, null=True, on_delete=models.PROTECT) qtd = models.IntegerField(…
-
0
votes2
answers295
viewsA: Foreignkey using User in other models
You take the client from the form, with this you will not display anything from the client class QuotationForm(forms.ModelForm): class Meta: model = Quotation fields = ('date_create', 'date_update',…
-
2
votes1
answer26
viewsA: Attributeerror at /posts/add/ 'Postform' Object has no attribute 'cleaned_data'
The cleaned_data only exists after the is_valid() is called. In your case you are about writing the method and running here: image = self.cleaned_data.get('image') Only at that moment you didn’t…
-
1
votes2
answers93
viewsA: Checking an element in a list of tuples using the in command, only one parameter observed in python
A simple way with in would be: lista = [('joao', 13), ('maria', 20), ('carlos', 30)] "carlos" in [x[0] for x in lista] True UPDATING: According to Anderson’s comment, it would look better as…
-
1
votes2
answers74
viewsA: Problem when displaying routes in Root Api
You’re right when you say only the first urls of your + appear on the site. This is because you are using the DefaultRouter in all apps and then doing the import and the new list from the .urls.…
-
0
votes1
answer420
viewsA: queries in Django’s views and template
The query would be like this: Cliente.objects.filter(animal__isnull=True).all() You can reference the foreign key directly.
-
2
votes1
answer23
viewsA: Triggers for date verification
You can use Event Scheduler Scheduled tasks of this type are also sometimes known as " time triggers " A small example can be found in documentation theirs: CREATE EVENT [IF NOT EXIST] event_name ON…
-
0
votes3
answers3838
viewsA: Validate an HTML form with JAVASCRIPT
You can use the required It’s not a pop up like you asked, but it’s quite useful for a basic form. <form> <fieldset><legend>Teste</legend> Informe seu nome: <input…
-
2
votes2
answers88
viewsA: Email Differentiating two environments in the system
A solution I often see for this type of problem is to put a key in the web.config. <appSettings> <add key="ambiente" value="HOMOLOGAÇÃO" /> ... </appSettings> Then you take it and…
-
1
votes1
answer261
viewsA: Callback from reCaptcha when user misses
There is no. Here you can see his documentation. https://developers.google.com/recaptcha/docs/display What I use is the grecaptcha.getResponse to know if it has already validated or not. If…
-
3
votes2
answers1157
viewsA: exceeded the 'max_user_connections' Resource
Assuming you’re using the Mysqlconnection then you should be able to do so: try { //ABRINDO CONEXAO01 MySqlConnection conexão01= ClassConexao.ObterConexao(); MySqlCommand _comandoSel = new…
-
6
votes2
answers342
viewsA: Filter for the next 90 days ASP.NET MVC
You can do it like this: DateTime filtro = DateTime.Now.AddDays(90); var r = db.SiteContexto.Where(x => x.DataEnvio < filtro && x.DataEnvio > DateTime.Now).ToList(); Get all records…
-
0
votes1
answer127
viewsQ: background-image: url( with a URL that has parentheses with Django template
I have a div as follows: <div style='background-image: url({{ OBJETO.URL }})' class="video-thumb"></div> Where Objeto.url deliver a string like this:…
-
2
votes1
answer652
viewsA: Ajax redirection on ASP.NET MVC
Redirect to ajax success: $.ajax({ url: minhaurl, data: $("#meuform").serialize(), type: 'post', success: function (data) { window.location.href = "@Url.Action("Index", "Home")"; } }); With this you…
-
2
votes1
answer52
viewsA: What am I doing with this method?
Imagine that your object Categoria has a field ind_exclusao, beyond the fields CategoriaId and Nome. Imagine you have a view to edit a category where you can change its name. That one view has a…
-
1
votes1
answer395
viewsA: How to fill in an Editorfor as the login user name
When you put a note of [Required] and uses the EditFor he will create the imput with data-val="true" that will already make this validation for you. When you did the @Html.EditorFor(model =>…
-
2
votes1
answer138
viewsA: When changing a Model, how to redo Scaffolding?
You have to delete what has already been created and create again. The act of editing the unchanged model that has already been created. Remembering that the inclusion of an annotation in the model…
-
6
votes2
answers468
viewsA: What is the corresponding timestamp variable type (SQL Server) in C#?
You can use the type byte annotated TimeStamp [Timestamp] public byte[] RowVersion { get; set; } Look at that one tutorial to better understand.…
-
1
votes2
answers673
viewsA: How to redirect if user is unauthorized
To demonstrate what @Murilo said in the comment: [Authorize] public ActionResult Index() { return View(); } The [Authorize] redirects by default to login. Change it to use the [PermissoesFiltro]…
-
11
votes4
answers9085
viewsA: NOT operator in python
It’s up to not Creates a file .py with the code below and wheel. def tem_vaga(quantidade): if quantidade == 3: return False return True def adiciona_perfis(): quantidade = 3 if (not…
-
6
votes5
answers711
viewsA: Change Divs with the same class
You have to do the Concat for each one, the suggestion here is to do with the each: $(document).ready(function(){ var valor = $('.valor').each(function(){ val = $(this).html() $(this).html(val +…
-
0
votes3
answers860
viewsA: Is it possible to call the same method in all Controller Asp.. net mvc without having to repeat the code?
One of the ways to reuse code between controllers would be with inheritance I don’t know if it would be ideal to change the language, but I will keep the answer focused on the question that is to…
-
1
votes3
answers431
views -
0
votes1
answer82
viewsA: Task em await Task.Whenall New transaction is not allowed because there are other threads running in the Session
You can’t do two hits async in the same context at the same time: public static async Task ExecutaTarefasAsync(IEnumerable<Urls> registros) { var urlTasks = registros.Select((registro, index)…
-
0
votes2
answers174
viewsA: How to write the date and time of an error in the Django log?
I took the data from this reply: The official logging documentation is that one. Examples: # create formatter formatter = logging.Formatter("%(asctime)s;%(levelname)s;%(message)s", "%Y-%m-%d…
-
2
votes2
answers402
viewsA: Calculate select field values from a form
Can make that way: $('select').change(function(){ var sum = 0; $('select :selected').each(function() { sum += Number($(this).val()); }); $("#valorTotal").val(sum); }); <script…
-
1
votes2
answers179
viewsA: Checking date within a range in SQL
In that Fiddle you see working Scheme: create table teste ( NmrCnt varchar(200), DataTrm DATETIME DEFAULT NULL); insert into teste VALUES (1, GETDATE()); insert into teste VALUES (2, (dateadd(dd,…
-
4
votes2
answers807
viewsA: Limit total options in select - PHP
You can do by javascript: Look at this Fiddle $( "#send" ).click(function() { var count = $("#options :selected").length; alert( count ); }); <script…
-
1
votes2
answers1265
viewsA: Visual Studio copy file to output directory
According to this documentation, that I think applies to your case tb, this exited with code 1 is: No files Were found to copy. This command below is how I copy in a project of mine, it works…
-
2
votes2
answers358
viewsA: Ping on server with C#
There is this class Ping public class PingExample { // args[0] can be an IPaddress or host name. public static void Main (string[] args) { Ping pingSender = new Ping (); PingOptions options = new…
-
1
votes3
answers367
viewsA: Run a SELECT JOIN with conditions for different tables
For Mysql you could do an IF in Select: IF(ISNULL(b.nome), c.nome, b.nome) as nome I’m not absolutely sure about the syntax, but the IF in select can solve it easily. UPDATING. I changed the above…
-
2
votes2
answers560
viewsA: datepicker does not work in dynamic form with Js
You need to redo the bind of the new element. Look at the example below: function FazBind() { $('.data').datepicker({ 'autoclose': true }); } function adicionarCampos() { var objSelect =…
-
0
votes1
answer90
viewsQ: Annotation to create Index Unique that accepts null with EF Code First
I want to create the following Index in a table by annotation: CREATE UNIQUE NONCLUSTERED INDEX idx_yourcolumn_notnull ON YourTable(yourcolumn) WHERE yourcolumn IS NOT NULL; SQL source above. The…
entity-framework-6asked Ricardo 5,680 -
8
votes2
answers497
viewsA: How to concatenate two Data?
So I tried with ISNULL() Here worked: DECLARE @DATA1 DATETIME = GETDATE(), @DATA2 DATETIME select Convert(nvarchar(50),@DATA1 , 121) +'|'+ isnull(Convert(nvarchar(50), @DATA2, 121),'')…
-
2
votes2
answers223
viewsQ: @Html.Checkboxfor Works on GET, but not on POST
I have the following model: public class MEUViewModel { public List<Obj1> Obj1s { get; set; } public List<Obj2> Obj2s { get; set; } public int IDMeu { get; set; } public int IDMeu2 {…
-
1
votes3
answers8281
viewsA: How to delete structure and data from mysql database
You can kill the entire database and redo it with the same name: DROP database 'meudatabase'; CREATE database 'meudatabase'; If you have a scritp to create the entire database better yet, something…
-
2
votes1
answer419
viewsA: How to select Count(*) with Python and mysql.Nector
Since it’s a Count you don’t need to use the for to get the data. Another thing is that the total is not a whole, it is a tuple Anyway do it like this: cur.execute("""SELECT COUNT(*) as total FROM…
-
3
votes1
answer509
viewsA: How to change web.config when running Deploy?
You can use the Web.Release.config where changes can be made at the time of publication. In the link above it has an example of how it works, worth a read, it is very cool. A practical example of it…
-
2
votes2
answers102
views -
7
votes3
answers49197
viewsA: How to use the output of a select to mount another?
Does right: select * from (select * from TABELA1) AS r where r.campo = 'eu' UPDATE MADE AFTER UPDATE OF QUESTION Your sub query returns a table with a column, to use this in select from the outside…
-
2
votes1
answer1246
viewsA: Update multiple records with Entityframework
There are some ways to update, I got the code below of that answer: var ls=new int[]{2,3,4}; using (var db=new SomeDatabaseContext()) { var some=…
-
3
votes2
answers864
views -
2
votes3
answers4197
viewsA: Select from two tables without repeating data
I’m putting an answer because in the comment will get very bad make the table I want to put example. What you’re saying is a problem is actually the "right". Let’s take a practical example: User…
-
1
votes2
answers1012
viewsA: Function with return using 'case when'
Running on the Sqlserver case that’s how it is: SELECT CASE WHEN [colunainteira] = 1 THEN 'um' WHEN [colunainteira] = 0 THEN 'zero' END FROM ...…
-
2
votes1
answer164
views -
8
votes2
answers1387
viewsA: Simplify LINQ query with Contains
First let’s understand the SQL that each of them generates: The contains is a WHERE id in (). When executing a query like this: db.TABELA.Where(p => ids.Contains(p.ID)).ToList(); The generated…
-
4
votes1
answer1267
viewsA: problem when installing Django
First you need to install the Python. Download it into the official website. When installing check the box Add Python 3.5 to PATH and installs. After installing the Python this way he will be listed…
-
1
votes1
answer594
viewsA: Problems sending e-mail Asp.net.mvc
With yahoo I’d be like this: SmtpClient smtp = new SmtpClient("smtp.mail.yahoo.com", 587); smtp.Credentials = new System.Net.NetworkCredential ("[email protected]", "senha"); smtp.EnableSsl = true;…
-
6
votes2
answers3060
viewsA: Delete line from a list in C#
From what I understand you want to do a validation on the list item mylistnova1 and if validated then you delete it from the list. In this case you cannot delete from a list that is in the loop, for…